Skip to content

pin actions/cache to a full-length commit SHA#199

Merged
aleksandra-bozhinoska-sonarsource merged 1 commit intoSonarSource:masterfrom
daantimmer:patch-1
Aug 28, 2025
Merged

pin actions/cache to a full-length commit SHA#199
aleksandra-bozhinoska-sonarsource merged 1 commit intoSonarSource:masterfrom
daantimmer:patch-1

Conversation

@daantimmer
Copy link
Copy Markdown
Contributor

GitHub suggests pinning actions to SHAs (not versions). If you’re using sonarqube-scan-action, it could break if that check ever gets turned on. Reference: As per https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions

In general it's recommended to only pin to SHAs and have a dependabot scan update the SHAs for you.

As per https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions it is recommended to pin actions to sha's instead of versions to increase security.
@aleksandra-bozhinoska-sonarsource
Copy link
Copy Markdown
Contributor

aleksandra-bozhinoska-sonarsource commented Aug 22, 2025

Hey @daantimmer, thank you for your suggestion!
That makes sense, however the documentation is referring to potential risks when using third-party actions, which is not the case in our scenario. Keeping the version as tag, as stated in the documentation, is more convenient and widely used option, so I would not merge this change at the moment.
However, we may reconsider our approach and potentially come back to it sometime later.
Many thanks for your efforts!

@daantimmer
Copy link
Copy Markdown
Contributor Author

But you are a third party for many others. Which means this GitHub policy can't be enforced when there is a dependency on sonarqube.

@aleksandra-bozhinoska-sonarsource
Copy link
Copy Markdown
Contributor

docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions

I see your point, thanks for clarifying. And to better understand your concern, is it that you would like to enforce this policy, or are you worried that it may be enforced by Github at some point?

@gbrune
Copy link
Copy Markdown

gbrune commented Aug 22, 2025

I’d like to add my support for @daantimmer’s request, we also want to enforce this policy across our repositories.

Enabling this new setting (see screenshot) in the GitHub Actions settings currently prevents the sonarqube-scan-action from executing.
image

Workflow fails with the following error:
image

Configuration:

- name: SonarQube Scan
  uses: SonarSource/sonarqube-scan-action@8c71dc039c2dd71d3821e89a2b58ecc7fee6ced9 # v5.3.0

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.

Thank you @daantimmer for your contribution!

@gbrune, many thanks for your argumentation as well!
We will include this improvement in the next release (which will happen ASAP).

@aleksandra-bozhinoska-sonarsource aleksandra-bozhinoska-sonarsource merged commit 1a6d90e into SonarSource:master Aug 28, 2025
72 of 73 checks passed
@mikel-jason
Copy link
Copy Markdown

FYI: This change killed the action for us on GitHub Enterprise Server where the referenced commit doesn't exist yet.

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.

4 participants