Skip to content

Harden GitHub workflows by pinning action SHAs and defining explicit permissions#795

Open
Copilot wants to merge 2 commits into
mainfrom
copilot/codeql-fixes-june2026
Open

Harden GitHub workflows by pinning action SHAs and defining explicit permissions#795
Copilot wants to merge 2 commits into
mainfrom
copilot/codeql-fixes-june2026

Conversation

Copilot AI commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

This PR addresses open CodeQL findings in .github/workflows by removing floating action tags, pinning each external action to a specific commit SHA, and adding explicit workflow permissions. Scope is workflow-only hardening with no functional application-code changes.

  • What changed

    • Replaced version-tagged uses: references (for example @v4, @v6, @release/v1) with full commit SHAs across all workflow files.
    • Updated all third-party and GitHub-maintained actions used by CI, release, packaging, CodeQL, Docker, and AWS publishing workflows.
    • Added top-level permissions blocks to workflows flagged by CodeQL for missing permissions.
    • Kept existing job-level permission overrides where write access is required.
    • Left local reusable workflows/actions (./.github/...) unchanged.
    • Corrected two workflow trigger keys from pull_request.type to pull_request.types.
  • Security impact

    • Eliminates tag-drift/supply-chain risk from mutable action tags.
    • Aligns workflows with CodeQL’s “pin actions to full-length commit SHA” requirement.
    • Ensures workflows explicitly declare permission scope.
  • Representative diff pattern

# before
- uses: actions/checkout@v7
- uses: github/codeql-action/analyze@v4
- uses: pypa/gh-action-pypi-publish@release/v1

# after
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b

Copilot AI changed the title Fix CodeQL workflow vulnerabilities by pinning GitHub Actions Harden GitHub workflows by pinning all action references to immutable SHAs Jun 24, 2026
Copilot AI requested a review from tammy-baylis-swi June 24, 2026 21:05

Copilot AI commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Make more changes to address these alerts about "Workflow does not contain permissions":

Updated in commit f24124e.

I added top-level permissions blocks to the workflows flagged by the "Workflow does not contain permissions" alerts and preserved job-level overrides where needed. I also fixed two pull_request trigger keys (type -> types) found during validation. Re-ran validation and the CodeQL actions scan reports 0 alerts.

Copilot AI changed the title Harden GitHub workflows by pinning all action references to immutable SHAs Harden GitHub workflows by pinning action SHAs and defining explicit permissions Jun 24, 2026
@tammy-baylis-swi tammy-baylis-swi marked this pull request as ready for review June 24, 2026 21:23
@tammy-baylis-swi tammy-baylis-swi requested review from a team as code owners June 24, 2026 21:23
Copilot AI review requested due to automatic review settings June 24, 2026 21:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the repository’s GitHub Actions workflows by pinning all third-party actions to immutable commit SHAs, adding explicit permissions blocks where missing, and fixing workflow trigger key typos to satisfy CodeQL workflow security findings.

Changes:

  • Replaced floating action refs (e.g., @v*, @release/v1) with full commit SHAs across workflows.
  • Added explicit workflow-level permissions (and preserved existing job-level overrides where needed).
  • Corrected pull_request.typepull_request.types in affected workflows.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/verify_install.yaml Pins actions/checkout to a commit SHA in install-test jobs (note: Alpine-vs-latest checkout split needs correction).
.github/workflows/verify_install_windows.yaml Pins actions/checkout / actions/setup-python to commit SHAs.
.github/workflows/verify_install_macos.yaml Pins actions/checkout / actions/setup-python to commit SHAs.
.github/workflows/run_tox_tests.yaml Fixes PR trigger key (types), adds explicit permissions, pins checkout/setup-python SHAs.
.github/workflows/run_tox_ruff_format.yaml Adds explicit permissions; pins checkout/setup-python SHAs.
.github/workflows/run_tox_lint_format.yaml Fixes PR trigger key (types), adds explicit permissions, pins checkout/setup-python SHAs.
.github/workflows/reversinglabs_scan.yaml Pins download-artifact and ReversingLabs scanner actions to commit SHAs.
.github/workflows/publish_lambda_layer.yaml Pins download-artifact and AWS credentials action to commit SHAs.
.github/workflows/get_apm_python_version.yaml Adds explicit permissions; pins checkout SHA.
.github/workflows/create_testrelease_pr.yaml Adds explicit permissions; pins checkout SHA.
.github/workflows/create_release_pr.yaml Adds explicit permissions; pins checkout SHA.
.github/workflows/codeql_analysis.yml Adds explicit permissions; pins checkout and CodeQL action SHAs.
.github/workflows/build_sdist_and_wheel.yaml Adds explicit permissions; pins checkout and upload-artifact SHAs.
.github/workflows/build_publish_testpypi.yaml Pins download-artifact and PyPI publish action SHAs.
.github/workflows/build_publish_pypi_and_draft_release.yaml Pins checkout, download-artifact, PyPI publish, and GitHub App token action SHAs.
.github/workflows/build_publish_lambda_layer.yaml Adds explicit permissions; pins checkout/setup-python/upload-artifact SHAs.
.github/workflows/build_publish_image_autoinstrumentation.yaml Pins docker/* actions and CodeQL upload-sarif to commit SHAs.
.github/workflows/build_publish_image_autoinstrumentation_beta.yaml Pins docker/* actions and CodeQL upload-sarif to commit SHAs.

Comment on lines 177 to +181
- if: contains(matrix.hostname, 'alpine3.13') || contains(matrix.hostname, 'alpine3.14') || contains(matrix.hostname, 'alpine3.15') || contains(matrix.hostname, 'alpine3.16')
uses: actions/checkout@v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
# Else use latest checkout
- if: ${{ !(contains(matrix.hostname, 'alpine3.13') || contains(matrix.hostname, 'alpine3.14') || contains(matrix.hostname, 'alpine3.15') || contains(matrix.hostname, 'alpine3.16') || contains(matrix.hostname, 'amazon2-')) }}
uses: actions/checkout@v7
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants