diff --git a/.github/workflows/privacy-guard.yml b/.github/workflows/privacy-guard.yml index 8b69f4e..5d7c78c 100644 --- a/.github/workflows/privacy-guard.yml +++ b/.github/workflows/privacy-guard.yml @@ -21,17 +21,25 @@ name: Privacy Guard on: push: pull_request: + # Deviation from the vllnt/skills template: pre-existing history fails + # the full-history email scan, and the template has no SHA baseline. + # The required job scopes push scans to the pushed range; this + # scheduled/manual job reports a full-history audit and is not required. + schedule: + - cron: "17 4 * * 1" + workflow_dispatch: permissions: contents: read concurrency: - group: privacy-guard-${{ github.head_ref || github.ref }} + group: privacy-guard-${{ github.event_name }}-${{ github.head_ref || github.ref }} cancel-in-progress: true jobs: privacy-guard: name: Privacy Guard + if: github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' runs-on: ubuntu-latest env: GITLEAKS_VERSION: "8.30.1" @@ -82,12 +90,12 @@ jobs: REF_NAME: ${{ github.ref_name }} run: | set -euo pipefail - # Pull requests: the commits this PR adds. Push to the default - # branch: the full history. Other pushes: the pushed range. + # Deviation from the vllnt/skills template: pre-existing history + # fails the full-history email scan, and the template has no SHA + # baseline. Pull requests: the commits this PR adds. Pushes with + # a known before SHA: the pushed range. Otherwise: full history. if [[ "$EVENT_NAME" == "pull_request" ]]; then export PRIVACY_COMMIT_RANGE="${PR_BASE}..${PR_HEAD}" - elif [[ "$EVENT_NAME" == "push" && "$REF_NAME" == "$DEFAULT_BRANCH" ]]; then - export PRIVACY_COMMIT_RANGE="--all" elif [[ "$EVENT_NAME" == "push" && "${BEFORE:-}" != "" && "$BEFORE" != 0000000000000000000000000000000000000000 ]]; then export PRIVACY_COMMIT_RANGE="${BEFORE}..HEAD" else @@ -108,3 +116,52 @@ jobs: fi - name: Check package contents run: bash scripts/check-package-contents.sh + + privacy-guard-history-audit: + name: Privacy Guard history audit + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + env: + GITLEAKS_VERSION: "8.30.1" + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install gitleaks + run: | + set -euo pipefail + base="https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}" + archive="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" + curl -sSfL -o "$RUNNER_TEMP/$archive" "$base/$archive" + curl -sSfL -o "$RUNNER_TEMP/checksums.txt" "$base/gitleaks_${GITLEAKS_VERSION}_checksums.txt" + (cd "$RUNNER_TEMP" && grep " ${archive}\$" checksums.txt | sha256sum -c -) + tar -xzf "$RUNNER_TEMP/$archive" -C "$RUNNER_TEMP" gitleaks + echo "$RUNNER_TEMP" >> "$GITHUB_PATH" + - name: Scan history for secrets + run: gitleaks detect --source . --log-opts=--all --redact --no-banner --exit-code 1 + - name: Test denylist guard + run: bash scripts/test-privacy-denylist.sh + - name: Test commit-metadata email check + run: bash scripts/test-check-commit-emails.sh + - name: Check denylist + env: + PRIVACY_DENYLIST_EXTRA: ${{ secrets.PRIVACY_DENYLIST_EXTRA }} + run: | + set -euo pipefail + code=0 + bash scripts/privacy-denylist.sh || code=$? + if [[ "$code" -eq 0 ]]; then + exit 0 + fi + if [[ "$code" -eq 2 && -n "${PRIVACY_DENYLIST_EXTRA:-}" ]]; then + echo "::warning title=Privacy guard::PRIVACY_DENYLIST_EXTRA has invalid regex line(s) for git grep -E. Re-running with the tracked denylist only. Fix the Actions secret." + unset PRIVACY_DENYLIST_EXTRA + bash scripts/privacy-denylist.sh + exit $? + fi + exit "$code" + - name: Check commit emails and trailers (full history) + run: | + set -euo pipefail + export PRIVACY_COMMIT_RANGE="--all" + bash scripts/check-commit-emails.sh