Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
184 lines
6.1 KiB
Markdown
184 lines
6.1 KiB
Markdown
<p align="center"><a href="../README.md">◂ Back to README</a></p>
|
|
|
|
# Terminal (CLI)
|
|
|
|
`harpia` is one binary covering both Docker Compose roles (`serve` and
|
|
`scanner`) plus every operator command. Every subcommand accepts `-h`/
|
|
`--help`.
|
|
|
|
## `harpia serve`
|
|
|
|
Runs the API server, batch ingestion, diff engine and the embedded
|
|
dashboard/executive report.
|
|
|
|
```
|
|
Usage: harpia serve [OPTIONS]
|
|
|
|
Options:
|
|
--bind <BIND> [default: 0.0.0.0:8788]
|
|
--config <CONFIG> [default: config/harpia.toml]
|
|
--sweeps <SWEEPS> [default: data/sweeps]
|
|
--data-dir <DATA_DIR> [default: data/harpia]
|
|
--admin-token <ADMIN_TOKEN> Token required by the API routes that change state.
|
|
Without it, a random token is generated at startup
|
|
and printed once [env: HARPIA_ADMIN_TOKEN]
|
|
```
|
|
|
|
This is the `harpia` Compose service's entrypoint.
|
|
|
|
Reads (`GET`) are open; the routes that change the configuration
|
|
(`POST`/`PUT`/`DELETE /api/config/groups…`) need the admin token in
|
|
`Authorization: Bearer <token>` or `X-Harpia-Token`, and a browser `Origin`, when
|
|
present, must match `Host`. Without `HARPIA_ADMIN_TOKEN`, `serve` prints a fresh
|
|
`http://…/?token=…` link at each start; opening it logs the dashboard in for
|
|
that tab.
|
|
|
|
`GET /metrics` serves Prometheus text: `harpia_build_info`,
|
|
`harpia_sweeps_ingested_total`, `harpia_assets{status}`, `harpia_open_ports`,
|
|
`harpia_findings{severidade}`, `harpia_kev_findings`, `harpia_vuln_db_cves`,
|
|
`harpia_feeds_last_sync_timestamp_seconds`, per-group
|
|
`harpia_last_sweep_{timestamp_seconds,duration_seconds,complete,events}` and
|
|
`harpia_webhook_deliveries_total{resultado}`. Like the other reads it needs no
|
|
token; an alert on `time() - harpia_last_sweep_timestamp_seconds` catches a
|
|
scanner that stopped.
|
|
|
|
## `harpia scanner`
|
|
|
|
Runs the continuous scheduler and scan engine, writing sweep batches,
|
|
never exits on its own, same lifecycle as a daemon.
|
|
|
|
```
|
|
Usage: harpia scanner [OPTIONS]
|
|
|
|
Options:
|
|
--config <CONFIG> [default: config/harpia.toml]
|
|
--out <OUT> [default: data/sweeps]
|
|
--data-dir <DATA_DIR> [default: data/harpia]
|
|
```
|
|
|
|
Picks the `nativo` (raw SYN) engine whenever a profile asks for it and
|
|
`CAP_NET_RAW` is actually usable, falling back to `nativo-sem-raw`
|
|
automatically otherwise, see [`architecture.md`](architecture.md#2-scan-engine).
|
|
This is the `scanner` Compose service's entrypoint.
|
|
|
|
## `harpia scan --group <name> --once`
|
|
|
|
Runs a single sweep for one group, for diagnostics; it writes a batch exactly
|
|
like `scanner` would, then exits.
|
|
|
|
```
|
|
Usage: harpia scan [OPTIONS]
|
|
|
|
Options:
|
|
--group <GROUP>
|
|
--once
|
|
--config <CONFIG> [default: config/harpia.toml]
|
|
--out <OUT> [default: data/sweeps]
|
|
--data-dir <DATA_DIR> [default: data/harpia]
|
|
```
|
|
|
|
```bash
|
|
harpia scan --group dmz --once --config config/harpia.toml --out data/sweeps --data-dir data/harpia
|
|
```
|
|
|
|
## `harpia config check`
|
|
|
|
Validates `harpia.toml` and prints, per group, the address count, effective
|
|
cron and any cadence overlap. Run this after every manual edit.
|
|
|
|
```
|
|
Usage: harpia config check [OPTIONS]
|
|
|
|
Options:
|
|
--config <CONFIG> [default: config/harpia.toml]
|
|
```
|
|
|
|
Exits non-zero on an invalid configuration, safe to use in a pre-push hook
|
|
or CI step, which is exactly what `scripts/check.sh` does.
|
|
|
|
## `harpia feeds sync` / `harpia feeds import`
|
|
|
|
```
|
|
Usage: harpia feeds <COMMAND>
|
|
|
|
Commands:
|
|
sync Download NVD and CISA KEV feeds incrementally
|
|
import Import feed files copied manually for isolated networks
|
|
```
|
|
|
|
```bash
|
|
# Live, one-shot sync (also happens automatically inside `serve` if
|
|
# padrao.feeds.sincronizar_automaticamente = true: see configuration.md)
|
|
harpia feeds sync --config config/harpia.toml --data-dir data/harpia
|
|
|
|
# Offline, for air-gapped networks
|
|
harpia feeds import ./nvd-dump --data-dir data/harpia
|
|
```
|
|
|
|
## `harpia changes --since <duration>`
|
|
|
|
Prints diff events (new/gone host, new/closed port, new/fixed
|
|
vulnerability) from the local state, the same data `/api/changes` serves.
|
|
|
|
```bash
|
|
harpia changes --since 24h --data-dir data/harpia
|
|
```
|
|
|
|
## `harpia export --format json|csv`
|
|
|
|
Exports the current deduplicated state (hosts, ports, findings), shares
|
|
its formatting logic with the `/api/export/*.csv` and `/api/hosts`
|
|
endpoints, so a terminal export and a dashboard download never drift apart.
|
|
|
|
```
|
|
Usage: harpia export [OPTIONS]
|
|
|
|
Options:
|
|
--format <FORMAT> [default: json]
|
|
--data-dir <DATA_DIR> [default: data/harpia]
|
|
--out <OUT>
|
|
```
|
|
|
|
```bash
|
|
harpia export --format csv --data-dir data/harpia --out hosts.csv
|
|
harpia export --format json --data-dir data/harpia # prints to stdout
|
|
```
|
|
|
|
## `harpia doctor [--json]`
|
|
|
|
Diagnoses the runtime environment; run this first when something looks
|
|
wrong, and always before reporting an issue (see
|
|
[`support.md`](support.md)).
|
|
|
|
```
|
|
Usage: harpia doctor [OPTIONS]
|
|
|
|
Options:
|
|
--json
|
|
--config <CONFIG> [default: config/harpia.toml]
|
|
--data-dir <DATA_DIR> [default: data/harpia]
|
|
```
|
|
|
|
```
|
|
$ harpia doctor
|
|
Harpia v1.0.0 - Diagnóstico do Ambiente
|
|
================================================================================
|
|
Item Status Detalhe
|
|
--------------------------------------------------------------------------------
|
|
versao ok harpia v1.0.0
|
|
config ok configuração válida (4 grupo(s))
|
|
net_raw ok CAP_NET_RAW disponível (motor nativo ativo)
|
|
sqlite ok banco SQLite acessível em data/harpia/harpia.db
|
|
vuln_db ok 135 CVE(s) carregados (12h atrás)
|
|
feeds_sync ok sincronizado há 12h (dentro do intervalo configurado)
|
|
--------------------------------------------------------------------------------
|
|
Resultado: OK
|
|
```
|
|
|
|
Exits `1` if any critical item (`config`, a missing database it needs to
|
|
write to) failed; a missing/stale vulnerability database or absent
|
|
`CAP_NET_RAW` are reported but don't fail the exit code; both have a
|
|
documented degraded path (see [`architecture.md`](architecture.md)).
|
|
`--json` is meant for scripted health checks and monitoring, not for
|
|
humans at a terminal.
|