Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/static-analysis-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,17 @@ jobs:
if: always()
steps:
- name: Download panic-attack findings
uses: actions/download-artifact@v8.0.2
uses: actions/download-artifact@v8.0.1
with:
name: panic-attack-findings
path: findings/
- name: Download hypatia findings
uses: actions/download-artifact@v8.0.2
uses: actions/download-artifact@v8.0.1
with:
name: hypatia-findings
path: findings/
- name: Download bridge report
uses: actions/download-artifact@v8.0.2
uses: actions/download-artifact@v8.0.1
with:
name: bridge-report
path: findings/
Expand Down
25 changes: 20 additions & 5 deletions .github/workflows/wellknown-enforcement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ on:
branches: [main, master]
paths:
- '.well-known/**'
- 'www/.well-known/**'
- 'security.txt'
- '.github/workflows/wellknown-enforcement.yml'
pull_request:
paths:
- '.well-known/**'
- 'www/.well-known/**'
- 'security.txt'
- '.github/workflows/wellknown-enforcement.yml'
schedule:
# Weekly expiry check
- cron: '0 9 * * *'
Expand All @@ -29,8 +34,12 @@ jobs:
- name: RFC 9116 security.txt validation
run: |
SECTXT=""
[ -f ".well-known/security.txt" ] && SECTXT=".well-known/security.txt"
[ -f "security.txt" ] && SECTXT="security.txt"
for candidate in www/.well-known/security.txt .well-known/security.txt security.txt; do
if [ -f "$candidate" ]; then
SECTXT="$candidate"
break
fi
done

if [ -z "$SECTXT" ]; then
echo "::error::No security.txt found — required for OpenSSF Best Practices. See https://github.com/hyperpolymath/well-known-ecosystem"
Expand All @@ -48,6 +57,10 @@ jobs:

# Check expiry
EXPIRES=$(grep "^Expires:" "$SECTXT" | cut -d: -f2- | tr -d ' ' | head -1)
if ! date -d "$EXPIRES" > /dev/null 2>&1; then
echo "::error::security.txt Expires field is not a valid date"
exit 1
fi
if date -d "$EXPIRES" > /dev/null 2>&1; then
DAYS=$(( ($(date -d "$EXPIRES" +%s) - $(date +%s)) / 86400 ))
if [ $DAYS -lt 0 ]; then
Expand All @@ -62,9 +75,11 @@ jobs:
- name: RSR well-known compliance
run: |
MISSING=""
[ ! -f ".well-known/security.txt" ] && [ ! -f "security.txt" ] && MISSING="$MISSING security.txt"
[ ! -f ".well-known/ai.txt" ] && MISSING="$MISSING ai.txt"
[ ! -f ".well-known/humans.txt" ] && MISSING="$MISSING humans.txt"
for name in security.txt ai.txt humans.txt; do
if [ ! -f "www/.well-known/$name" ] && [ ! -f ".well-known/$name" ] && [ ! -f "$name" ]; then
MISSING="$MISSING $name"
fi
done

if [ -n "$MISSING" ]; then
echo "::warning::Missing RSR recommended files:$MISSING"
Expand Down
27 changes: 7 additions & 20 deletions .github/workflows/workflow-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ 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
if ! head -6 "$file" | grep -q "^# SPDX-License-Identifier:"; 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 "Require an SPDX identifier in the first six header lines (allow gh actions-lock managed preamble)"
exit 1
fi
echo "All workflows have SPDX headers"
Expand All @@ -63,24 +63,11 @@ jobs:
fi
echo "All workflows have permissions declared"

- 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)

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"
exit 1
fi
echo "All actions are SHA-pinned"
- name: Self-test lock integrity checker (positive and negative)
run: bash tests/workflows/check-workflow-uses-lock_test.sh

- name: Check SHA-Pinned or generated lockfile-pinned Actions
run: bash scripts/check-workflow-uses-lock.sh .
Comment on lines +66 to +70

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Trigger linting when checker inputs change

