Skip to content

fix: Improve navigation and testing for flow-less findings - #4

Merged
misonijnik merged 5 commits into
mainfrom
misonijnik/fixes
Jul 17, 2026
Merged

fix: Improve navigation and testing for flow-less findings#4
misonijnik merged 5 commits into
mainfrom
misonijnik/fixes

Conversation

@misonijnik

Copy link
Copy Markdown
Member

No description provided.

Add regression tests for the flow-less navigation fix:
- transformSarif parses `line` from the primary location's startLine
- a result with no codeFlows still exposes `line` and `file`
- generateContent keeps the primary-location file in `referenced`
  so a flow-less finding's source file survives pruning
Fold state was one shared set keyed by bare directory path, so a custom
rules directory sharing its path with a builtin one (e.g. java/security
in both) folded and unfolded together. Each origin section now owns its
collapse set via OriginSection, making the key collision impossible.
Phone initial folding seeds per section from that origin's tree.
Findings whose SARIF result has no code flows previously went nowhere:
no file opened, no highlight, and their source file was not even
bundled. The primary location is now a first-class navigation target:

- sarif.ts synthesizes a single sink step from the result's primary
  location when no usable code flow exists (empty flows are dropped),
  built through the same buildSteps mapping as real traces
- generateContent bundles every referenced file, including each
  finding's primary file and non-code extensions (.jsp etc. view as
  plaintext); referencedFiles() is shared with main.ts's guard, which
  had a stale steps-only copy of the formula
- the store falls back to the finding's own bundled file when a flow
  has no steps (shared sinkFocus/bundledFile helpers), restores a
  persisted traceless selection across reloads, and never navigates
  to a file missing from the bundle (which blanked the code pane)
- CodeView hides the step nav for zero-step flows instead of showing
  a phantom 1/0 counter, keeps the flow nav visible as the way back
  out of an empty flow, and omits tabs for unbundled step files
- main.ts: degrade the 'no source files found' hard-fail to a stderr
  warning and still export a findings-only viewer — the UI now handles
  missing files gracefully, and a report whose paths can't resolve
  locally (e.g. generated on another machine) is still useful
- store.ts: guard selectFile itself so no caller can navigate to an
  unbundled path; bundledFile delegates to fileByPath so one predicate
  defines 'bundled'; generalize sinkFocus to flowFocus(stepIndex) and
  route the persisted-restore fallback through it, removing the
  hand-rolled duplicate chain and the misleading steps.at(?? -1)
…ed sink

A finding without code flows (e.g. a pattern match like a hardcoded
credential) has no source→sink path, so synthesizing a single 'sink' step
from its primary location was misleading: the Steps panel stamped a sink
severity badge on it and the toolbar showed a degenerate 1/1 navigator.

Drop the synthesis — a trace-less result now yields flows: [{ steps: [] }]
and the viewer navigates via the finding's own line/file (already wired in
store flowFocus and CodeView's finding.line fallback). This aligns sarif
with the rest of the codebase, whose store/generateContent tests already
model traceless findings as empty-step flows.
@misonijnik
misonijnik merged commit c891968 into main Jul 17, 2026
1 check passed
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