Skip to content

feat: add dependabot security backport labels#24484

Merged
CommanderK5 merged 10 commits into
mainfrom
feat/dependabot-security-backports
Apr 23, 2026
Merged

feat: add dependabot security backport labels#24484
CommanderK5 merged 10 commits into
mainfrom
feat/dependabot-security-backports

Conversation

@CommanderK5
Copy link
Copy Markdown
Contributor

Dependabot security update PRs should be backported with the workflow added in #24025, but today they still rely on someone noticing and adding the backport label manually.

This updates the dependabot workflow to add the existing backport label automatically when a newly opened Dependabot PR looks like a security fix, and it adjusts the Slack notification text so those PRs are called out explicitly.

@CommanderK5 CommanderK5 changed the title feat(.github/workflows): add dependabot security backport labels feat: add dependabot security backport labels Apr 17, 2026
Copy link
Copy Markdown
Contributor

@jdomeracki-coder jdomeracki-coder left a comment

Choose a reason for hiding this comment

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

Code Review — PR #24484

🤖 Generated with Coder Agents

Summary

This PR adds automatic backport labeling for Dependabot security update PRs and customizes the Slack notification to call them out. The approach is straightforward and the step ordering is correct (label before approve/merge so the backport workflow triggers on close).

🟡 IMPORTANT — Prefer alert-lookup over body-text grep

The dependabot/fetch-metadata action (already used at the metadata step) natively supports security alert detection via its alert-lookup input. Enabling it:

- name: Dependabot metadata
  id: metadata
  uses: dependabot/fetch-metadata@ffa630c65fa7e0ecfa0625b5ceda64399aea1b36 # v3.0.0
  with:
    github-token: "${{ secrets.GITHUB_TOKEN }}"
    alert-lookup: true

gives you steps.metadata.outputs.alert-state (OPEN, FIXED, or DISMISSED) and steps.metadata.outputs.ghsa-id. Then the security check becomes:

if: steps.metadata.outputs.alert-state != ''

This is more reliable than grepping the PR body for dependabot alert|security vulnerabilit(y|ies) because:

  1. Fragility — if Dependabot ever changes their PR body template wording, the regex breaks silently and security PRs stop getting backported with no alert.
  2. False negatives — a different phrasing or a non-English locale could bypass detection.
  3. False positives — a version-update PR whose changelog happens to mention "security vulnerability" would get incorrectly labeled.

The structured output from the action itself is the canonical signal.

🔵 NITPICK — Minor observations

  1. Step output when skipped: When the if condition skips the step (label already present), steps.security_backport.outputs.added is empty. The || 'false' fallback in the Slack step handles this correctly — looks good.

  2. Shell safety: Passing github.event.pull_request.body via the PR_BODY env var (not inline) correctly avoids shell injection. Good pattern.

Verdict

The logic and integration with the existing backport workflow are sound. The main suggestion is to replace the body-text grep with alert-lookup: true on the existing fetch-metadata step for a more reliable detection mechanism.

@CommanderK5 CommanderK5 marked this pull request as ready for review April 20, 2026 10:04
@CommanderK5 CommanderK5 enabled auto-merge (squash) April 20, 2026 12:46
Copy link
Copy Markdown
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

This is a good enhancement but I wonder if there can be a case when an upgrade may not be a valid backport for an older release.

Also @f0ssel is there a process to inform the release manager when a new back port PR needs review or approval?

@CommanderK5
Copy link
Copy Markdown
Contributor Author

CommanderK5 commented Apr 21, 2026

This is a good enhancement but I wonder if there can be a case when an upgrade may not be a valid backport for an older release.

Also @f0ssel is there a process to inform the release manager when a new back port PR needs review or approval?

Good point - yes, I think that can happen. A dependency/security bump on main may still need adjustments on an older release branch, or may turn out not to be the right backport as-is.

This change does not auto-merge anything into release branches though; it only makes sure eligible Dependabot security PRs get the existing backport label. The backport workflow still opens normal backport PRs for review, so we can adjust or close them if a straight backport is not valid.

On the release-manager question: I did not add anything in this PR to explicitly notify the release manager when a generated backport PR is opened. This PR only covers labeling the original Dependabot security PR and improving that Slack notification. If we want release-manager notification/review routing for the backport PRs themselves, that seems like a good follow-up.

@jdomeracki-coder @Shelnutt2

@matifali
Copy link
Copy Markdown
Member

This PR only covers labeling the original Dependabot security PR and improving that Slack notification.

If we have a slack notification that is enough.

@CommanderK5 CommanderK5 requested a review from matifali April 22, 2026 09:17
@CommanderK5 CommanderK5 merged commit 06d7fc5 into main Apr 23, 2026
29 checks passed
@CommanderK5 CommanderK5 deleted the feat/dependabot-security-backports branch April 23, 2026 03:58
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants