Skip to content

fix: only skip CVE remediation for open PRs - #1606

Merged
brendan-kellam merged 1 commit into
mainfrom
brendan/fix-cve-remediation-open-prs
Aug 18, 2026
Merged

fix: only skip CVE remediation for open PRs#1606
brendan-kellam merged 1 commit into
mainfrom
brendan/fix-cve-remediation-open-prs

Conversation

@brendan-kellam

@brendan-kellam brendan-kellam commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resolve the current state of GitHub pull requests attached to Linear CVE issues
  • suppress remediation only when at least one attached pull request is open
  • keep issues with closed or merged pull requests eligible for a new remediation PR
  • add workflow permissions and regression coverage for open and closed attachments

Test plan

  • bash -n .github/scripts/find-unlinked-cve-issues.sh .github/scripts/test-cve-remediation.sh
  • .github/scripts/test-cve-remediation.sh
  • git diff --check

No changelog entry per request.


Note

Medium Risk
Changes which CVEs enter automated remediation and adds GitHub API calls in discovery; misclassification could duplicate or miss remediation PRs.

Overview
CVE discovery no longer treats any linked PR as “in progress.” Issues are excluded from nightly remediation only when a Linear attachment points at a GitHub pull request that is still open; CVEs linked only to closed PRs (or with no PR) stay eligible for a new remediation run.

The discovery script now resolves each unique linked PR URL via gh api (using GH_TOKEN) and attaches githubPrState before the jq filter runs. The reusable workflow’s discover job adds pull-requests: read and passes the workflow token into the script.

Tests and workflow copy were updated for open vs closed attachments and to assert GitHub state lookups and permissions.

Reviewed by Cursor Bugbot for commit 8b240a4. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features

    • CVE remediation now identifies issues without an open linked pull request, including links to pull requests in companion repositories.
    • Pull-request states are validated before issues are filtered.
  • Bug Fixes

    • Closed pull requests no longer incorrectly prevent CVE issues from being identified for remediation.
  • Tests

    • Expanded coverage for open and closed pull requests, state validation, and workflow permissions.

@github-actions

Copy link
Copy Markdown
Contributor

@brendan-kellam your pull request is missing a changelog!

@brendan-kellam
brendan-kellam merged commit 6d1e610 into main Aug 18, 2026
10 of 12 checks passed
@brendan-kellam
brendan-kellam deleted the brendan/fix-cve-remediation-open-prs branch August 18, 2026 01:35
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 95910976-d023-409f-acac-019c236da2f0

📥 Commits

Reviewing files that changed from the base of the PR and between 3ce4393 and 8b240a4.

📒 Files selected for processing (5)
  • .github/scripts/filter-unlinked-cve-issues.jq
  • .github/scripts/find-unlinked-cve-issues.sh
  • .github/scripts/test-cve-remediation.sh
  • .github/workflows/_cve-remediation.yml
  • .github/workflows/cve-remediation.yml

Walkthrough

The CVE remediation workflow now queries linked GitHub pull-request states, enriches issue attachments with those states, and excludes only issues linked to open pull requests. Tests cover closed pull requests and companion repositories.

Changes

CVE open pull-request filtering

Layer / File(s) Summary
Workflow permissions and authentication
.github/workflows/_cve-remediation.yml, .github/workflows/cve-remediation.yml, .github/scripts/test-cve-remediation.sh
The discovery job requests pull-request read access and passes GH_TOKEN. Workflow descriptions and assertions refer to CVEs without open linked pull requests.
Pull-request state enrichment
.github/scripts/find-unlinked-cve-issues.sh, .github/scripts/test-cve-remediation.sh
The discovery script queries each unique linked pull-request URL, validates open or closed states, and adds githubPrState to matching attachments. Tests mock gh api and verify endpoint queries.
Open-PR filtering and validation
.github/scripts/filter-unlinked-cve-issues.jq, .github/scripts/test-cve-remediation.sh
The filter excludes issues only when a valid linked pull request has state open. Fixtures and expected results cover closed pull requests, including companion repositories.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CVEWorkflow
  participant DiscoveryScript
  participant GitHubAPI
  participant JQFilter
  CVEWorkflow->>DiscoveryScript: Pass GH_TOKEN and CVE issues
  DiscoveryScript->>GitHubAPI: Query each unique pull-request endpoint
  GitHubAPI-->>DiscoveryScript: Return open or closed state
  DiscoveryScript->>JQFilter: Pass enriched issue attachments
  JQFilter-->>CVEWorkflow: Return issues without open linked PRs
Loading
✨ 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 brendan/fix-cve-remediation-open-prs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8b240a4. Configure here.

pull_number="${BASH_REMATCH[3]}"
if ! pr_state=$(gh api "repos/$owner/$repository/pulls/$pull_number" --jq '.state'); then
echo "Could not fetch linked GitHub pull request: $pr_url" >&2
exit 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PR fetch failure aborts all discovery

Medium Severity

Any failed gh api lookup (or unparsable linked PR URL) exits the whole discovery script before filtering. One deleted, private companion, or temporarily unreachable attachment then blocks remediation for every CVE that night, including issues with no linked PRs. That conflicts with only suppressing issues that still have an open PR.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8b240a4. Configure here.

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