Skip to content

fix(security): each finding keeps its own fingerprint across unrelated edits, and deduplication and correlation give one result in every input order, in devops scan and in reviews #1141

Closed

Description

@dan-petty

Problem

Acceptance criteria

  • Fingerprint v2 for a result with a region = sha256 of:
    • tool and rule id;
    • repo-relative path;
    • the enclosing qualified symbol from the pre-analysis outline (<module> at module level);
    • a window hash over the first 100 non-whitespace characters starting at the flagged line.
    • An occurrence index is added only among results still equal on all of these.
  • A result without a region takes its identity from SARIF logicalLocations: kind/namespace/name[/container] for Kubernetes objects, and purl@version for advisories.
  • Stability tests:
    • a non-identical line and an identical line inserted above each leave every other fingerprint unchanged;
    • two distinct sites give two fingerprints;
    • inserting a tenth DaemonSet leaves the other nine objects' fingerprints unchanged.
  • deduplicate and devops scan keep all 3 rows of a fixture with 3 BLE001 hits in one file.
  • A tool's own partialFingerprints are kept as a property, not as identity.
  • correlation_key uses (path or logical location, overlapping region, CWE) [code: normalization.py:162-169].
  • A fingerprint suppression still matches after an edit above the line.
  • Fingerprint pins move here from test(security): pin the finding fingerprint and run-store digest to literal values #855: golden fingerprint pins and the rule that a change to the fingerprint inputs bumps the key are written against v2, not v1. test(security): pin the finding fingerprint and run-store digest to literal values #855 keeps its run_store.digest pins and its golden SARIF; this item updates the golden's fingerprints when it bumps the key.
  • fix(security): kube-linter findings carry their own check, message and manifest file, and scan reports keep each one #1045 (a P0 child that lands first) writes its symbol identity for symbol-located findings (kube-linter, Trivy, Pluto, Popeye, Dive) in this item's logicalLocations form (kind/namespace/name), so those findings change identity once. fix(security): kube-linter findings carry their own check, message and manifest file, and scan reports keep each one #1045 keeps its own fingerprint bullet.
  • Order independence (from feat(review): order-independent review finding consolidation with a permutation test #608). A test that fails before this item runs deduplicate and correlate over itertools.permutations of four fixtures, carried from feat(review): order-independent review finding consolidation with a permutation test #608 and re-expressed as normalized results with the same paths, lines and messages: the chained triple, a chain whose bridging finding sorts first, the fix(review): findings are lost between the model reply and the report #512 SQL-injection pair, and the recorded _watcher session. It asserts one distinct set of (fingerprint, location, severity, sorted tools) and, separately, one distinct output sequence. A test comparing entry counts does not count: _watcher has 3 entries in every order, and only the anchor and output order move.
  • Complete linkage. Input is pre-sorted by a total key (parsed path and start line, then rule id, then tool, then fingerprint). A finding joins a cluster only when the correlation key (path or logical location, overlapping region, CWE) holds against every original member, and members are merged after clustering. The bridging-first chain leaves 2 clusters in every order.
  • Deterministic picks. The representative and every scalar are chosen by highest severity, then narrowest parsed region, then the total key; list fields are sorted; the output order has location and rule tie-breaks. _watcher keeps k8s/informer.py:44-112 in every order, and parsed locations sort a.py:9 before a.py:10.
  • Stdlib only (itertools, no networkx).
  • (person-run) Offline replay: the finding lists reaching deduplicate and correlate in one feat(review): synthetic defect corpora for review evaluation #415 corpus run are captured, and the number of lists with more than one output across permutations is counted before and after, recorded in the task file.
  • (person-run) devops scan row counts over src/ before and after, plus the number of identities that needed an occurrence index, recorded in the task file.
  • Tests run offline with fakes and recorded tool output: no network, no real scanner, no model; each test under 1 s.
  • changelog.d/<n>.md records the change; CHANGELOG.md and docs/ROADMAP.md are not edited.
  • uv run devops ci passes.

Key questions

Strategic alignment

Update 2026-10-08: refinement

#871 shipped compute_fingerprint_v2 (review/fingerprint.py:26-60) for admission (review/admission.py:154-175), so 'Blocks: #871' no longer applies. Open: devops scan uses v1 (security/normalization.py:156-166); advisories are located at <manifest>:<line> (ai/review/pipeline.py:830), not purl@version; kube-linter and Pluto omit the namespace until #1045. The PR builds on review/fingerprint.py. #1352 takes this item's object form, #771 keys verdicts on it, and #1353's match needs purl@version.

Activity

  1. added
    type/bug
    scope/security
    scope/review
    priority/p1-high
    on Oct 3, 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 2 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.

  4. dan-petty commented on Oct 9, 2026

    @dan-petty
    OwnerAuthor

    Folded in from the #1045 re-scope (2026-10-09)

    Trivy and Dive identity moves here from #1045: they are not Kubernetes objects, so their identity is the advisory's purl@version. Note for this item's refinement: after #1045 only kube-linter carries the namespace (Kind/<namespace>/<name>); Pluto gets it with #1434.

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

    @dan-petty-bot
    Collaborator

    What changed

    #1487, merged into release/v0.2.31 as a525a81.

    Description

    Closes #1141 (absorbs #608).

    Migrates devops scan and NormalizedFinding to Fingerprint v2 (CONST_SARIF_FINGERPRINT_KEY = "devopsCli/v2"):

    • Computes SHA-256 over tool, rule ID, repository-relative path, qualified enclosing symbol extracted via AST (e.g. Class.method, function name, <module>), and a 100 non-whitespace character window hash starting from the flagged line.
    • Assigns deterministic occurrence index on collisions.
    • Derives identity for region-less findings from SARIF logicalLocations (kind/namespace/name[/container] for Kubernetes resources, purl@version for dependency advisories).
    • Retains scanner's own partialFingerprints as metadata properties without overriding identity.
    • Formulates correlation_key as (path or logical location, overlapping region, CWE).
    • Enforces complete linkage clustering in correlate with pre-sorting by total key (parsed_path, start_line, end_line, rule_id, tool, fingerprint), ensuring bridging-first chains leave 2 distinct clusters in every permutation.
    • Ensures findings from the same tool do not correlate across checks.
    • Selects cluster representatives and scalar values deterministically using highest severity, narrowest parsed region span, and total finding key, sorting locations numerically (a.py:9 before a.py:10).
    • Adds order-independence permutation tests across 4 fixtures: chained triple, bridging-first chain, fix(review): findings are lost between the model reply and the report #512 SQL injection pair, and recorded _watcher session (`k8s/informer.…

    11 file(s) changed.

    How it was verified

    Check runs at 739e319:

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

    Acceptance Criteria of docs/agent/tasks/task-1141-fingerprint-v2-and-deterministic-correlation.md:

    • Fingerprint v2 for a result with a region = sha256 of tool, rule id, path, enclosing qualified symbol from AST, 100 non-whitespace character window hash, and occurrence index on collision (test_a_finding_without_a_symbol_keeps_its_fingerprint).
    • A result without a region takes identity from SARIF logicalLocations: kind/namespace/name[/container] for Kubernetes objects, and purl@version for advisories (test_a_finding_without_a_region_takes_identity_from_logical_locations_or_purl).
    • Stability tests pass: non-identical and identical lines inserted above leave fingerprints unchanged, distinct sites give distinct fingerprints, inserting a 10th DaemonSet leaves the other 9 unchanged, and suppressions match after line shifts (test_fingerprint_v2_stability_on_unrelated_insertions, test_fingerprint_v2_distinguishes_distinct_sites, test_fingerprint_v2_daemonset_stability, test_fingerprint_suppression_matches_after_edit_above_line).
    • deduplicate and devops scan keep all 3 rows of a fixture with 3 BLE001 hits in one file (test_deduplicate_and_scan_keep_all_rows_of_ble001_fixture).
    • A tool's own partialFingerprints are kept as a property, not as identity (test_a_tools_own_partial_fingerprints_are_kept_as_a_property_not_identity).
    • correlation_key uses (path or logical location, overlapping region, CWE).
    • A fingerprint suppression still matches after an edit above the line.
    • Fingerprint pins bumped to "devopsCli/v2".
    • Order independence: deduplicate and correlate produce identical sets and output sequences over itertools.permutations across 4 fixtures: chained triple, bridging-first chain, fix(review): findings are lost between the model reply and the report #512 SQL injection pair, and recorded _watcher session (test_order_independence_across_permutations).
    • Complete linkage: input pre-sorted by total key; findings join cluster only when correlation predicate holds against every member; bridging-first chain leaves 2 clusters in every order (test_bridging_first_chain_leaves_two_clusters_in_every_order).
    • Deterministic picks: representative and scalars chosen by highest severity, narrowest parsed region, and total key; list fields sorted; _watcher keeps k8s/informer.py:44-112 in every order; parsed locations sort a.py:9 before a.py:10 (test_watcher_session_keeps_informer_range_in_every_order, test_cluster_ranking_sorts_parsed_location_numerically).
    • Stdlib only (itertools, no networkx).
    • Tests run offline with fakes and recorded tool output: no network, no real scanner, no model; each test under 1 s.
    • changelog.d/1141.md records the change; CHANGELOG.md and docs/ROADMAP.md are not edited.
    • uv run devops ci passes.
    • Pending a person: Offline replay: the finding lists reaching deduplicate and correlate in one feat(review): synthetic defect corpora for review evaluation #415 corpus run are captured, and the number of lists with more than one output across permutations is counted before and after, recorded in the task file.
    • Pending a person: devops scan row counts over src/ before and after, plus the number of identities that needed an occurrence index, recorded in the task file.
  6. 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/p1-highscope/reviewscope/securitytype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions