Repository navigation
Description
Describe the bug
releaseWorkflowsMustNotRestoreUntrustedCache (ISSUE-705) treats an opt-in setup action's cache as enabled whenever its cache: input is a non-empty string that is not "false". It does not evaluate GitHub expressions, so an input that turns the cache off on the release trigger and keeps it on everywhere else is still reported as restoring a cache on the release path.
That is the remediation the finding itself recommends ("disable caching on publish paths") and the one plumber#409 proposes, applied the only way that keeps ordinary builds fast. A repository that does the right thing gets the same High finding as one that does nothing, and the only way to clear it is to remove the cache from every run, including pull request builds that never publish.
To Reproduce
name: plugin
on:
workflow_dispatch:
pull_request:
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-java@v4
with:
java-version: "17"
distribution: temurin
cache: ${{ github.event_name != 'workflow_dispatch' && 'maven' || '' }}
- run: mvn -B package
- name: Publish
if: github.event_name == 'workflow_dispatch'
run: npx ovsx publish plugin.vsix -p "$OVSX_PAT"
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}plumber analyze reports:
HIGH [ISSUE-705] job "plugin/build-and-publish" restores a cache via "actions/setup-java@v4" on a release-type trigger — scope the key (and any restore-keys) to the release ref or disable caching on publish paths
On workflow_dispatch, the only trigger that publishes, the expression evaluates to '' and setup-java restores nothing. On pull_request it restores the Maven cache, but nothing is published.
Splitting the step in two with step-level if: conditions (one cached step with if: github.event_name != 'workflow_dispatch', one uncached with if: github.event_name == 'workflow_dispatch') is flagged as well, with the same finding on 0.5.12, because _cache_enabled only looks at action.with[...] and never at the step's if:.
Expected behavior
When the enable input is an expression, the control should resolve it per trigger where it can. At minimum, the common shape github.event_name != '<release trigger>' && '<manager>' || '' (and its == inverse) should be treated as disabled on that trigger. A step whose if: excludes every release trigger of the job should not count as a restore on the release path either.
Where the expression cannot be resolved, reporting the step as not_evaluable, or as a lower-severity "conditional cache on a release path, verify manually", would be more accurate than a High that asserts a restore that does not happen.
Relevant versions and configuration files
- OS: Windows 11 (binary
plumber-windows-amd64) - Platform: GitHub (github.com)
- Plumber version: 0.5.12
.plumber.yaml: none, built-in default configuration
Relevant logs
Rule source at policies/cache_poisoning.rego: actions/setup-java is an opt-in cache action with enableInput: cache, and _cache_enabled accepts any is_string(c) with c != "" and lower(c) != "false". The unexpanded ${{ ... }} text satisfies all three.
Additional context
This matters most on exactly the jobs the control exists for. The pattern in the reproduction (build on every PR with a cache, publish to a marketplace on manual dispatch) is common for IDE plugins and CLI releases, and the conditional input is the least disruptive way for a maintainer to close the gap. A false positive there teaches them to disable the control instead.
Activity
fix(policies): resolve the cache-poisoning release path per trigger
fix(policies): resolve the cache-poisoning release path per trigger
fix(policies): resolve the cache-poisoning release path per trigger
fix(policies): resolve the cache-poisoning release path per trigger
feat(ir,github): carry step-level if conditions for actions and run s…
fix(policies): resolve the cache-poisoning release path per trigger
feat(ir,github): carry if conditions for jobs, actions and run scripts
fix(policies): resolve the cache-poisoning release path per trigger
docs(cache-poisoning): describe the per-trigger resolution and ISSUE-…
fix(policies): resolve the cache-poisoning release path per trigger
docs(cache-poisoning): describe the per-trigger resolution and ISSUE-…
fix(policies): resolve the cache-poisoning release path per trigger
docs(cache-poisoning): describe the per-trigger resolution and ISSUE-…
feat(ir,github): carry if conditions for jobs, actions and run scripts
docs(cache-poisoning): describe the per-trigger resolution and ISSUE-…
chore(release): 0.5.13 [skip ci]
fix(policies): resolve the cache-poisoning release path per trigger