feat(plc): PLC findings keyed by what they flag, saved through RunFindings (#491 follow-up)

PLC findings were still keyed by POU and line and inserted one by one, so
every line shift in an export made a duplicate finding (they are not
auto-closed, so the old one stayed).

- plc::analyze_tree gives each hit its content: the POU, the rule's title
  and description (variable and function names, no line numbers) and its
  occurrence among identical hits in the POU. A PLCopen XML line is a line
  of the embedded body, not of the file, so the file is not read.
- The PLC scan saves through RunFindings: content keys, the row stored
  under the line-based fingerprint taken over (id, status, triage kept),
  moved lines followed, control refs refreshed on earlier rows (what the
  removed loop did). Still no auto-close for PLC.
- content_fingerprints works without a tree when the scanner gives the
  content (a PLC scan reads several trees).
- Test: a comment added on top keeps every PLC content key, and no two
  hits share one. Staging test plan: check 19.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-10-06 13:09:11 +02:00
1 parent f170e7cfe5
commit 47de7ecf0d
4 files changed
+78 -41

No files matched your search

@@ -19,6 +19,7 @@ together on stage in one pass before the next prod promotion.
| #461 | Transitive NuGet packages of `<PackageReference>` projects resolved from nuget.org |
| #467 (follow-up) | npm and Maven licenses from their public registries |
| #491 | Findings keyed by the code they flag, not its line number |
| #491 (PLC) | PLC findings keyed the same way |
**Customer-visible on the next prod rescan** is marked **[visible]**: these
change what a customer sees on their existing targets, without them doing
@@ -354,6 +355,18 @@ target with history (findings, at least one marked by a person, issues).
`CVE_ISSUE_EPSS_PERCENTILE` (default `0.95`, `off`) sets the EPSS step-up.
- **[visible]** KEV and EPSS badges on the SBOM page; CVE issues for KEV
CVEs whatever their severity.
||||||| parent of 8c986d6 (feat(plc): PLC findings keyed by what they flag, saved through RunFindings (#491 follow-up))
### 20. #491 follow-up: PLC findings
- **Do:** rescan an existing PLC target (e.g. `fixtures/nightly/plc/mixer_ld.xml`
or the CODESYS sample) without changes; then upload the same ST/PLCopen
export with a comment added at the top and rescan.
- **Expect:** first rescan: no new findings, statuses kept (log
`… now keyed by their content` with `adopted=…`); after the change: still
no new findings, the lines follow (log `findings whose code moved …`).
Control refs a newer mapping computes still reach earlier findings.
- **[visible]** PLC targets no longer get a duplicate finding for every line
shift in an export.
## After the pass