Skip to content

ci: automatically publish suppressions after merged PRs#8527

Open
chadlwilson wants to merge 4 commits into
dependency-check:mainfrom
chadlwilson:automatically-publish-suppressions
Open

ci: automatically publish suppressions after merged PRs#8527
chadlwilson wants to merge 4 commits into
dependency-check:mainfrom
chadlwilson:automatically-publish-suppressions

Conversation

@chadlwilson
Copy link
Copy Markdown
Collaborator

@chadlwilson chadlwilson commented May 20, 2026

Description of Change

Alternate implementation of #8516 which triggers off merged pull requests targetting the branch.

As noted in #8516 (comment) the on.branch or normal on.pull_request triggers won't work, as they operate in the context of the relevant branch; however https://github.com/dependency-check/DependencyCheck/tree/generatedSuppressions is a bare tree/orphaned branch which does not contain the workflow definitions - so there is nothing to trigger. You can simulate a similar warning if you try and use workflow dispatch off this branch, which it wont let you:

image

The alternative is to use the (somewhat risky) pull_request_target event; which operates in the context of the default branch's workflow (main), in the PR target repository. This means it always uses the workflow definition off main, which in our case is what we want - albeit with some downsides.

This event type is pretty notorious recently for repos getting script-injected and tokens stolen due to "untrusted PR code" being used when misconfigured; so we have to be careful here, similar to the "Lint PR" workflow too. To mitigate all this, this only runs on post-review PR merges (which unfortunately GHA does not have a dedicated event for), and only those targeting the generatedSuppressions branch (and file paths to be extra paranoid).

IMO risk should be OK given it always checks out code from hard-coded generatedSuppressions branch, and does not inject/interpolate any variables from the PR context. We probably need some GHA workflow static analysis tooling though, to prevent regression.

Testing off my fork: https://github.com/chadlwilson/DependencyCheck/actions/workflows/publish-suppressions.yml

Related issues

Have test cases been added to cover the new functionality?

N/A

@chadlwilson chadlwilson changed the title fix: automatically publish suppressions after merged PRs ci: automatically publish suppressions after merged PRs May 20, 2026
@chadlwilson chadlwilson requested a review from Copilot May 20, 2026 16:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates GitHub Actions workflows to run in the safer pull_request_target context with clearer warning comments, and gates publishing suppressions to merged PRs.

Changes:

  • Switch publish-suppressions to trigger on pull_request_target (closed) for a specific branch/path and only proceed when the PR is merged.
  • Add pull_request_target safety warning comments to workflows.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/publish-suppressions.yml Adds pull_request_target trigger + merge gate for suppression publishing, plus safety notes.
.github/workflows/lint-pr.yml Adds pull_request_target safety notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/publish-suppressions.yml Outdated
Comment thread .github/workflows/lint-pr.yml Outdated
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@chadlwilson chadlwilson requested a review from Copilot May 20, 2026 16:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread .github/workflows/lint-pr.yml Outdated
Comment thread .github/workflows/publish-suppressions.yml
Comment thread .github/workflows/publish-suppressions.yml
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@chadlwilson chadlwilson added the github_actions Pull requests that update Github_actions code label May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update Github_actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve publish-suppressions action trigger

2 participants