From 61040c2c9a9fcaa55146c4249e14219e650acf51 Mon Sep 17 00:00:00 2001 From: Kaio Magalhaes Date: Sun, 9 Aug 2026 13:19:53 -0300 Subject: [PATCH 1/2] Run the workflows against this repo on merge and PR This repository ships reusable workflows and had no CI of its own, so nothing was exercised until after it had already landed in every consuming repo - which, since they all reference @main unpinned, meant production was the test environment. Two bugs shipped that way: a documented `allowed_outdated_libraries` input that never existed, and gate steps whose jq check ignored --audit-level entirely. Adds self-scan.yml with two jobs: - secret-scan: calls security.yml on this repo. notify_webhook is off because there is no SECURITY_WEBHOOK_URL secret here and validate-inputs correctly fails when notifications are on without one. scan_filesystem is on, which is safe since those findings are advisory. - lint-workflows: runs actionlint, which validates workflow syntax, expressions and contexts, and runs shellcheck over the inline `run:` scripts - where the real logic in this repo lives. Installed from a pinned release with checksum verification rather than via a third-party action, matching how TruffleHog is installed. Runs on pull_request as well as pushes to main. Catching a problem before the merge is the point, given consumers pick up @main instantly. node-security-dependency-scan.yml is deliberately not called: it runs `npm ci` and this repository has no package.json, so it would fail for reasons unrelated to whether the workflow is correct. Also fixes the one issue actionlint found in existing code - SC2129, individual redirects to $GITHUB_STEP_SUMMARY in the OWASP report step, now a single grouped redirect - so the new job starts green. Verified: actionlint 1.7.12 reports no issues across all four workflow files, and the checksum grep the install step uses was run against the real actionlint release, matching exactly one line. Co-Authored-By: Claude Opus 5 (1M context) --- .../node-security-dependency-scan.yml | 8 +- .github/workflows/self-scan.yml | 75 +++++++++++++++++++ 2 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/self-scan.yml diff --git a/.github/workflows/node-security-dependency-scan.yml b/.github/workflows/node-security-dependency-scan.yml index 0a470df..f31fc2d 100644 --- a/.github/workflows/node-security-dependency-scan.yml +++ b/.github/workflows/node-security-dependency-scan.yml @@ -181,9 +181,11 @@ jobs: run: | if [ -d reports ] && [ -n "$(ls -A reports 2>/dev/null)" ]; then echo "::warning title=OWASP Dependency Check::Report generated - download the 'owasp-dependency-check-report' artifact to review findings." - echo "## OWASP Dependency Check" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "Report available as the \`owasp-dependency-check-report\` artifact." >> "$GITHUB_STEP_SUMMARY" + { + echo "## OWASP Dependency Check" + echo "" + echo "Report available as the \`owasp-dependency-check-report\` artifact." + } >> "$GITHUB_STEP_SUMMARY" else echo "::warning title=OWASP Dependency Check::No report was produced - the scan may not have completed." fi diff --git a/.github/workflows/self-scan.yml b/.github/workflows/self-scan.yml new file mode 100644 index 0000000..4cf9181 --- /dev/null +++ b/.github/workflows/self-scan.yml @@ -0,0 +1,75 @@ +# This repository ships reusable workflows, so nothing here ran against +# itself - changes were only exercised once they had already landed in every +# consuming repo. This runs them on this repo instead, and lints the workflow +# files, so a broken change is caught here rather than downstream. +# +# Runs on pull_request as well as pushes to main: catching a problem before +# the merge is the point, since consumers pick up `@main` immediately. +name: Self Scan + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +env: + ACTIONLINT_VERSION: "1.7.12" + +jobs: + # Dogfood the secret scanner on this repository. + # + # notify_webhook is off: this repo has no SECURITY_WEBHOOK_URL secret, and + # validate-inputs correctly fails when notifications are on without one. + # + # node-security-dependency-scan.yml is deliberately NOT called here - it + # runs `npm ci`, and this repository has no package.json, so it would fail + # for reasons that say nothing about whether the workflow is correct. + secret-scan: + uses: ./.github/workflows/security.yml + with: + notify_webhook: false + scan_filesystem: true + show_keys: false + + # Catches invalid workflow syntax, bad expressions, unknown contexts, and - + # via shellcheck - bugs in the inline `run:` scripts, which is where the + # real logic in this repo lives. + lint-workflows: + name: Lint workflows + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install actionlint + run: | + set -euo pipefail + + BINARY="actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" + CHECKSUMS="actionlint_${ACTIONLINT_VERSION}_checksums.txt" + BASE="https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}" + + TEMP_DIR=$(mktemp -d) + cd "$TEMP_DIR" + + curl -sSfL -o "$BINARY" "${BASE}/${BINARY}" + curl -sSfL -o "$CHECKSUMS" "${BASE}/${CHECKSUMS}" + + # Verified rather than trusted, and installed from a pinned release + # instead of a third-party action, matching how TruffleHog is + # installed in security.yml. + grep " ${BINARY}\$" "$CHECKSUMS" | sha256sum -c - + + tar -xzf "$BINARY" actionlint + sudo install -m 755 actionlint /usr/local/bin/actionlint + cd / && rm -rf "$TEMP_DIR" + + actionlint --version + + - name: Run actionlint + run: actionlint -color From 2051fd8e9dc41b5f574b614d8d298dbdc3f9c50c Mon Sep 17 00:00:00 2001 From: Kaio Magalhaes Date: Sun, 9 Aug 2026 13:38:44 -0300 Subject: [PATCH 2/2] Run the self scan on every branch push Was push-to-main plus pull_request. Now `branches: ["**"]`, matching how consuming repos call these workflows, so every push exercises them. Dropped the pull_request trigger: with pushes on all branches it only duplicated runs for same-repo branches. The tradeoff is that PRs opened from forks no longer trigger a run, since fork pushes do not fire in the base repo. Worth adding back if this repo ever takes fork contributions. Documented why the jobs use local `./.github/...` references rather than `@main`: GitHub resolves a local reusable-workflow reference against the same commit as the caller, so a branch push tests that branch's copy. Referencing `@main` would silently test the already-merged version and defeat the purpose. Verified rather than assumed. Pushed a scratch branch carrying a marker echo that existed only on that branch, and the marker executed inside the secret-scan job - confirming the called workflow comes from the branch commit, not from main. Scratch branch removed. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/self-scan.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/self-scan.yml b/.github/workflows/self-scan.yml index 4cf9181..41d75bc 100644 --- a/.github/workflows/self-scan.yml +++ b/.github/workflows/self-scan.yml @@ -3,14 +3,20 @@ # consuming repo. This runs them on this repo instead, and lints the workflow # files, so a broken change is caught here rather than downstream. # -# Runs on pull_request as well as pushes to main: catching a problem before -# the merge is the point, since consumers pick up `@main` immediately. +# Runs on every branch, not just main. Consumers pick up `@main` the instant +# it lands, so a signal that only arrives after merge is already too late. +# +# The jobs below reference the workflows by local path (`./.github/...`) +# rather than `@main`. That is deliberate and is what makes this test the +# *current* version: GitHub resolves a local reusable-workflow reference +# against the same commit as the caller, so a push to any branch exercises +# that branch's copy. Using `@main` here would test the already-merged +# version and defeat the point. name: Self Scan on: push: - branches: [main] - pull_request: + branches: ["**"] permissions: contents: read