#!/bin/bash set -euo pipefail cd "$(dirname "$0")/../.." work=$(mktemp -d "${TMPDIR:-/tmp}/parcel-security.XXXXXX") trap 'rm -rf "$work"' EXIT mkdir -p "$work/repository" "$work/checks" git -C "$work/repository" init -q git -C "$work/repository" config user.name 'Fixture Author' git -C "$work/repository" config user.email fixture@example.invalid cp .gitleaksignore "$work/repository/" printf 'clean fixture\n' > "$work/repository/fixture" git -C "$work/repository" add . git -C "$work/repository" -c core.hooksPath=/dev/null commit -q -sm 'Clean fixture' gitleaks git --redact "$work/repository" > "$work/scan.log" 2>&1 # Synthetic token: a negative control, never an actual credential. seed=$(openssl rand -hex 18) printf 'token="ghp_%s"\n' "$seed" > "$work/repository/seed" git -C "$work/repository" add seed git -C "$work/repository" -c core.hooksPath=/dev/null commit -q -sm 'Seed fixture' if gitleaks git --redact --report-format json --report-path "$work/findings.json" "$work/repository" > "$work/scan.log" 2>&1; then printf 'Secret scanner accepted a seeded credential.\n' >&2 exit 1 fi grep -q REDACTED "$work/findings.json" if grep -Fq "$seed" "$work/findings.json"; then printf 'Secret scanner report was not redacted.\n' >&2 exit 1 fi cat > "$work/checks/workflow.yml" <<'YAML' name: Fixture on: pull_request permissions: contents: read jobs: check: name: Fixture runs-on: macos-15 timeout-minutes: 5 steps: - run: printf '%s\n' '${{ github.event.pull_request.title }}' YAML if zizmor --offline --pedantic "$work/checks/workflow.yml" > "$work/workflow.log" 2>&1; then printf 'Workflow scanner accepted a seeded shell injection.\n' >&2 exit 1 fi grep -q template-injection "$work/workflow.log" printf 'Secret and workflow security negative controls passed.\n'