Skip to content

P-015: carry reachability slices through the SARIF aggregator - #22

Merged
PhysShell merged 3 commits into
mainfrom
claude/own-net-research-synthesis-8akz2e
Jun 26, 2026
Merged

P-015: carry reachability slices through the SARIF aggregator#22
PhysShell merged 3 commits into
mainfrom
claude/own-net-research-synthesis-8akz2e

Conversation

@PhysShell

@PhysShell PhysShell commented Jun 26, 2026

Copy link
Copy Markdown
Owner

What & why

Mirrors the Own.NET reachability-evidence model (P-015) in the audit lift-out so a normalized finding can explain its path, not just its point. Companion to physshell/own.net claude/own-net-research-synthesis-8akz2e.

Background: a review of the ReachHover (data-flow reachability UI) + Optional-Checker (modular contracts) research reframed the work from "Rust borrow checker compiling to C#" to reachability-oriented diagnostics + modular contract checking for C#/WPF resource & lifetime analysis. The first, highest-leverage step is structured, walkable evidence.

Changes

  • report/sarif.py — each result now emits relatedLocations from a finding's optional evidence list and a codeFlows reachability slice from its optional flow list (each item {path, line, label}). Purely additive & forward-compatible: findings without these keys produce byte-for-byte the same SARIF (existing fixtures unaffected); when upstream normalization starts attaching them (e.g. a DI captive's singleton → transient → scoped path from own-check's OwnIR), they flow straight through to GitHub code scanning / IDE hovers.
  • src/OwnAudit.Core/Finding.cs — add an EvidenceSpan record + structured Evidence (relatedLocations) and ordered Flow (codeFlows) members, default empty.

Testing

Not run in this environment (no local clone/build). Kept additive/backward-compatible so existing SARIF output is unchanged unless a producer attaches evidence/flow.

See Own.NET docs/proposals/P-015-reachability-evidence.md for the full design and gap analysis.

🤖 Generated with Claude Code


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Findings can now include optional evidence and flow details, enriching SARIF output with additional related locations and ordered code flow information.
    • Evidence steps support file/line references with labels for clearer reporting of reachability context.
  • Bug Fixes

    • Improved export robustness by filtering out invalid or incomplete evidence/flow steps, so only usable locations are included in generated reports.

Mirror the Own.NET reachability-evidence model in the audit lift-out so a
normalized finding can explain its path, not just its point:

- report/sarif.py: each result now emits relatedLocations from a finding's
  optional `evidence` list and a codeFlows reachability slice from its optional
  `flow` list (each item {path,line,label}). Purely additive and
  forward-compatible -- findings without these keys produce byte-for-byte the
  same SARIF, so existing fixtures are unaffected; when upstream normalization
  starts attaching them (e.g. a DI captive's singleton -> transient -> scoped
  retention path from own-check's OwnIR), they flow straight through to GitHub
  code scanning / IDE hovers.
- src/OwnAudit.Core/Finding.cs: add an EvidenceSpan record and structured
  Evidence (relatedLocations) + ordered Flow (codeFlows) members, default empty.

See Own.NET docs/proposals/P-015 for the full design and the gap analysis.

Copy link
Copy Markdown
Owner Author

Reviewer orientation

Companion to PhysShell/Own.NET#118. This side just teaches the SARIF aggregator to pass a reachability slice through to GitHub code scanning / IDE hovers.

Where to look: report/sarif.py — the new _evidence_steps / _related_locations / _code_flows helpers and the two splice points in to_sarif's result loop.

Safety claim to check: purely additive. f.get("evidence") / f.get("flow") default to None_evidence_steps(None)[] → falsy → not spliced. So a findings.json without these keys exports identical SARIF; existing fixtures should be unaffected. Tolerant parsing drops malformed/lineless steps rather than raising.

Forward path: when own-check's OwnIR findings start carrying flow (the singleton → transient → scoped DI path), it surfaces here automatically with no further change to this file.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 03ef868764

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread report/sarif.py Outdated
continue
if ln < 1:
continue
out.append((s.get("path") or "", ln, s.get("label") or ""))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Drop evidence steps without an artifact URI

When a producer sends an evidence or flow step that has a line but no path, this keeps the step and later emits artifactLocation.uri: "". That includes the new EvidenceSpan.File == "" same-file convention documented in Finding.cs; instead of resolving it to the primary finding path or dropping the malformed anchor, one optional evidence item can make the GitHub SARIF upload unprocessable because it contains an empty artifact location.

Useful? React with 👍 / 👎.

… URI

Addresses Codex review (PR #22): an evidence/flow step with a line but no path
was kept and serialized as artifactLocation.uri: "", which makes the whole SARIF
upload unprocessable for GitHub code scanning. Now a step's empty path is first
resolved to the parent finding's path (the EvidenceSpan.File == "" "same file as
the finding" convention documented in Finding.cs); a step that still has no
usable path is dropped, so one malformed optional step can no longer poison the
export.
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0ffeb4f3-4769-4be1-9fd3-ff7cd07f8bdd

📥 Commits

Reviewing files that changed from the base of the PR and between 653e2af and cc8b680.

📒 Files selected for processing (1)
  • report/sarif.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • report/sarif.py

📝 Walkthrough

Walkthrough

The PR adds structured evidence and flow data to findings, then exports those locations into SARIF as relatedLocations and codeFlows when present.

Changes

Reachability evidence export

Layer / File(s) Summary
Finding evidence contract
src/OwnAudit.Core/Finding.cs
Finding gains a new EvidenceSpan record plus Evidence and Flow lists for structured location steps.
SARIF reachability export
report/sarif.py
SARIF export now documents, sanitizes, and attaches evidence steps as relatedLocations and codeFlows when available.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A bunny hops by, ears held high,
With evidence trails that reach the sky.
Hops to the left, hops to the flow,
Into SARIF the breadcrumbs go.
Thump-thump, the report shines bright tonight 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: passing reachability slices through the SARIF aggregator.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/own-net-research-synthesis-8akz2e

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@report/sarif.py`:
- Around line 104-113: The evidence step parser in `_evidence_steps()` only
reads `path`, so it drops spans coming from the new producer model that uses
`File` instead. Update the span extraction in `report/sarif.py` to accept `File`
as a fallback alongside `path` (using the existing `default_path` behavior), and
keep the rest of the validation in `s.get("line")` handling unchanged so
`relatedLocations` and `codeFlows` can emit correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 34a2f97e-c02c-428c-b68e-7a589d2ed8d7

📥 Commits

Reviewing files that changed from the base of the PR and between da65d1c and 653e2af.

📒 Files selected for processing (2)
  • report/sarif.py
  • src/OwnAudit.Core/Finding.cs

Comment thread report/sarif.py Outdated
Addresses CodeRabbit review (PR #22, Major): _evidence_steps() read only the
lowercase `path`/`line`/`label` keys, but the producer model in Finding.cs names
them File/Line/Label. A span serialized straight from EvidenceSpan would have
every step silently dropped, so relatedLocations/codeFlows would never emit.

Read each field case-insensitively (path|file|File, line|Line, label|Label) so
the aggregator tolerates either the normalized lowercase record or a raw
EvidenceSpan dump, while the line/empty-path validation is unchanged (a step
still needs a resolvable line and a non-empty path, the same-file convention
still resolves to the finding's own path).
@PhysShell
PhysShell merged commit 8532917 into main Jun 26, 2026
3 checks 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