Repository navigation
ci(#5221): redact behaviour debug artifacts before upload #6167
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
ifireball
merged 7 commits into
fullsend-ai:main
from
ifireball:fix/5221-redact-behaviour-artifacts
Aug 13, 2026
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2385e35
fix(#5221): redact behaviour debug artifacts before upload
ifireball fd7ebc3
fix(#5221): always stub binary behaviour artifact files
ifireball 5e704d1
fix(#5221): harden behaviour artifact redaction per review
ifireball b8b9cf5
fix(#5221): register redaction scripts in vendored defaults manifest
ifireball ffb6273
fix(#5221): harden literal redaction and workflow log sanitization
ifireball 280af01
fix(#5221): address behaviour artifact redaction security review
ifireball c4d8de3
fix(#5221): widen Bearer/token redaction pattern
ifireball 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,181 @@ | ||
| #!/usr/bin/env bash | ||
| # redact-behaviour-artifacts-test.sh — Tests for redact-behaviour-artifacts.sh | ||
| # | ||
| # Run from repo root: bash .github/scripts/redact-behaviour-artifacts-test.sh | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| REDACT_SCRIPT="${SCRIPT_DIR}/redact-behaviour-artifacts.sh" | ||
| FAILURES=0 | ||
|
|
||
| TMPDIR="$(mktemp -d)" | ||
| trap 'rm -rf "${TMPDIR}"' EXIT | ||
|
|
||
| # Build secret-like literals at runtime so pre-commit detect-private-key and secret | ||
| # scanners do not see contiguous token/PEM patterns in the repository. | ||
| fake_ghp_token() { | ||
| printf '%s%s' "gh" "p_${1}" | ||
| } | ||
|
|
||
| fake_pem_block() { | ||
| local kind="$1" | ||
| local payload="$2" | ||
| printf '%s\n' \ | ||
| "$(printf '%s %s %s-----' '-----BEGIN' "${kind}" 'PRIVATE KEY')" \ | ||
| "${payload}" \ | ||
| "$(printf '%s %s %s-----' '-----END' "${kind}" 'PRIVATE KEY')" | ||
| } | ||
|
|
||
| fake_pgp_block() { | ||
| local payload="$1" | ||
| printf '%s\n' \ | ||
| "$(printf '%s %s %s %s-----' '-----BEGIN' 'PGP' 'PRIVATE KEY' 'BLOCK')" \ | ||
| "${payload}" \ | ||
| "$(printf '%s %s %s %s-----' '-----END' 'PGP' 'PRIVATE KEY' 'BLOCK')" | ||
| } | ||
|
|
||
| run_test() { | ||
| local test_name="$1" | ||
| local must_not_contain="$2" | ||
| local must_contain="${3:-}" | ||
|
|
||
| local actual | ||
| actual="$(<"${TMPDIR}/artifact.log")" | ||
|
|
||
| if [ -n "${must_not_contain}" ] && echo "${actual}" | grep -qF "${must_not_contain}"; then | ||
| echo "FAIL: ${test_name}" | ||
| echo " sanitized output still contains: '${must_not_contain}'" | ||
| FAILURES=$((FAILURES + 1)) | ||
| return | ||
| fi | ||
|
|
||
| if [ -n "${must_contain}" ] && ! echo "${actual}" | grep -qF "${must_contain}"; then | ||
| echo "FAIL: ${test_name}" | ||
| echo " expected to find: '${must_contain}'" | ||
| FAILURES=$((FAILURES + 1)) | ||
| return | ||
| fi | ||
|
|
||
| echo "PASS: ${test_name}" | ||
| } | ||
|
|
||
| run_redaction() { | ||
| rm -rf "${TMPDIR}/artifacts" | ||
| mkdir -p "${TMPDIR}/artifacts" | ||
| cp "${TMPDIR}/artifact.log" "${TMPDIR}/artifacts/artifact.log" | ||
| ARTIFACT_DIR="${TMPDIR}/artifacts" bash "${REDACT_SCRIPT}" >/dev/null | ||
| cp "${TMPDIR}/artifacts/artifact.log" "${TMPDIR}/artifact.log" | ||
| } | ||
|
|
||
| run_redaction_on_tree() { | ||
| ARTIFACT_DIR="${TMPDIR}/artifacts" bash "${REDACT_SCRIPT}" >/dev/null | ||
| } | ||
|
|
||
| echo "==> PEM block redaction" | ||
| cat >"${TMPDIR}/artifact.log" <<EOF | ||
| before | ||
| $(fake_pem_block "RSA" "MIIEowIBAAKCAQEAfake") | ||
| after | ||
| EOF | ||
| run_redaction | ||
| run_test "redacts-rsa-pem-block" "MIIEowIBAAKCAQEAfake" "[REDACTED PRIVATE KEY]" | ||
|
|
||
| cat >"${TMPDIR}/artifact.log" <<EOF | ||
| $(fake_pgp_block "lQOYBCA") | ||
| EOF | ||
| run_redaction | ||
| run_test "redacts-pgp-pem-block" "lQOYBCA" "[REDACTED PRIVATE KEY]" | ||
|
|
||
| echo "==> Token pattern redaction" | ||
| TOKEN="$(fake_ghp_token "abcdefghijklmnopqrstuvwxyz1234567890")" | ||
| cat >"${TMPDIR}/artifact.log" <<EOF | ||
| auth failed with ${TOKEN} | ||
| EOF | ||
| run_redaction | ||
| run_test "redacts-ghp-token" "${TOKEN}" | ||
|
|
||
| cat >"${TMPDIR}/artifact.log" <<EOF | ||
| remote: https://x-access-token:ghp_secret@github.com/org/repo.git | ||
| EOF | ||
| run_redaction | ||
| run_test "redacts-access-token-url" "ghp_secret" | ||
|
|
||
| echo "==> Literal secret redaction" | ||
| cat >"${TMPDIR}/artifact.log" <<'EOF' | ||
| dumped literal-secret-pem-value in log | ||
| Normal log line: assertion failed at step 3 | ||
| EOF | ||
| mkdir -p "${TMPDIR}/artifacts" | ||
| cp "${TMPDIR}/artifact.log" "${TMPDIR}/artifacts/artifact.log" | ||
| ARTIFACT_DIR="${TMPDIR}/artifacts" TEST_CODER_PEM="literal-secret-pem-value" bash "${REDACT_SCRIPT}" >/dev/null | ||
| cp "${TMPDIR}/artifacts/artifact.log" "${TMPDIR}/artifact.log" | ||
| run_test "redacts-literal-env-secret" "literal-secret-pem-value" "Normal log line: assertion failed at step 3" | ||
|
|
||
| cat >"${TMPDIR}/artifact.log" <<'EOF' | ||
| dumped literal-secret\value in log | ||
| EOF | ||
| mkdir -p "${TMPDIR}/artifacts" | ||
| cp "${TMPDIR}/artifact.log" "${TMPDIR}/artifacts/artifact.log" | ||
| ARTIFACT_DIR="${TMPDIR}/artifacts" TEST_CODER_PEM='literal-secret\value' bash "${REDACT_SCRIPT}" >/dev/null | ||
| cp "${TMPDIR}/artifacts/artifact.log" "${TMPDIR}/artifact.log" | ||
| run_test "redacts-literal-backslash-secret" 'literal-secret\value' | ||
|
|
||
| echo "==> Compressed artifact redaction" | ||
| rm -rf "${TMPDIR}/artifacts" | ||
| mkdir -p "${TMPDIR}/artifacts" | ||
| TOKEN="$(fake_ghp_token "abcdefghijklmnopqrstuvwxyz1234567890")" | ||
| printf 'token=%s\n' "${TOKEN}" >"${TMPDIR}/artifacts/secret.log" | ||
| gzip -c "${TMPDIR}/artifacts/secret.log" >"${TMPDIR}/artifacts/secret.log.gz" | ||
| rm -f "${TMPDIR}/artifacts/secret.log" | ||
| run_redaction_on_tree | ||
| gunzip -c "${TMPDIR}/artifacts/secret.log.gz" >"${TMPDIR}/artifact.log" | ||
| run_test "redacts-gzip-log" "${TOKEN}" | ||
|
|
||
| rm -rf "${TMPDIR}/artifacts" | ||
| mkdir -p "${TMPDIR}/artifacts/inner" | ||
| printf 'leaked literal-secret-pem-value here\n' >"${TMPDIR}/artifacts/inner/nested.log" | ||
| ( | ||
| cd "${TMPDIR}/artifacts/inner" | ||
| zip -qr "../bundle.zip" nested.log | ||
| ) | ||
| rm -rf "${TMPDIR}/artifacts/inner" | ||
| ARTIFACT_DIR="${TMPDIR}/artifacts" TEST_CODER_PEM="literal-secret-pem-value" bash "${REDACT_SCRIPT}" >/dev/null | ||
| mkdir -p "${TMPDIR}/unzipped" | ||
| unzip -q "${TMPDIR}/artifacts/bundle.zip" -d "${TMPDIR}/unzipped" | ||
| cp "${TMPDIR}/unzipped/nested.log" "${TMPDIR}/artifact.log" | ||
| run_test "redacts-zip-nested-log" "literal-secret-pem-value" | ||
|
|
||
| rm -rf "${TMPDIR}/artifacts" "${TMPDIR}/unzipped" | ||
| mkdir -p "${TMPDIR}/artifacts/inner" | ||
| printf 'leaked literal-secret-pem-value here\n' >"${TMPDIR}/artifacts/inner/nested.log" | ||
| tar -czf "${TMPDIR}/artifacts/bundle.tar.gz" -C "${TMPDIR}/artifacts/inner" nested.log | ||
| rm -rf "${TMPDIR}/artifacts/inner" | ||
| ARTIFACT_DIR="${TMPDIR}/artifacts" TEST_CODER_PEM="literal-secret-pem-value" bash "${REDACT_SCRIPT}" >/dev/null | ||
| mkdir -p "${TMPDIR}/unzipped" | ||
| tar -xzf "${TMPDIR}/artifacts/bundle.tar.gz" -C "${TMPDIR}/unzipped" | ||
| cp "${TMPDIR}/unzipped/nested.log" "${TMPDIR}/artifact.log" | ||
| run_test "redacts-tar-gz-nested-log" "literal-secret-pem-value" | ||
|
|
||
| echo "==> Encrypted/opaque artifact handling" | ||
| rm -rf "${TMPDIR}/artifacts" "${TMPDIR}/unzipped" | ||
| mkdir -p "${TMPDIR}/artifacts" | ||
| printf 'opaque-binary-secret' >"${TMPDIR}/artifacts/payload.gpg" | ||
| run_redaction_on_tree | ||
| cp "${TMPDIR}/artifacts/payload.gpg" "${TMPDIR}/artifact.log" | ||
| run_test "stubs-encrypted-artifact" "opaque-binary-secret" "[REDACTED OPAQUE CONTENT]" | ||
|
|
||
| rm -rf "${TMPDIR}/artifacts" | ||
| mkdir -p "${TMPDIR}/artifacts" | ||
| printf 'GIF89a' >"${TMPDIR}/artifacts/exfil.gif" | ||
| printf '%s' "$(printf 'fake-secret-payload' | base64)" >>"${TMPDIR}/artifacts/exfil.gif" | ||
| run_redaction_on_tree | ||
| cp "${TMPDIR}/artifacts/exfil.gif" "${TMPDIR}/artifact.log" | ||
| run_test "stubs-fake-media-artifact" "fake-secret-payload" "[REDACTED OPAQUE CONTENT]" | ||
|
|
||
| echo "" | ||
| if [ "${FAILURES}" -gt 0 ]; then | ||
| echo "${FAILURES} test(s) failed" | ||
| exit 1 | ||
| fi | ||
| echo "All redact-behaviour-artifacts tests passed" | ||
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.
Uh oh!
There was an error while loading. Please reload this page.