When a PR modifies only scripts/check-workflow-uses-lock.sh or tests/workflows/check-workflow-uses-lock_test.sh, this workflow is skipped because its pull_request.paths and push.paths sections still match only .github/workflows/**. A repository-wide search shows no other workflow invoking these new checks, so the enforcement or its tests can be changed without running either command; include both paths in the workflow triggers.

Useful? React with 👍 / 👎.

Comment on lines +69 to +70

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reconcile upload-artifact refs before enabling the check

After the self-test is fixed, this newly enabled command still exits with status 1 on the current tree: static-analysis-gate.yml contains four actions/upload-artifact@v7.0.2 uses, while its per-workflow entry in actions.lock lists only actions/upload-artifact@v7.0.1. The separate v7.0.2 dependency record does not satisfy the script's exact per-workflow lookup, so this lint step remains unconditionally red until the lockfile is regenerated or those workflow refs are aligned.

Useful? React with 👍 / 👎.


- name: Check for Duplicate Workflows
run: |
Expand Down
73 changes: 73 additions & 0 deletions scripts/check-workflow-uses-lock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
# Verify that every non-local GitHub Action is pinned directly to a 40-hex
# commit or is resolved to a full commit in the generated gh actions-lock file.
# Do not modify actions.lock by hand.
set -euo pipefail

root="$(cd "$(dirname "$0")/.." && pwd)"
if [ "$#" -gt 0 ]; then root="$(cd "$1" && pwd)"; fi

Check failure on line 9 in scripts/check-workflow-uses-lock.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_scaffoldia&issues=AaHfxMA98-rYvi0m48C7&open=AaHfxMA98-rYvi0m48C7&pullRequest=69
lock="$root/.github/workflows/actions.lock"
if [ ! -s "$lock" ]; then

Check failure on line 11 in scripts/check-workflow-uses-lock.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_scaffoldia&issues=AaHfxMA98-rYvi0m48C8&open=AaHfxMA98-rYvi0m48C8&pullRequest=69
echo "FAIL: missing generated actions.lock: $lock" >&2
exit 1
fi

fail=0
checked=0
shopt -s nullglob
for file in "$root"/.github/workflows/*.yml "$root"/.github/workflows/*.yaml; do
rel=".github/workflows/$(basename "$file")"
while IFS= read -r line; do
# Comments (including workflow examples) do not match the anchored selector.
spec="$(printf '%s\n' "$line" | sed -nE 's/^[[:space:]]*(-[[:space:]]*)?uses:[[:space:]]*([^[:space:]#]+).*$/\2/p')"
[ -n "$spec" ] || continue

Check failure on line 24 in scripts/check-workflow-uses-lock.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_scaffoldia&issues=AaHfxMA98-rYvi0m48C9&open=AaHfxMA98-rYvi0m48C9&pullRequest=69
checked=$((checked + 1))
case "$spec" in

Check failure on line 26 in scripts/check-workflow-uses-lock.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a default case (*) to handle unexpected values.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_scaffoldia&issues=AaHfxMA98-rYvi0m48C-&open=AaHfxMA98-rYvi0m48C-&pullRequest=69
./*) continue ;;
docker://*) echo "FAIL: $rel uses a Docker action without a reviewed digest: $spec" >&2; fail=1; continue ;;
esac

source="$(printf '%s\n' "$spec" | cut -d@ -f1)"
version="$(printf '%s\n' "$spec" | awk -F@ '{print $NF}')"
if [ "$source" = "$spec" ] || ! [[ "$source" == */* ]]; then

Check failure on line 33 in scripts/check-workflow-uses-lock.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_scaffoldia&issues=AaHfxMA98-rYvi0m48C_&open=AaHfxMA98-rYvi0m48C_&pullRequest=69
echo "FAIL: $rel uses an action without an immutable ref: $spec" >&2
fail=1
continue
fi
# Native full-SHA uses (including reusable workflows) are immutable.
if [[ "$version" =~ ^[0-9a-f]{40}$ ]]; then continue; fi
# A tag is allowed only when the generated lock includes a matching
# workflow reference AND an exact ref->sha1-40 dependency record.
owner="$(printf '%s\n' "$source" | cut -d/ -f1)"
name="$(printf '%s\n' "$source" | cut -d/ -f2)"
key="$owner/$name@$version"

if ! awk -v wf=" '$rel':" -v key=" - '$key'" '
$0 == "dependencies:" {exit}
$0 == wf {inside=1; next}
inside && /^ [^ ]/ {inside=0}
inside && $0 == key {found=1}
END {exit(found ? 0 : 1)}
' "$lock"; then
echo "FAIL: $rel: $key is missing from actions.lock workflow entries" >&2
fail=1
continue
fi

record="$(awk -v key=" '$key':" '
$0 == "dependencies:" {deps=1; next}
deps && $0 == key {inside=1; next}
inside && /^ [^ ]/ {exit}
inside {print}
' "$lock")"
if ! printf '%s\n' "$record" | grep -Fxq " ref: '$version'" ||
! printf '%s\n' "$record" | grep -Eq "^[[:space:]]+commit: 'sha1-[0-9a-f]{40}'$"; then
echo "FAIL: $rel: lock entry $key lacks matching ref and 40-hex SHA" >&2
fail=1
fi
done < "$file"
done
[ "$checked" -gt 0 ] || { echo "FAIL: no active action uses found" >&2; exit 1; }

Check failure on line 71 in scripts/check-workflow-uses-lock.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_scaffoldia&issues=AaHfxMA98-rYvi0m48DA&open=AaHfxMA98-rYvi0m48DA&pullRequest=69
[ "$fail" -eq 0 ] || exit 1

Check failure on line 72 in scripts/check-workflow-uses-lock.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_scaffoldia&issues=AaHfxMA98-rYvi0m48DB&open=AaHfxMA98-rYvi0m48DB&pullRequest=69
echo "PASS: $checked uses resolve to direct 40-hex pins or generated actions.lock SHA records"
31 changes: 31 additions & 0 deletions tests/workflows/check-workflow-uses-lock_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
# Offline positive/negative fixtures for the lock-aware workflow pin checker.
set -euo pipefail
root="$(cd "$(dirname "$0")/../.." && pwd)"
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
mkdir -p "$tmp/.github/workflows"
sha="$(printf 'a%.0s' {1..40})"
cat > "$tmp/.github/workflows/actions.lock" <<EOF
version: 'v0.0.3'
workflows:
'.github/workflows/fixture.yml':
- 'actions/checkout@v7.0.1'
dependencies:
'actions/checkout@v7.0.1':
ref: 'v7.0.1'
commit: 'sha1-$sha'
owner_id: 1
repo_id: 2
EOF
printf '%s\n' 'name: fixture' 'jobs:' ' run:' ' steps:' ' - uses: actions/checkout@v7.0.1' > "$tmp/.github/workflows/fixture.yml"
bash "$root/scripts/check-workflow-uses-lock.sh" "$tmp"
sed -i 's/checkout@v7.0.1/checkout@v7.0.2/' "$tmp/.github/workflows/fixture.yml"
if bash "$root/scripts/check-workflow-uses-lock.sh" "$tmp" >/dev/null 2>&1; then
echo 'FAIL: mismatched workflow tag was wrongly accepted' >&2
exit 1
fi
printf '%s\n' 'name: fixture' 'jobs:' ' run:' ' steps:' " - uses: actions/checkout@$sha" > "$tmp/.github/workflows/fixture.yml"
bash "$root/scripts/check-workflow-uses-lock.sh" "$tmp"
printf '%s\n' 'PASS: matching lock, mismatched ref, and direct SHA cases verified'
Loading