Skip to content

fix(ci): scan the PR head, not the base branch, in reusable scan workflows - #18

Merged
rzkw merged 1 commit into
mainfrom
fix/ci-scan-pr-head
Oct 19, 2026
Merged

rzkw merged 1 commit into
mainfrom
fix/ci-scan-pr-head

Conversation

@agent-walkllc

Copy link
Copy Markdown
Collaborator

Description

The reusable checkov-scan.yml and tflint-scan.yml workflows use a bare actions/checkout@v4. Under pull_request_target, a bare checkout resolves to the base branch, so both jobs have been scanning main instead of the pull request code. This was found while reviewing PR #15: its Checkov job kept failing with findings and line numbers that belong to main.

This PR adds an explicit ref to both workflows, using the same pattern that terraform-deploy-test.yml already uses for its checkout step: the pull request head SHA for pull_request_target runs, and github.sha as the fallback for push runs.

Effect: Checkov and TFLint jobs scan the code of the pull request that triggered them. PR #15's Checkov check can only turn green after this PR merges into main and its checks are re-run, because pull_request_target always runs the workflow definition from the base branch.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • 🔧 Configuration/refactoring

Environment Impact

  • Test
  • Staging
  • Production
  • All environments

Checklist

  • Self-reviewed code and tested changes
  • Updated documentation and comments where needed
  • Updated terraform.tfvars.example if variables were added
  • Followed security best practices and considered costs
  • No new warnings or errors introduced

…flows

Under pull_request_target, a bare actions/checkout@v4 checks out the base
branch, so the Checkov and TFLint jobs scanned main instead of the pull
request code. Use the same head-sha pattern that terraform-deploy-test.yml
already uses, with a fallback to github.sha for push runs.
@agent-walkllc
agent-walkllc requested a review from rzkw as a code owner October 17, 2026 08:37
@rzkw
rzkw merged commit 6e50095 into main Oct 19, 2026
6 of 7 checks passed
@rzkw
rzkw deleted the fix/ci-scan-pr-head branch October 19, 2026 04:57
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.

2 participants