Skip to content

Deepen coverage 4x: 15 new demos, 741 new tests, error-path hardening#6

Open
cognis-digital wants to merge 1 commit into
mainfrom
feature/depth-4x-tests-demos-hardening
Open

Deepen coverage 4x: 15 new demos, 741 new tests, error-path hardening#6
cognis-digital wants to merge 1 commit into
mainfrom
feature/depth-4x-tests-demos-hardening

Conversation

@cognis-digital

Copy link
Copy Markdown
Owner

Summary

Roughly 4x the depth of the repo across tests, demos, and error handling — all real work, public API unchanged.

Tests: 232 → 973 (all green)

New edge-case / error-path suites:

  • test_core_edgecases — malformed/hostile observation records, unknown/absent families, empty feeds & batches, JSON/JSONL parser robustness, threshold behavior, determinism.
  • test_rules_edgecases — Sigma UUID / Suricata SID determinism, families with no strong indicator, custom DBs, SID-band invariants.
  • test_cli_errors + test_cli_integration — the exit-code contract (0/1/2), missing files, bad output paths, and a scan/correlate matrix over every bundled fixture in all output formats.
  • test_mcp_server — the stdlib MCP server: scan/correlate/list_signatures + JSON-RPC initialize/tools/list/tools/call dispatch and error paths.
  • test_datafeeds — cache freshness, offline-miss error path, format parsing, air-gap snapshot export/import round-trip.
  • test_probe_integration — authorized active probe via an injected connector: authorization/scope refusal, CIDR & pinned-port scope, connection-error handling, rate limiting, sweep skipping, CS attribution.
  • test_ai_backend — opt-in backend disabled-by-default, JSON-array extraction (fenced/prose/<think>), finding normalization, never-raises contract.
  • test_db_coverage — parametrized per-family self-detection + rule validity across the whole DB.
  • test_matching_engine, test_reporting_edgecases, test_correlate_edgecases, test_selfcheck_edgecases, test_connect_edgecases, test_public_api.

Demos: 5 → 20 audience scenarios

SARIF/code-scanning, CI gate, HTML report, status badge, JSONL ingest, free-text triage, correlation graph, threshold tuning, signature inventory, self-check, layered feeds+signatures, beacon cadence, per-family Sigma, campaign gate, and a full air-gap workflow. Each runs fully offline and exits 0. run_all.py, tests/test_demos.py, and docs/DEMOS.md updated.

Fixes (public API unchanged)

  • cli rules -o <bad-path> raised an uncaught FileNotFoundError (ugly traceback); now prints a clear error and returns exit 2, matching the scan/correlate error paths.
  • mcp_server scan/correlate silently coerced threshold=0 to 35 via an x or 35 fallback (0 is falsy); added _coerce_threshold so an explicit 0 (report everything) is honored, matching the core/CLI contract.
  • .gitignore — the !demos/** negation was un-ignoring demos/__pycache__/*.pyc; re-excluded compiled artifacts.

Verification

  • python -m pytest -q973 passed
  • python -m c2detect self-check → HEALTHY (rc 0)
  • PYTHONUTF8=1 python demos/run_all.py → rc 0; all 20 demos also pass standalone

Tests: 232 -> 973 (all green). New suites cover malformed/hostile
observation records, unknown/absent C2 families, empty feeds and batches,
JSON/JSONL parser robustness, rule-gen determinism (stable Sigma UUIDs +
Suricata SIDs), the CLI exit-code contract and error paths, the stdlib MCP
server (scan/correlate/list + JSON-RPC dispatch), the datafeeds cache and
air-gap snapshot round-trip, the authorized active probe (injected
connector: scope/rate-limit/error handling), the opt-in AI backend
(disabled-by-default + JSON extraction + never-raises), per-family DB
detection, a CLI integration matrix over every bundled fixture, and the
public API surface.

Demos: 5 -> 20 audience scenarios (SARIF/code-scanning, CI gate, HTML
report, status badge, JSONL ingest, free-text triage, correlation graph,
threshold tuning, signature inventory, self-check, layered feeds+signatures,
beacon cadence, per-family Sigma, campaign gate, air-gap workflow). Each
runs fully offline and exits 0; run_all.py, tests/test_demos.py and
docs/DEMOS.md updated.

Fixes (public API unchanged):
- cli rules -o <bad-path>: raised an uncaught FileNotFoundError; now prints
  a clear error and returns exit 2, matching the scan/correlate error paths.
- mcp_server scan/correlate: threshold=0 was silently coerced to 35 by an
  `x or 35` fallback (0 is falsy); added _coerce_threshold so an explicit 0
  (report everything) is honored, matching the core/CLI contract.
- .gitignore: the `!demos/**` negation was un-ignoring demos/__pycache__/*.pyc;
  re-excluded *.pyc and **/__pycache__/ so compiled artifacts stay out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant