Skip to content

Deepen fedramplens 4x: tests, demos, hardening + bug fixes#5

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

Deepen fedramplens 4x: tests, demos, hardening + bug fixes#5
cognis-digital wants to merge 2 commits into
mainfrom
feature/depth-4x-tests-demos-hardening

Conversation

@cognis-digital

Copy link
Copy Markdown
Owner

Quadruples the depth of the repo with real work; public API unchanged.

Tests: 53 -> 242 test functions (all green, python -m pytest -q)

  • test_core_validation.py — exhaustive boundary/component/flow/POA&M validation, malformed-file error paths, direct-dataclass hardening.
  • test_analysis.py — SC-8 crossing detection (both directions, external tokens, missing encrypted key), dangling flows, orphan components, POA&M overdue/risk/date handling, coverage math, authorization gate, summary shape.
  • test_oscal.py — OSCAL SSP + POA&M output shape, deterministic uuids, control-id normalization, DOT structure/escaping.
  • test_sarif_edge.py — SARIF envelope, rule de-duplication, severity→level mapping + rule-default escalation, preserved properties, empty/robust findings.
  • test_cli.py — every subcommand, all output formats, exit codes (0/1/2), error paths.
  • test_datafeeds.py — catalog, cache/age metadata, offline get() contract, snapshot export/import round-trip, control normalization + enhancement fallback, graceful degrade.

All new tests are stdlib-only and never touch the network (offline OSCAL fixture cache).

Demos: 5 -> 20 runnable scenarios (each exits 0 under PYTHONUTF8=1)

Added scenarios 06–20: AO risk dashboard, CI gate + SARIF upload, control-coverage report, POA&M tracker, external-dependency inventory, boundary hygiene lint, High-baseline walkthrough, JSON pipeline integration, air-gap snapshot transfer, enrichment graceful-degrade contract, SARIF rule catalogue, diagram export formats, OSCAL SSP deep-inspect, error-handling showcase, and a full-package pipeline capstone. run_all.py and docs/DEMOS.md updated.

Error handling + real bug fixes (public API stable)

  1. Uncaught KeyError in analyze_boundary — a Boundary built directly via the public dataclass with an out-of-range/uppercased impact, or a POA&M severity outside the weight table, leaked a raw KeyError. Now impact is normalized (and an out-of-range value raises a clear BoundaryError), and an unknown severity is weighted as moderate.
  2. POA&M date validation gap — the scheduled-date parse only ran inside the open branch, so a malformed date on a closed item was silently accepted. Validation now runs on every item; bad_poam_date is surfaced regardless of status.
  3. Loose type validation_build_boundary now rejects non-dict components/flows/POA&M items and a non-list controls field with precise errors.
  4. SARIF rule default level — a rule's defaultConfiguration.level reflected only the first finding of its type; it now escalates to the most severe. Exporter also tolerates findings missing type/severity/detail.
  5. CLI — catches a late BoundaryError from analyze/ssp/poam and exits 2 with a clear message.

Version bumped 0.4.9 -> 0.5.0.

Tests (53 -> 242 test functions, all green):
- test_core_validation.py: exhaustive boundary/component/flow/POA&M
  validation + malformed-file error paths + direct-dataclass hardening
- test_analysis.py: SC-8 crossing detection (both directions, tokens,
  missing key), dangling flows, orphans, POA&M overdue/risk/date, coverage
  math, authorization gate, summary shape
- test_oscal.py: SSP + POA&M output shape, deterministic uuids, control-id
  normalization, DOT structure/escaping
- test_sarif_edge.py: envelope, rule de-dup, level mapping + rule-default
  escalation, preserved properties, empty/robust findings
- test_cli.py: every subcommand, all formats, exit codes, error paths
- test_datafeeds.py: catalog, cache/age, offline get contract, snapshot
  round-trip, control normalization/fallback, graceful degrade

Demos (5 -> 20 runnable scenarios, each exits 0):
- Added 06-20 covering AO risk dashboard, CI gate, coverage report, POA&M
  tracker, dependency inventory, hygiene lint, High-baseline walkthrough,
  JSON pipeline, air-gap snapshot transfer, enrichment degrade contract,
  SARIF rule catalogue, diagram export, SSP deep inspect, error-handling
  showcase, and a full-package pipeline capstone
- run_all.py + docs/DEMOS.md updated

Hardening + real bug fixes (public API unchanged):
- analyze_boundary raised an uncaught KeyError when a Boundary was built
  directly via the public dataclass with (a) an out-of-range/uppercased
  impact or (b) a POA&M severity outside the weight table. Now normalizes
  impact and raises a clear BoundaryError, and tolerates unknown severity
  as moderate.
- POA&M scheduled-date validation now runs on every item (open or closed),
  so a malformed date is surfaced as bad_poam_date regardless of status.
- _build_boundary rejects non-dict components/flows/POA&M items and a
  non-list controls field with precise errors.
- to_sarif escalates a rule's default level to the most severe finding of
  its type and tolerates findings missing type/severity/detail.
- CLI catches late BoundaryError from analyze/ssp/poam (exit 2).
… PR)

The config used the deprecated v4 flat glob syntax; labeler@v5 requires
each label to be an array of config options with changed-files /
any-glob-to-any-file. It errored 'found unexpected type for label docs'
on every pull_request_target run. Migrated all rules and added a demos label.
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