Files
fn_registry/python/functions/datascience/render_sigma_html.md
T
egutierrez 99672a4745 feat: funciones datascience — ops_to_rdf_triples, ops_to_sigma_json, render_sigma_html
Conversión de operations.db a triples RDF y formato sigma.js, más
renderizado HTML standalone con dark theme y ForceAtlas2 layout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 22:03:51 +02:00

2.0 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports tested tests test_file_path file_path
render_sigma_html function py datascience 1.0.0 impure def render_sigma_html(graph_data: dict, output_path: str, title: str = 'OSINT Graph') -> str Genera un archivo HTML standalone con sigma.js v2.4 que visualiza un grafo OSINT. Aplica ForceAtlas2, dark theme, filtros por tipo de nodo y tooltip con metadata. Retorna el path absoluto del archivo escrito.
graph
sigma
osint
visualization
html
forceatlas2
network
dark-theme
ops_to_sigma_json_py_datascience
false error_go_core
json
os
false
python/functions/datascience/render_sigma_html.py

Ejemplo

from datascience.ops_to_sigma_json import ops_to_sigma_json
from datascience.render_sigma_html import render_sigma_html

graph = ops_to_sigma_json("apps/osint_analysis/operations.db")
path = render_sigma_html(graph, "/tmp/osint_graph.html", title="Red OSINT")
print(f"Abre en el browser: {path}")

Notas

Funcion impura — escribe un archivo en disco.

El HTML es completamente standalone: no necesita servidor web ni backend. Todos los assets se cargan desde jsDelivr CDN:

  • graphology 0.25.4
  • graphology-layout-forceatlas2 0.10.1
  • sigma 2.4.0

El JSON del grafo se embebe directamente en el <script> para evitar peticiones CORS al abrir desde file://.

ForceAtlas2 se ejecuta sincrono con 500 iteraciones antes de instanciar el renderer. Para grafos grandes (>500 nodos) considerar reducir iteraciones o usar barnesHutOptimize: true (que se activa automaticamente para grafos >300 nodos).

Panel lateral (fijo, top-right):

  • Titulo del grafo
  • Contador de nodos y aristas
  • Checkboxes de filtro por tipo (con color dot)

Tooltip (hover sobre nodo):

  • Label y tipo del nodo
  • status, domain
  • Todos los campos adicionales de metadata aplanados

Los caracteres especiales en labels y metadata se escapan correctamente para evitar XSS al abrir el HTML.