Repository navigation
Harden snapshot autofix and improve sensitive data redaction #1931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dd301f1
chore(security): harden snapshot autofix and fix sensitive data redac…
toxsick 130b182
chore(deps): use Renovate best practices preset
toxsick b2d0756
chore: merge main and resolve security audit documentation conflict
toxsick f8c969c
chore(ci): match coverage sources across project roots
toxsick 352be0e
chore(security): address snapshot autofix review findings
toxsick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔎 Supported by static analysis
Script executed:
Repository: fuf-stack/pixels
Length of output: 3586
Script executed:
Repository: fuf-stack/pixels
Length of output: 23831
Exclude the Storybook browser projects from the snapshot test runs.
buildSnapshotsruns barepnpm test, which can select the@repo/storybook-configbrowser projects. The unit-test job inci.ymlexcludes them with--project='!@repo/storybook-config*'. Thesnapshotsjob has no Chromium install step. If those projects run in that job, eachpnpm testrun can fail. The-uretry then fails the same way, andbuildSnapshotsthrowsTests failed after updating snapshots. The workflow then never uploads the artifact.Apply the same exclusion to every test run in the wrapper:
Suggested fix
const test = (args = []) => { - const result = spawnSync('pnpm', ['test', ...args], { stdio: 'inherit' }); + const result = spawnSync( + 'pnpm', + ['test', '--project=!@repo/storybook-config*', ...args], + { stdio: 'inherit' }, + );spawnSyncdoes not use a shell, so the!and*in the project pattern are passed literally. Alternatively, thesnapshotsjob can install Chromium, but that adds a browser install to a job that already runs branch code.🔎 Supported by static analysis
Script executed:
Repository: fuf-stack/pixels
Length of output: 2143
Script executed:
Repository: fuf-stack/pixels
Length of output: 27187
Keep build code out of base-branch cache scope.
The
snapshotsjob checks out the Renovate head (ref: ${{ needs.resolve.outputs.sha }}), runs./.github/actions/setup-project, and then runsbuildSnapshots. The workflow starts this job frompull_request_target,issue_comment, orworkflow_dispatch. The last two run from the default branch. Runs in those contexts use the base-branch cache scope.contents: readandpersist-credentials: falsedo not limit cache writes, because cache writes use runner runtime credentials rather thanGITHUB_TOKEN.Branch code can write to the cache through these paths:
setup-projectrunspnpm buildin the same job. This runs repository build code from the Renovate branch.setup-projectusesactions/setup-nodewithcache: pnpm. On a cache miss, its post step saves a cache built from the branch'spnpm install.release-please.ymlalso usessetup-project, so a later trusted run can restore a matching key.spawnSync('pnpm', ['test', ...args], { stdio: 'inherit' })passes the parent environment to the test process. That environment can include runner cache variables.Changing only the build job to
pull_requestdoes not coverissue_commentorworkflow_dispatch. Those runs still use the default-branch cache scope. Limit branch-code execution topull_requestruns, or remove branch-code execution from the other triggers.The
spawnSyncfilter below reduces what the test process inherits. It does not cover thepnpm buildstep or thesetup-nodecache save. Same-user processes can still read the parent environment, so this is partial mitigation only.Partial mitigation: drop runtime variables from the test child environment
const test = (args = []) => { - const result = spawnSync('pnpm', ['test', ...args], { stdio: 'inherit' }); + const env = Object.fromEntries( + Object.entries(process.env).filter(([key]) => { + return !/^(ACTIONS_|INPUT_)/.test(key); + }), + ); + const result = spawnSync('pnpm', ['test', ...args], { + stdio: 'inherit', + env, + });Sources: Learnings, Linters/SAST tools