-
Notifications
You must be signed in to change notification settings - Fork 0
Configure zizmor to check the action.yml/workflow files and address any issues #30
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 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ad6c942
Apply automatic zizmor fixes
glaubinix 31a1a65
Validate webhook URLs and Composer commands from the incoming payload
glaubinix b15d7dc
Fix potential code injection via template expansion with payload.branch
glaubinix efd8d73
Fix stray semicolon
glaubinix 91295e1
GitHub Actions: configure zizmor to run on every PR/main
glaubinix 4523e1c
Fix action.yml input description
glaubinix f6690b6
Fix check file names
glaubinix 6ac2914
Attempts at fixinig COMPOSER_AUTH
glaubinix 281d4ef
Document masking + CONDUCTOR_ACTION_VERSION steps
glaubinix a71d345
Fix env variable names by dropping the GITHUB_EVENT_CLIENT_PAYLOAD_
glaubinix b86d17b
Sort GitHub action step properties to be consistent accross the action
glaubinix 4406dc1
Update action.yml
glaubinix 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: GitHub Actions Security Analysis with zizmor 🌈 | ||
|
|
||
| on: # zizmor: ignore[concurrency-limits] | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - '.github/workflows/*.yml' | ||
| - 'action.yml' | ||
| pull_request: | ||
| paths: | ||
| - '.github/workflows/*.yml' | ||
| - 'action.yml' | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| zizmor: | ||
| name: Run zizmor 🌈 | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Run zizmor 🌈 | ||
| uses: zizmorcore/zizmor-action@b1d7e1fb5de872772f31590499237e7cce841e8e # v0.5.3 | ||
| with: | ||
| advanced-security: false | ||
| annotations: true | ||
| online-audits: false | ||
| persona: 'pedantic' |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| BRANCH="${1:?branch name required}" | ||
|
|
||
| # Require every Conductor-managed branch to start with the literal prefix | ||
| # "conductor" and contain only characters that are safe inside a git refspec. | ||
| BRANCH_RE='^conductor[A-Za-z0-9._/-]*$' | ||
|
|
||
| if [[ ! "${BRANCH}" =~ ${BRANCH_RE} ]]; then | ||
| echo "::error ::branch '${BRANCH}' is not allowed; must start with 'conductor' and contain only [A-Za-z0-9._/-]" | ||
| exit 1 | ||
| fi |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| EXPECTED_SUBCOMMAND="${1:?expected subcommand required}" | ||
| : "${COMPOSER_COMMAND_STRING:?COMPOSER_COMMAND_STRING not set}" | ||
|
|
||
| # `read -ra` splits on $IFS only; it does not expand $vars, run command | ||
| # substitutions, honour quoting, or perform globbing. Every shell metacharacter | ||
| # in the payload therefore stays as a literal byte inside its token. | ||
| read -ra TOKENS <<< "${COMPOSER_COMMAND_STRING}" | ||
|
|
||
| if [[ "${#TOKENS[@]}" -lt 2 ]]; then | ||
| echo "::error ::composer command must contain at least a binary and a subcommand" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "${TOKENS[0]}" != "composer" ]]; then | ||
| echo "::error ::composer command must start with 'composer', got '${TOKENS[0]}'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "${TOKENS[1]}" != "${EXPECTED_SUBCOMMAND}" ]]; then | ||
| echo "::error ::composer subcommand must be '${EXPECTED_SUBCOMMAND}', got '${TOKENS[1]}'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Reject tokens containing characters that have no business | ||
| # appearing in a Composer package name, version constraint, or flag. | ||
| SAFE_TOKEN_RE='^[A-Za-z0-9._:/@^+|=~*,<>!-]+$' | ||
| for token in "${TOKENS[@]}"; do | ||
| if [[ ! "${token}" =~ ${SAFE_TOKEN_RE} ]]; then | ||
| echo "::error ::composer command token '${token}' contains disallowed characters" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| set -x | ||
| # Argv-form execution: bash passes each array element as one argv entry with | ||
| # no further parsing, so metacharacters inside a token reach Composer as | ||
| # literal string data rather than as shell syntax. | ||
| exec composer "${TOKENS[@]:1}" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| TRUSTED_BASE="${1:?trusted base URL required}" | ||
| URL="${2:?webhook URL required}" | ||
|
|
||
| # Strip a single trailing slash from the base so the prefix check below can | ||
| # always append "/". Requiring the URL to start with "<base>/" prevents a host | ||
| # like "packagist.com.evil.example" from sneaking past "packagist.com". | ||
| TRUSTED_BASE="${TRUSTED_BASE%/}" | ||
|
|
||
| case "${TRUSTED_BASE}" in | ||
| https://*) ;; | ||
| *) echo "::error ::packagist_url must use https://, got '${TRUSTED_BASE}'"; exit 1 ;; | ||
| esac | ||
|
|
||
| case "${URL}" in | ||
| "${TRUSTED_BASE}/"*) ;; | ||
| *) echo "::error ::webhook URL '${URL}' is not under the trusted base '${TRUSTED_BASE}/'"; exit 1 ;; | ||
| esac | ||
|
|
||
| # Restrict the path portion after the trusted base to alphanumerics, dashes, | ||
| # and forward slashes. This blocks query strings, fragments, percent-encoding, | ||
| # and any other characters that have no business appearing in a Conductor | ||
| # webhook callback path. | ||
| SUFFIX="${URL#"${TRUSTED_BASE}/"}" | ||
| case "${SUFFIX}" in | ||
| *[!A-Za-z0-9/-]*) | ||
| echo "::error ::webhook URL path '${SUFFIX}' must contain only alphanumerics, '-' and '/'" | ||
| exit 1 | ||
| ;; | ||
| esac |
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.
Uh oh!
There was an error while loading. Please reload this page.