Repository navigation
fix(ci): apply foundation CI/CD security fixes #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
44aa2a4
fix(ci): apply foundation CI/CD security fixes
hyperpolymath fb20771
Merge branch 'main' into chore/apply-foundation-ci-fixes-20260911
mistral-vibe 2270f49
fix(ci): address review findings - remove duplicate steps from scorec…
mistral-vibe 66b5daf
fix(ci): address review findings - add persist-credentials to all che…
mistral-vibe c49be4b
fix(ci): add step-security/harden-runner for RE001 compliance
mistral-vibe 17ec53c
fix(ci): add permissions block to main-estate-audit.yml to address Co…
mistral-vibe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| name: 'Affirmation Document Gate' | ||
| description: 'Validates an applicable AFFIRMATION snapshot without treating it as a universal or self-proving document.' | ||
| inputs: | ||
| required: | ||
| description: 'Set true only when the repository declares the governance-tier capability.' | ||
| required: false | ||
| default: 'false' | ||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Run Affirmation Check | ||
| shell: bash | ||
| env: | ||
| AFFIRMATION_REQUIRED: ${{ inputs.required }} | ||
| run: "${{ github.action_path }}/check.sh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| root=${GITHUB_WORKSPACE:-.} | ||
| required=${AFFIRMATION_REQUIRED:-false} | ||
| aff_file= | ||
|
|
||
| for candidate in AFFIRMATION.adoc AFFIRMATION.md AFFIRMATION; do | ||
| if [[ -f "$root/$candidate" ]]; then | ||
| aff_file=$candidate | ||
| break | ||
| fi | ||
| done | ||
|
|
||
| if [[ -z "$aff_file" ]]; then | ||
| if [[ "$required" == "true" ]]; then | ||
| echo "::error::AFFIRMATION.adoc is required by the declared governance-tier capability." | ||
| exit 1 | ||
| fi | ||
| echo "::notice::AFFIRMATION is not applicable: governance-tier was not required." | ||
| exit 0 | ||
| fi | ||
|
|
||
| path=$root/$aff_file | ||
| echo "Found AFFIRMATION document: $aff_file" | ||
|
|
||
| substantive_lines=$(awk '!/^[[:space:]]*(#|\/\/|;|$)/ { count++ } END { print count + 0 }' "$path") | ||
| if (( substantive_lines < 5 )); then | ||
| echo "::error::$aff_file has only $substantive_lines substantive lines; it is a stub, not an affirmation." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if grep -qiE '\{\{|TODO: update|<PROJECT|YOUR_PROJECT|lorem ipsum|example\.com' "$path"; then | ||
| echo "::error::$aff_file contains template placeholders." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # The signature is the signature on the commit containing this content. Text | ||
| # such as "Signed:" inside the document proves nothing. Shallow checkouts may | ||
| # not contain the file-changing commit, so report that limitation honestly. | ||
| signature=N | ||
| last_update_ts= | ||
| if git -C "$root" rev-parse --is-inside-work-tree >/dev/null 2>&1; then | ||
| signature=$(git -C "$root" log -1 --format='%G?' -- "$aff_file" 2>/dev/null || true) | ||
| last_update_ts=$(git -C "$root" log -1 --format='%at' -- "$aff_file" 2>/dev/null || true) | ||
| fi | ||
|
|
||
| case "$signature" in | ||
| G) echo "Affirmation commit signature verified with a trusted key." ;; | ||
| U) echo "::notice::Affirmation commit has a valid signature from an untrusted or locally unknown key." ;; | ||
| B|R|E) echo "::error::Affirmation commit signature is bad, revoked, or failed verification."; exit 1 ;; | ||
| *) echo "::notice::Affirmation commit signature could not be verified from the available Git history." ;; | ||
| esac | ||
|
|
||
| # A dated affirmation is a frozen receipt, not a claim that remains current | ||
| # forever. Report age without invalidating historical evidence or forcing an | ||
| # empty monthly rewrite. | ||
| if [[ -n "$last_update_ts" ]]; then | ||
| current_ts=$(date +%s) | ||
| age_days=$(( (current_ts - last_update_ts) / 86400 )) | ||
| if (( age_days > 28 )); then | ||
| echo "::warning::$aff_file is a $age_days-day-old snapshot; verify its anchor before relying on it as current." | ||
| else | ||
| echo "$aff_file snapshot age: $age_days days." | ||
| fi | ||
| fi | ||
|
|
||
| echo "AFFIRMATION document validation passed." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) | ||
| fixture=$(mktemp -d) | ||
| trap 'rm -rf -- "$fixture"' EXIT | ||
|
|
||
| GITHUB_WORKSPACE=$fixture AFFIRMATION_REQUIRED=false "$here/check.sh" | ||
|
|
||
| if GITHUB_WORKSPACE=$fixture AFFIRMATION_REQUIRED=true "$here/check.sh"; then | ||
| echo "required-but-absent affirmation unexpectedly passed" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| printf '= AFFIRMATION\n' > "$fixture/AFFIRMATION.adoc" | ||
| if GITHUB_WORKSPACE=$fixture AFFIRMATION_REQUIRED=true "$here/check.sh"; then | ||
| echo "stub affirmation unexpectedly passed" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| printf '%s\n' \ | ||
| '= AFFIRMATION — controlled fixture' \ | ||
| 'This snapshot makes a falsifiable claim.' \ | ||
| 'The claim is anchored to a named revision.' \ | ||
| 'Tests were run and their scope is stated.' \ | ||
| 'Unproved properties are not called proved.' \ | ||
| 'Later revisions must be assessed separately.' \ | ||
| > "$fixture/AFFIRMATION.adoc" | ||
| GITHUB_WORKSPACE=$fixture AFFIRMATION_REQUIRED=true "$here/check.sh" | ||
|
|
||
| echo 'affirmation-check controls passed' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: 'Accreditations & Badges Gate' | ||
| description: 'Validates presence, standing, and non-drift of accreditations and badges (GLAMA, Greenweb, OpenSSF, RSR, etc.).' | ||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Run Badges and Accreditations Check | ||
| shell: bash | ||
| run: | | ||
| echo "Validating Accreditations and Badges..." | ||
| README="README.adoc" | ||
| [ -f "README.md" ] && README="README.md" | ||
|
|
||
| if [ ! -f "$README" ]; then | ||
| echo "::warning::No README found to check badges." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Check for core badges | ||
| for badge in "GLAMA" "Greenweb" "OpenSSF" "License"; do | ||
| if ! grep -qi "$badge" "$README"; then | ||
| echo "::warning::Missing $badge badge in $README. Check standing and display." | ||
| fi | ||
| done | ||
|
|
||
| # Check Idris Inside / RSR compliance | ||
| if [ -d "src" ] || ls *.ipkg 1>/dev/null 2>] || ls *.ipkg 1>/dev/null 2>&11; then | ||
| if ! grep -qi "Idris Inside" "$README"; then | ||
| echo "::warning::Idris source detected but 'Idris Inside' badge is missing." | ||
| fi | ||
| if ! grep -qi "RSR" "$README"; then | ||
| echo "::warning::Missing RSR-compliant badge in Idris repository." | ||
| fi | ||
| fi | ||
|
|
||
| echo "Badges and Accreditations validation complete." | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| name: 'BoJ Cartridge Gate' | ||
| description: 'Checks for a BoJ cartridge when BoJ integration is applicable.' | ||
| inputs: | ||
| required: | ||
| description: 'Set true when this repository declares BoJ integration.' | ||
| required: false | ||
| default: 'false' | ||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Run BoJ Cartridge Check | ||
| shell: bash | ||
| env: | ||
| BOJ_CARTRIDGE_REQUIRED: ${{ inputs.required }} | ||
| run: "${{ github.action_path }}/check.sh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| root=${GITHUB_WORKSPACE:-.} | ||
| required=${BOJ_CARTRIDGE_REQUIRED:-false} | ||
| found= | ||
|
|
||
| for candidate in cartridge.json cartridge.yml cartridge.yaml; do | ||
| if [[ -f "$root/$candidate" ]]; then | ||
| found=$candidate | ||
| break | ||
| fi | ||
| done | ||
| if [[ -z "$found" && -d "$root/.cartridges" ]]; then | ||
| found=.cartridges/ | ||
| fi | ||
|
|
||
| if [[ -z "$found" ]]; then | ||
| if [[ "$required" == "true" ]]; then | ||
| echo '::error::A BoJ cartridge is required but no canonical cartridge path exists.' | ||
| exit 1 | ||
| fi | ||
| echo '::notice::BoJ cartridge is not applicable to this repository.' | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "BoJ cartridge present at $found." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) | ||
| fixture=$(mktemp -d) | ||
| trap 'rm -rf -- "$fixture"' EXIT | ||
|
|
||
| GITHUB_WORKSPACE=$fixture BOJ_CARTRIDGE_REQUIRED=false "$here/check.sh" | ||
|
|
||
| if GITHUB_WORKSPACE=$fixture BOJ_CARTRIDGE_REQUIRED=true "$here/check.sh"; then | ||
| echo 'required-but-absent BoJ cartridge unexpectedly passed' >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| printf '%s\n' '{"name":"controlled-fixture"}' > "$fixture/cartridge.json" | ||
| GITHUB_WORKSPACE=$fixture BOJ_CARTRIDGE_REQUIRED=true "$here/check.sh" | ||
|
|
||
| echo 'boj-cartridge-check controls passed' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| name: 'Code Hygiene Check' | ||
| description: 'Fails on untracked debt markers in source, and on undeclared proof circumventions in proof code.' | ||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Run Hygiene Check | ||
| shell: bash | ||
| run: bash "$GITHUB_ACTION_PATH/check.sh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| # Distinguish untracked implementation debt from prose, templates, generated | ||
| # metadata, and issue-linked work. Proof circumventions remain a separate, | ||
| # stricter check over proof languages only. | ||
| set -uo pipefail | ||
| fail=0 | ||
|
|
||
| readonly allow_file='.cicd-hygiene-allow' | ||
| allow_args=() | ||
| if [[ -f "$allow_file" ]]; then | ||
| echo "Using allowlist $allow_file:" | ||
| while IFS= read -r pat || [[ -n "$pat" ]]; do | ||
| case "$pat" in | ||
| ''|'#'*) continue ;; | ||
| *) | ||
| echo " exclude: $pat" | ||
| allow_args+=(":(exclude)$pat") | ||
| ;; | ||
| esac | ||
| done < "$allow_file" | ||
| fi | ||
|
|
||
| # The horizon is deliberately explicit. These are implementation-language | ||
| # files, wherever they occur in the tree. Documentation, workflows, | ||
| # machine-readable templates, packaging recipes, and container templates are | ||
| # not silently relabelled as application source. | ||
| exclude_paths=( | ||
| ':(exclude).github/**' ':(exclude).githooks/**' | ||
| ':(exclude).machine_readable/**' ':(exclude)docs/**' | ||
| ':(exclude)packaging/**' ':(exclude)container/**' | ||
| ":(exclude)$allow_file" | ||
| ) | ||
|
|
||
| source_paths=( | ||
| '*.adb' '*.ads' '*.affine' '*.agda' '*.bash' '*.c' '*.cc' '*.clj' '*.cljs' | ||
| '*.cjs' '*.cpp' '*.cr' '*.cts' '*.cxx' '*.eph' '*.erl' '*.ex' '*.exs' | ||
| '*.fish' '*.fs' | ||
| '*.fsx' '*.gleam' '*.go' '*.h' '*.hh' '*.hpp' '*.hs' '*.idr' '*.java' | ||
| '*.js' '*.jsx' '*.kt' '*.kts' '*.lean' '*.lhs' '*.lua' '*.m' '*.mjs' | ||
| '*.ml' '*.mli' '*.mm' '*.mts' '*.nu' | ||
| '*.php' '*.pl' '*.pm' '*.py' '*.r' '*.rb' '*.res' '*.resi' '*.roc' '*.rs' | ||
| '*.scala' '*.sh' '*.sol' '*.sql' '*.swift' '*.thy' '*.ts' '*.tsx' '*.v' | ||
| '*.vala' '*.vapi' '*.zig' | ||
| "${exclude_paths[@]}" | ||
| ) | ||
|
|
||
| echo 'Scanning implementation source for untracked debt markers...' | ||
| debt="$({ git grep --untracked -n -E -w 'TODO|FIXME|XXX|HACK|STUB' -- \ | ||
| "${source_paths[@]}" "${allow_args[@]+"${allow_args[@]}"}" || true; } \ | ||
| | perl -ne 'print if /:[0-9]+:.*\b(?:TODO|FIXME|XXX|HACK|STUB)\b(?!\(#[0-9]+\))/')" | ||
| if [[ -n "$debt" ]]; then | ||
| echo '::error::Untracked debt markers found in implementation source:' >&2 | ||
| printf '%s\n' "$debt" | ||
| echo '::error::Resolve the debt or link it as MARKER(#issue).' >&2 | ||
| fail=1 | ||
| else | ||
| echo ' none.' | ||
| fi | ||
|
|
||
| echo 'Scanning proof code for undeclared circumventions...' | ||
| circ="$({ git grep --untracked -n -E -w 'sorry|believe_me|admit|postulate|assert_total' -- \ | ||
| '*.idr' '*.lean' '*.v' '*.agda' '*.thy' \ | ||
| "${exclude_paths[@]}" \ | ||
| "${allow_args[@]+"${allow_args[@]}"}" || true; } \ | ||
| | grep -vE ':[0-9]+:[[:space:]]*(\|\|\||--|//|\(\*)' || true)" | ||
| if [[ -n "$circ" ]]; then | ||
| echo '::error::Undeclared proof circumventions found:' >&2 | ||
| printf '%s\n' "$circ" | ||
| echo "::error::If sanctioned, isolate the axioms, list the module in $allow_file," >&2 | ||
| echo '::error::and enforce the exact count with a trusted-base check.' >&2 | ||
| fail=1 | ||
| else | ||
| echo ' none.' | ||
| fi | ||
|
|
||
| if [[ "$fail" -eq 1 ]]; then | ||
| echo '::error::Code hygiene gate failed.' >&2 | ||
| exit 1 | ||
| fi | ||
| echo 'Hygiene check passed.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| set -euo pipefail | ||
|
|
||
| checker="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/check.sh" | ||
| readonly checker | ||
| fixture="$(mktemp -d)" | ||
| trap 'rm -rf "$fixture"' EXIT | ||
| git -C "$fixture" init -q | ||
| git -C "$fixture" config user.email test@example.invalid | ||
| git -C "$fixture" config user.name 'Hygiene test' | ||
| mkdir -p "$fixture/src" "$fixture/docs" "$fixture/.github/workflows" \ | ||
| "$fixture/.machine_readable/templates" | ||
|
|
||
| printf '%s\n' '// clean source' > "$fixture/src/main.rs" | ||
| printf '%s\n' 'TODO in documentation is explanatory.' > "$fixture/docs/design.md" | ||
| printf '%s\n' 'example = believe_me value' > "$fixture/docs/example.idr" | ||
| printf '%s\n' '// marker in the filename is not debt' > "$fixture/src/TODO.rs" | ||
| printf '%s\n' '# TODO: workflow follow-up' > "$fixture/.github/workflows/ci.yml" | ||
| printf '%s\n' 'TODO: fill this template' > "$fixture/.machine_readable/templates/example.ncl" | ||
| git -C "$fixture" add . | ||
| git -C "$fixture" commit -qm fixture | ||
|
|
||
| (cd "$fixture" && bash "$checker") | ||
|
|
||
| printf '%s\n' '// TODO: TypeScript implementation debt' > "$fixture/src/app.ts" | ||
| if (cd "$fixture" && bash "$checker"); then | ||
| echo 'FAIL: untracked TypeScript debt was accepted' >&2 | ||
| exit 1 | ||
| fi | ||
| printf '%s\n' '// clean TypeScript source' > "$fixture/src/app.ts" | ||
|
|
||
| printf '%s\n' '// TODO: untracked implementation debt' > "$fixture/src/main.rs" | ||
| if (cd "$fixture" && bash "$checker"); then | ||
| echo 'FAIL: untracked source debt was accepted' >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| printf '%s\n' '// TODO(#123): tracked implementation debt' > "$fixture/src/main.rs" | ||
| (cd "$fixture" && bash "$checker") | ||
|
|
||
| printf '%s\n' 'proof = believe_me value' > "$fixture/src/Safety.idr" | ||
| if (cd "$fixture" && bash "$checker"); then | ||
| echo 'FAIL: proof circumvention was accepted' >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| printf '%s' 'src/Safety.idr' > "$fixture/.cicd-hygiene-allow" | ||
| (cd "$fixture" && bash "$checker") | ||
| echo 'All code-hygiene positive and negative controls passed.' |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.