Repository navigation
Harden GitHub Actions workflows per zizmor, poutine and octoscan - #6900
Open
ondrejmirtes wants to merge 1 commit into
Open
ondrejmirtes wants to merge 1 commit into
ondrejmirtes wants to merge 1 commit into
Conversation
- Pass expressions to run scripts through env variables instead of expanding them into the script (template-injection) - Declare explicit least-privilege permissions on every workflow and document the non-obvious ones - Do not persist checkout credentials unless a later step pushes with them - Add concurrency groups where a newer run supersedes an older one - Name the remaining anonymous jobs after their IDs, keeping check names - Install actionlint from its digest-pinned image instead of piping a downloaded script into bash - Scan only externally triggerable workflows with octoscan, its default - Configure poutine's allowed GitHub-hosted arm runner and the reviewed third-party actions - Document by-design exceptions with inline zizmor ignores Amp-Thread-ID: https://ampcode.com/threads/T-01a197a7-c816-7129-bba7-bbd97e6de236
| run: "php -d memory_limit=599M bin/phpstan analyse --generate-baseline baseline-php-${{ matrix.php-version }}.neon" | ||
| env: | ||
| MATRIX_PHP_VERSION: ${{ matrix.php-version }} | ||
| run: "php -d memory_limit=599M bin/phpstan analyse --generate-baseline baseline-php-${MATRIX_PHP_VERSION}.neon" |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes what the linters in
lint-workflows.ymlreport. Run locally with the same versions and flags CI uses (actionlint 1.7.12, octoscan v0.1.7, poutine 1.1.4, zizmor 1.20.0--persona=auditor):Fixes
run:scripts (matrix scripts, step outputs,vars.*,github.ref_name, PR number and URL,GITHUB_TOKENfordocker login) now go throughenv:. Matrix scripts run witheval "$MATRIX_SCRIPT", which keeps the same parsing, quoting and-e/pipefail behaviour as the old inline script.Contents: read, Metadata: read, Packages: read, per a recent run's log), so this only narrows. Jobs that only authenticate withPHPSTAN_BOT_TOKENget{}.claude-react-on-review-dispatchdrops fromactions: writetoactions: read, which is enough to download the artifact. Write and OIDC permissions now have a comment explaining them.persist-credentials: falseon every checkout whose job never pushes.git fetchfrom this public repo still works without credentials.create-pull-requestsets up its own token.head_ref || run_idgroup, and single groups for the push and cron workflows.unverified_script_exec: actionlint now runs fromdocker://rhysd/actionlint:1.7.12@sha256:…instead ofbash <(curl …/main/…). Note that this pins actionlint instead of always using the latest version.Linter configuration
filter_triggers: external, octoscan's default, replaces''. Its checkout, local-action andGITHUB_OUTPUTrules only matter for workflows that outside contributors can trigger with privileges, and those workflows are still scanned.runner-labelis disabled because everyruns-onexpression resolves to a GitHub-hosted label..github/poutine.yml):ubuntu-24.04-armis allowed as a runner (it's GitHub-hosted). The SHA-pinned third-party actions already in use are acknowledged, so a newly added action still gets reported.By-design exceptions (inline
zizmor: ignore)dangerous-triggers: the threepull_request_targetworkflows and theworkflow_rundispatch. None of them check out or run PR code.artipacked: merge-maintained-branch, create-tag and the phpstan-dist checkout, which push with the persisted bot credentials.concurrency-limits: apiref-infra queues instead of cancelling, so a CDK deploy is never interrupted. Review dispatch and create-tag runs don't supersede one another.cache-poisoning(phar.yml, Alpine PHP build cache): only branch pushes can write the cache that a tag build reads.obfuscation(phar.yml): computed lookups into the origins/prereleases JSON maps, andshell: cmdfor MSVC builds.