Improve build_cts_json.yaml workflow security #105
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Limits the increased permissions to a dedicated job which runs only on push events to
main
.The previous implementation was already enough to protect against malicious PRs from forks, see for example this run (not malicious), which only has
Contents: read
as desired.However, if Dependabot was used on the repository (at some point in the future), it would have increased its default read-only permissions to write permissions, making it easier for compromised dependencies to directly affect the repository.
With the new changes an unprivileged job builds the
cts.json
now, and more privileged job pushes the changes, but only when running onmain
. Thects.json
file is passed as artifact between the jobs (as described in the documentation).This should hopefully make it more secure.
Side note: These changes have the side effect that the modified
cts.json
file now also becomes available in the "Artifacts" section of runs (even for pull requests), see for example https://github.com/jsonpath-standard/jsonpath-compliance-test-suite/actions/runs/14638122807.