Skip to content

test(security): pin the finding fingerprint and run-store digest to literal values #855

Closed

Description

@dan-petty

Context & Rationale

Two digests are persisted outside the PR that computes them.

NormalizedFinding.fingerprint (security/normalization.py:150-160):

  • It is sha256 over tool, rule_id, path and the canonical message, joined by '␟' and truncated to the first 32 hex characters.
  • Suppression policies store it and match it only on exact equality (security/suppression.py:59-60).
  • SARIF emits it as partialFingerprints under devopsCli/v1 (config/constants.py:2030).

run_store.digest (ai/run_store.py:54-57):

  • It names stored baselines: {subject_key}.json (:430, :447) and the Valkey keys (:267, :302).
  • Subjects embed digest() values (commands/review.py:1599, benchmark.py:183, prompt_eval.py:193).

Tests check only relations, such as line-insensitivity and round-trip (tests/test_security_sarif.py:227-255). A refactor that reorders the hashed parts, or changes the separator, the canonicalisation or the json.dumps options, passes every test while silently reopening every suppression and orphaning every stored baseline.

Scope & Deliverables

  • Deliverable:
    • In tests/test_security_sarif.py:
      • 3-4 fixed NormalizedFinding inputs pinned to literal 32-hex fingerprints;
      • an assertion that CONST_SARIF_FINGERPRINT_KEY is devopsCli/v1, with a comment stating the rule: an algorithm change bumps the key, updates the pins and adds a CHANGELOG line in the same commit;
      • a golden tests/golden/sarif_report.json, compared with to_sarif output and validated against tests/fixtures/sarif-schema-2.1.0.json.
    • In tests/test_run_store.py: literal digests for 2 fixed dicts.
  • Acceptance criteria:
    • Swapping two hashed parts, changing the separator or changing the canonicalisation fails the fingerprint pin.
    • Changing digest()'s json.dumps options fails the run-store pin.
    • The golden SARIF file validates against the schema and equals to_sarif output.
    • The new tests run in at most 1 s, with no new dependency.
  • Key questions: none.
  • Constraint: none beyond the version-key rule above.

Strategic Alignment

  • Milestone: Backlog
  • Depends on: none

Activity

  1. added
    type/test
    scope/security
    priority/p2-medium
    on Oct 1, 2026
  2. added this to the v0.2.31 milestone on Oct 8, 2026
  3. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.31 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: finding identity v2, URL credential masking, tests that leave no state, the Docker endpoint check and the Argo CD/OTel perimeters. Position 1 of 10 in the release's planned merge order. This item still needs refinement before its release starts (see the planning note), so its board Status stays New.

  4. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1478, merged into release/v0.2.31 as 80d418c.

    Resolves #855

    5 file(s) changed.

    How it was verified

    Check runs at 5b62b3b:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-855-pin-fingerprint-and-digest.md:

    • Fingerprint pins in tests/test_security_sarif.py:
      • Pinned 4 fixed NormalizedFinding inputs (covering line-based, symbol-based, multi-tool, and canonical message variation) to literal 32-hex SHA-256 fingerprints (test_finding_fingerprints_are_pinned_to_literal_values).
      • Added assertion that CONST_SARIF_FINGERPRINT_KEY == "devopsCli/v1" with documentation that an algorithm change bumps the key, updates the pins, and adds a CHANGELOG line in the same commit (test_sarif_fingerprint_key_pinned).
      • Verified that swapping hashed parts, changing the separator, or altering message canonicalisation breaks the fingerprint pin (test_swapping_parts_or_changing_separator_or_canonicalisation_alters_fingerprint).
    • Golden SARIF report:
      • Added golden SARIF report tests/golden/sarif_report.json.
      • Asserted to_sarif output equals the golden report, and validated the golden document against tests/fixtures/sarif-schema-2.1.0.json (test_golden_sarif_report_matches_and_validates_against_schema).
    • Run-store digest pins in tests/test_run_store.py:
      • Pinned run_store.digest to literal 16-hex SHA-256 digests for 2 fixed dicts (test_digest_pinned_to_literal_values).
      • Verified that altering json.dumps serialization options changes the digest (test_digest_fails_when_json_options_differ).
    • Performance & dependencies:
      • The new tests execute in < 1 second with zero new dependencies added.
    • Changelog:
      • Added changelog fragment changelog.d/855.md under ### Security.
    • uv run devops ci passes.
  5. added a commit that references this issue on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/securitytype/test

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions