GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add cache-write input for read-only cache mode by salmanmkc · Pull Request #1284 · actions/setup-python Conversation
Contributor
Right now if you use This adds a Usage: - uses: actions/setup-python@v6 with: python-version: "3.12" cache: pip cache-write: ${{ github.event_name != 'pull_request' }} What changed:
Same change going into setup-node, setup-go, setup-java, setup-dotnet.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Add a 'cache-write' input (default: true) that controls whether the cache is saved at the end of the workflow. When set to 'false', the action will restore cached dependencies but skip saving, providing a read-only cache mode. This is useful for preventing cache poisoning attacks from untrusted PR builds while still benefiting from cached dependencies.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pull request overviewAdds a new action input to support “read-only” cache usage by allowing workflows to restore caches without writing updated caches back, helping mitigate cache poisoning risks for untrusted PRs. Changes:
Reviewed changesCopilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
+12
to
+13
|
| const cacheWriteEnabled = core.getInput('cache-write'); | |
| if (cacheWriteEnabled === 'false') { | |
| const cacheWriteInput = core.getInput('cache-write'); | |
| const cacheWriteEnabled = | |
| cacheWriteInput === '' | |
| ? true | |
| : core.getBooleanInput('cache-write'); | |
| if (!cacheWriteEnabled) { |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const cacheWriteEnabled = core.getInput('cache-write'); | ||
| if (cacheWriteEnabled === 'false') { | ||
| core.info('Cache write is disabled (read-only mode). Skipping cache save.'); | ||
| return; | ||
| } | ||
|
|
||
| const cache = core.getInput('cache'); | ||
| if (cache) { | ||
| await saveCache(cache); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
New cache-write behavior is not covered by tests. Add a unit test in __tests__/cache-save.test.ts that sets cache-write to false and asserts cache.saveCache is not called (and optionally that the skip message is logged) when cache is enabled.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
After reviewing the current GitHub Actions cache security model, I recommend closing this PR as unnecessary for the stated cache-poisoning threat.
The suggested Explicit restore-only behavior may still be useful ergonomically, but GitHub already recommends composing References:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.