Repository navigation
Description
What are you really trying to do?
Gate PRs on the dependencies they change: deny a PR that adds or upgrades to a package with a critical/high advisory, without blocking PRs because of advisories that already exist on main. This is what the pr-review.yaml starter template appears to be for.
Describe the bug
The diff_report entrypoint's vulnerabilities variable holds every finding from a scan of the target ref, not the findings the diff introduced. So a rule like the starter template's
when: vulnerabilities.exists(v, v.advisory.severity.level in [severity.critical, severity.high])
denies every PR that touches dependencies while any pre-existing critical/high finding is unignored, including PRs that don't touch the affected package.
deputy diff already works out which findings the change introduced. In runDiffAnalysis (internal/cli/cmd/diff.go), splitVulnsByChange and reclassifyUnchangedVulns partition the findings into changedVulns and unchangedVulns, and the comment there says the split exists "so the rendered report, JSON contract, and CI gates all agree on what this change actually introduced". But DiffPolicyReport is built with Vulnerabilities: reportVulns, the unpartitioned list, so policies never see the split. diff_vulnerability has the same issue, since runDiffPolicies builds it from the same list.
The docs describe vulnerabilities as "Vulnerability findings" (policy-inputs.md) and the policy examples diff_report header as "list of all vulnerabilities", so the behavior is arguably documented, but it makes the starter PR template block on findings unrelated to the PR.
Minimal Reproduction
- A repo whose target ref has a dependency with a high-severity advisory (no ignore rule).
- A PR that bumps an unrelated dependency.
deputy diff main HEAD --policy policy/ci/pr-review.yaml→pr-block-vulnerable-depsdenies.
Workaround we're using: restrict the rule to packages in changes:
vulnerabilities.exists(v, v.advisory.severity.level in [severity.critical, severity.high] &&
changes.exists(c, c.package.name == v.package.name && c.package.ecosystem == v.package.ecosystem))
That still denies when a PR bumps a package that keeps an existing advisory, which reclassifyUnchangedVulns would have classified as pre-existing.
Possible fixes: expose the introduced findings to policies (a new variable such as introduced_vulnerabilities, or make vulnerabilities mean the introduced set for diff_report / diff_vulnerability), and update pr-review.yaml to use it.
Environment/Versions
- OS and processor: macOS arm64 locally; ubuntu-24.04 in GitHub Actions
- deputy: main @ 1c97f17 (2026-09-30), via
temporalio/deputy/actions/setup@mainandactions/diff@main
Additional context
Also noticed: the policy examples diff_report output shows changes entries with flat name / ecosystem fields, but at runtime they are diff.v1.PackageChange messages (c.package.name), so a rule written from the example doesn't match.
Activity