Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 34 additions & 11 deletions .github/workflows/workflow-linter.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# This workflow is managed by gh actions-lock.
# SPDX-License-Identifier: MPL-2.0
# This workflow is managed by gh actions-lock.
# This workflow is managed by gh actions-lock.
# This workflow is managed by gh actions-lock.
# workflow-linter.yml - Validates GitHub workflows against RSR security standards
# This workflow can be copied to other repos for consistent enforcement
name: Workflow Security Linter

on:
push:
# A PR push already runs this through pull_request; push runs only on
# main, so each PR push is linted once and main is still checked after merge.
branches:
- main
paths:
- '.github/workflows/**'
pull_request:
Expand All @@ -24,7 +25,7 @@ permissions:

jobs:
lint-workflows:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
Expand All @@ -39,13 +40,15 @@ jobs:
failed=0
for file in .github/workflows/*.yml .github/workflows/*.yaml; do
[ -f "$file" ] || continue
if ! head -1 "$file" | grep -q "^# SPDX-License-Identifier:"; then
# actions-lock may prepend its own comment. Require the licence
# in the leading comment block, before the workflow body.
if ! awk '/^# SPDX-License-Identifier:/ { found=1 } /^[[:space:]]*[^#[:space:]]/ { exit } END { exit !found }' "$file"; then
echo "ERROR: $file missing SPDX header"
failed=1
fi
done
if [ $failed -eq 1 ]; then
echo "Add '# SPDX-License-Identifier: MPL-2.0' as first line"
echo "Add '# SPDX-License-Identifier: MPL-2.0' to the leading comment block"
exit 1
fi
echo "All workflows have SPDX headers"
Expand All @@ -67,18 +70,39 @@ jobs:
fi
echo "All workflows have permissions declared"

# Bun is the estate's first-choice runtime (LANGUAGE-POLICY.adoc §1:
# Bun > Deno > pnpm > npm). It is the estate pin 1.4.2, downloaded and
# sha256-checked as Estate Rules installs its tools, so this gate runs
# no third-party action and no unpinned runtime.
- name: Install verified Bun 1.4.2
run: |
curl --proto '=https' --proto-redir '=https' --fail --silent --show-error --location \
https://github.com/oven-sh/bun/releases/download/bun-v1.4.2/bun-linux-x64.zip \
--output "$RUNNER_TEMP/bun.zip"
echo "36368faef7527875d5ffa52e53cd48021741f2a83eb6208a8dd64068d422a913 $RUNNER_TEMP/bun.zip" | sha256sum --check --strict
unzip -q "$RUNNER_TEMP/bun.zip" -d "$RUNNER_TEMP"
echo "$RUNNER_TEMP/bun-linux-x64" >> "$GITHUB_PATH"

- name: Check SHA-Pinned Actions
run: |
echo "=== Checking Action Pinning ==="
# Find any uses: lines that don't have @SHA format
# Pattern: uses: owner/repo@<40-char-hex>
unpinned=$(grep -rnE "^[[:space:]]+uses:" .github/workflows/ | \
grep -v "@[a-f0-9]\{40\}" | \
grep -v "uses: \./\|uses: docker://\|uses: actions/github-script" || true)
# Delegated to scripts/check-action-pinning.js. The rule it enforces is
# unchanged in spirit — every action ref must resolve to an immutable
# commit — but "pinned" now includes refs the workflow lockfile
# resolves, which is how this repo pins them. Kept as a script rather
# than inline because the inline form needs a heredoc inside a YAML
# block scalar, and that is a well-known way to ship a gate that
# silently does nothing.
if ! bun scripts/check-action-pinning.js; then
unpinned="see above"
else
unpinned=""
fi

if [ -n "$unpinned" ]; then
echo "ERROR: Found unpinned actions:"
echo "$unpinned"
echo ""
echo "Replace version tags with SHA pins, e.g.:"
echo " uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6.0.1"
Expand Down Expand Up @@ -118,7 +142,6 @@ jobs:
has_rb=$(find . -name "*.rb" -path "*/lib/*" -o -path "*/app/*" 2>/dev/null | head -1)

echo "Detected languages:"
[ -n "$has_js" ] && echo " - javascript-typescript"
[ -n "$has_py" ] && echo " - python"
[ -n "$has_go" ] && echo " - go"
[ -n "$has_rs" ] && echo " - rust (note: CodeQL rust is limited)"
Expand Down
Loading
Loading