935008ec3f
Añade el capability group `recon` (dominio cybersecurity + pipelines, Python),
con la política de archivado OSINT y página madre docs/capabilities/recon.md.
Lookups y sondeo (wrappers de CLI):
- whois_lookup, rdap_lookup, dns_records, ping_host, traceroute_host, nmap_scan
- save_scan_to_osint (sink común) + recon_osint (pipeline one-shot scan+archivado)
Escaneo de puertos/servicios nativo (stdlib, sin nmap ni sudo):
- scan_tcp_ports: connect-scan TCP concurrente (open/closed/filtered)
- grab_service_banner: banner grab + identificación de servicio/versión real
- identify_port_service: puro, puerto -> servicio IANA esperado (~120 puertos)
- scan_port_services: pipeline one-shot (scan -> identify + banner por puerto abierto)
Fingerprint de tecnología web (estilo Wappalyzer), patrón pura/impura:
- fetch_http_fingerprint: GET stdlib, recoge headers/html/cookies (solo nombres)
- detect_web_tech: puro, matchea ~50 firmas regex -> tecnologías por categoría
- fingerprint_web_stack: pipeline one-shot url -> tecnologías
Todas devuelven dict {status} sin lanzar. Tests: 43 verdes, sin red externa.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
83 lines
3.9 KiB
Markdown
83 lines
3.9 KiB
Markdown
# Sink — Funciones que escriben datos a destinos externos
|
|
|
|
Tag: `sink`. Grupo de funciones que **escriben** datos a un destino externo: BD, archivo, dashboard, alerta, email. Input: datos. Output: efecto observable. Ultimo eslabon del flujo en `data_factory` (analogia Factorio = rocket silo).
|
|
|
|
Filtro MCP: `mcp__registry__fn_search query="" tag="sink"`.
|
|
|
|
## Funciones del grupo
|
|
|
|
| ID | Lang | Destino |
|
|
|---|---|---|
|
|
| [bq_insert_rows_py_infra](../../python/functions/infra/bq_insert_rows.md) | py | BigQuery streaming insert |
|
|
| [bq_load_from_file_py_infra](../../python/functions/infra/bq_load_from_file.md) | py | BigQuery batch load (file) |
|
|
| [bq_load_from_gcs_py_infra](../../python/functions/infra/bq_load_from_gcs.md) | py | BigQuery batch load (GCS) |
|
|
| [bq_export_to_gcs_py_infra](../../python/functions/infra/bq_export_to_gcs.md) | py | BigQuery -> GCS export |
|
|
| [metabase_create_card_py_infra](../../python/functions/infra/metabase_create_card.md) | py | Metabase saved question |
|
|
| [metabase_export_card_py_infra](../../python/functions/infra/metabase_export_card.md) | py | Metabase card export (CSV/Excel) |
|
|
| [metabase_create_dashboard_subscription_py_infra](../../python/functions/infra/metabase_create_dashboard_subscription.md) | py | Dashboard email subscription |
|
|
| [metabase_create_card_alert_py_infra](../../python/functions/infra/metabase_create_card_alert.md) | py | Card alert (threshold/schedule) |
|
|
| [http_post_json_py_infra](../../python/functions/infra/http_post_json.md) | py | HTTP JSON POST |
|
|
| [http_post_json_go_infra](../../functions/infra/http_post_json.md) | go | HTTP JSON POST |
|
|
| [db_insert_row_go_infra](../../functions/infra/db_insert_row.md) | go | SQL row insert |
|
|
| [save_scan_to_osint_py_cybersecurity](../../python/functions/cybersecurity/save_scan_to_osint.md) | py | Vault Obsidian (nota) + osint_db (DuckDB via HTTP) — sink de scans de red |
|
|
|
|
## Ejemplo canonico
|
|
|
|
Persistir resultados a BigQuery + crear card Metabase + alerta.
|
|
|
|
```python
|
|
from infra import bq_insert_rows, metabase_create_card, metabase_create_card_alert
|
|
|
|
# 1. Insertar filas a BQ
|
|
bq_insert_rows(
|
|
project_id="my-gcp-project",
|
|
dataset_id="analytics",
|
|
table_id="daily_kpis",
|
|
rows=results,
|
|
)
|
|
|
|
# 2. Card en Metabase apuntando a esa tabla
|
|
card = metabase_create_card(
|
|
name="Daily KPIs",
|
|
sql="SELECT * FROM `my-gcp-project.analytics.daily_kpis` WHERE date >= CURRENT_DATE() - 7",
|
|
database_id=3,
|
|
)
|
|
|
|
# 3. Alerta si la metrica clave cae
|
|
metabase_create_card_alert(
|
|
card_id=card["id"],
|
|
threshold={"goal": 100, "above_goal": False},
|
|
schedule="hourly",
|
|
)
|
|
```
|
|
|
|
## Fronteras del grupo
|
|
|
|
NO cubre:
|
|
- **Extract** (leer de fuente externa) -> [[extractor]].
|
|
- **Transform** (modificar datos sin efectos externos) -> [[transformer]].
|
|
- Escritura a la BD interna del registry (`registry.db`, `operations.db`) — tag `registry` o equivalente.
|
|
- Deploy de codigo (eso es `deploy`).
|
|
- Logs / telemetria propia (van a `call_monitor.db`, no son sinks de pipeline).
|
|
|
|
## Cuando NO usar `sink`
|
|
|
|
- Si la funcion escribe pero los datos NO salen del proceso actual (cache en memoria) -> no es sink.
|
|
- Si la funcion devuelve algo al caller sin efecto externo -> es transformer.
|
|
|
|
## Side effects observables
|
|
|
|
Por definicion, todos los sinks son **impuros** y tienen `error_type` definido. La salida del flujo data_factory es siempre visible: una fila nueva en BD, un email enviado, un dashboard actualizado.
|
|
|
|
## Consumidores
|
|
|
|
- `data_factory` — tab Sinks.
|
|
- `dag_engine` DAG steps con `function: <sink_id>`.
|
|
- Pipelines de produccion (con secrets de credenciales fuera del registry).
|
|
|
|
## Notas
|
|
|
|
- BQ load/insert/export todos como sink — escriben a recurso externo.
|
|
- Metabase notifications (subscription + alert) son sinks "puros" en el sentido de que producen efectos sin cambiar datos.
|
|
- HTTP POST cuenta como sink solo cuando se usa para **enviar** datos (webhook, API target), no para "obtener via POST".
|