Skip to content

Commit 4396428

Browse files
Jonathan D.A. Jewellclaude
andcommitted
security: fix OpenSSF Scorecard workflow issues
- Add SPDX headers (PMPL-1.0) to all workflows - Add permissions: read-all at workflow level - SHA-pin all GitHub Actions (no version tags) - Remove duplicate rust.yml (rust-ci.yml is comprehensive) - Update SLSA generator to v2.0.0 - Update codecov-action to v4 Fixes ERR-SEC-001 (unpinned actions), ERR-SEC-002 (missing permissions), ERR-LIC-001 (missing SPDX headers). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7eeff98 commit 4396428

14 files changed

Lines changed: 123 additions & 190 deletions

.github/workflows/codeql.yml

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
6-
#
7-
# ******** NOTE ********
8-
# We have attempted to detect the languages in your repository. Please check
9-
# the `language` matrix defined below to confirm you have the correct set of
10-
# supported CodeQL languages.
11-
#
1+
# SPDX-License-Identifier: PMPL-1.0
2+
# SPDX-FileCopyrightText: 2025 Jonathan D.A. Jewell
123
name: "CodeQL Advanced"
134

145
on:
@@ -19,23 +10,15 @@ on:
1910
schedule:
2011
- cron: '17 23 * * 3'
2112

13+
permissions: read-all
14+
2215
jobs:
2316
analyze:
2417
name: Analyze (${{ matrix.language }})
25-
# Runner size impacts CodeQL analysis time. To learn more, please see:
26-
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27-
# - https://gh.io/supported-runners-and-hardware-resources
28-
# - https://gh.io/using-larger-runners (GitHub.com only)
29-
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
3018
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
3119
permissions:
32-
# required for all workflows
3320
security-events: write
34-
35-
# required to fetch internal or private CodeQL packs
3621
packages: read
37-
38-
# only required for workflows in private repositories
3922
actions: read
4023
contents: read
4124

@@ -47,55 +30,25 @@ jobs:
4730
build-mode: none
4831
- language: rust
4932
build-mode: none
50-
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
51-
# Use `c-cpp` to analyze code written in C, C++ or both
52-
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
53-
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
54-
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
55-
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
56-
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
57-
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
33+
5834
steps:
5935
- name: Checkout repository
60-
uses: actions/checkout@v4
61-
62-
# Add any setup steps before running the `github/codeql-action/init` action.
63-
# This includes steps like installing compilers or runtimes (`actions/setup-node`
64-
# or others). This is typically only required for manual builds.
65-
# - name: Setup runtime (example)
66-
# uses: actions/setup-example@v1
36+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
6737

68-
# Initializes the CodeQL tools for scanning.
6938
- name: Initialize CodeQL
70-
uses: github/codeql-action/init@v4
39+
uses: github/codeql-action/init@a4784f2dad6682d68cce8299ef20b1ca931bbdfb # v4
7140
with:
7241
languages: ${{ matrix.language }}
7342
build-mode: ${{ matrix.build-mode }}
74-
# If you wish to specify custom queries, you can do so here or in a config file.
75-
# By default, queries listed here will override any specified in a config file.
76-
# Prefix the list here with "+" to use these queries and those in the config file.
77-
78-
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
79-
# queries: security-extended,security-and-quality
8043

81-
# If the analyze step fails for one of the languages you are analyzing with
82-
# "We were unable to automatically build your code", modify the matrix above
83-
# to set the build mode to "manual" for that language. Then modify this step
84-
# to build your code.
85-
# ℹ️ Command-line programs to run using the OS shell.
86-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
8744
- name: Run manual build steps
8845
if: matrix.build-mode == 'manual'
8946
shell: bash
9047
run: |
91-
echo 'If you are using a "manual" build mode for one or more of the' \
92-
'languages you are analyzing, replace this with the commands to build' \
93-
'your code, for example:'
94-
echo ' make bootstrap'
95-
echo ' make release'
48+
echo 'Manual build not configured'
9649
exit 1
9750
9851
- name: Perform CodeQL Analysis
99-
uses: github/codeql-action/analyze@v4
52+
uses: github/codeql-action/analyze@a4784f2dad6682d68cce8299ef20b1ca931bbdfb # v4
10053
with:
10154
category: "/language:${{matrix.language}}"
Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,45 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
6-
# This workflow lets you generate SLSA provenance file for your project.
7-
# The generation satisfies level 3 for the provenance requirements - see https://slsa.dev/spec/v0.1/requirements
8-
# The project is an initiative of the OpenSSF (openssf.org) and is developed at
9-
# https://github.com/slsa-framework/slsa-github-generator.
10-
# The provenance file can be verified using https://github.com/slsa-framework/slsa-verifier.
11-
# For more information about SLSA and how it improves the supply-chain, visit slsa.dev.
1+
# SPDX-License-Identifier: PMPL-1.0
2+
# SPDX-FileCopyrightText: 2025 Jonathan D.A. Jewell
3+
#
4+
# SLSA Level 3 Provenance Generator
5+
# See https://slsa.dev/spec/v0.1/requirements
126

137
name: SLSA generic generator
148
on:
159
workflow_dispatch:
1610
release:
1711
types: [created]
1812

13+
permissions: read-all
14+
1915
jobs:
2016
build:
2117
runs-on: ubuntu-latest
2218
outputs:
2319
digests: ${{ steps.hash.outputs.digests }}
2420

2521
steps:
26-
- uses: actions/checkout@v4
22+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
2723

28-
# ========================================================
29-
#
30-
# Step 1: Build your artifacts.
31-
#
32-
# ========================================================
3324
- name: Build artifacts
3425
run: |
35-
# These are some amazing artifacts.
3626
echo "artifact1" > artifact1
3727
echo "artifact2" > artifact2
3828
39-
# ========================================================
40-
#
41-
# Step 2: Add a step to generate the provenance subjects
42-
# as shown below. Update the sha256 sum arguments
43-
# to include all binaries that you generate
44-
# provenance for.
45-
#
46-
# ========================================================
4729
- name: Generate subject for provenance
4830
id: hash
4931
run: |
5032
set -euo pipefail
51-
52-
# List the artifacts the provenance will refer to.
5333
files=$(ls artifact*)
54-
# Generate the subjects (base64 encoded).
5534
echo "hashes=$(sha256sum $files | base64 -w0)" >> "${GITHUB_OUTPUT}"
5635
5736
provenance:
5837
needs: [build]
5938
permissions:
60-
actions: read # To read the workflow path.
61-
id-token: write # To sign the provenance.
62-
contents: write # To add assets to a release.
63-
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.4.0
39+
actions: read
40+
id-token: write
41+
contents: write
42+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
6443
with:
6544
base64-subjects: "${{ needs.build.outputs.digests }}"
66-
upload-assets: true # Optional: Upload to a new release
45+
upload-assets: true
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1+
# SPDX-License-Identifier: PMPL-1.0
2+
# SPDX-FileCopyrightText: 2025 Jonathan D.A. Jewell
13
name: Guix/Nix Package Policy
24
on: [push, pull_request]
5+
6+
permissions: read-all
7+
38
jobs:
49
check:
510
runs-on: ubuntu-latest
611
steps:
7-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
813
- name: Enforce Guix primary / Nix fallback
914
run: |
1015
# Check for package manager files
1116
HAS_GUIX=$(find . -name "*.scm" -o -name ".guix-channel" -o -name "guix.scm" 2>/dev/null | head -1)
1217
HAS_NIX=$(find . -name "*.nix" 2>/dev/null | head -1)
13-
18+
1419
# Block new package-lock.json, yarn.lock, Gemfile.lock, etc.
1520
NEW_LOCKS=$(git diff --name-only --diff-filter=A HEAD~1 2>/dev/null | grep -E 'package-lock\.json|yarn\.lock|Gemfile\.lock|Pipfile\.lock|poetry\.lock|cargo\.lock' || true)
1621
if [ -n "$NEW_LOCKS" ]; then
1722
echo "⚠️ Lock files detected. Prefer Guix manifests for reproducibility."
1823
fi
19-
24+
2025
# Prefer Guix, fallback to Nix
2126
if [ -n "$HAS_GUIX" ]; then
2227
echo "✅ Guix package management detected (primary)"
@@ -25,5 +30,5 @@ jobs:
2530
else
2631
echo "ℹ️ Consider adding guix.scm or flake.nix for reproducible builds"
2732
fi
28-
33+
2934
echo "✅ Package policy check passed"
Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,37 @@
1-
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
1+
# SPDX-License-Identifier: PMPL-1.0
2+
# SPDX-FileCopyrightText: 2025 Jonathan D.A. Jewell
23
name: Deploy Jekyll with GitHub Pages dependencies preinstalled
34

45
on:
5-
# Runs on pushes targeting the default branch
66
push:
77
branches: ["main"]
8-
9-
# Allows you to run this workflow manually from the Actions tab
108
workflow_dispatch:
119

12-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1310
permissions:
1411
contents: read
1512
pages: write
1613
id-token: write
1714

18-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2015
concurrency:
2116
group: "pages"
2217
cancel-in-progress: false
2318

2419
jobs:
25-
# Build job
2620
build:
2721
runs-on: ubuntu-latest
2822
steps:
2923
- name: Checkout
30-
uses: actions/checkout@v4
24+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
3125
- name: Setup Pages
32-
uses: actions/configure-pages@v5
26+
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
3327
- name: Build with Jekyll
34-
uses: actions/jekyll-build-pages@v1
28+
uses: actions/jekyll-build-pages@44a6e6beabd48582f863aeeb6cb2151cc1716697 # v1
3529
with:
3630
source: ./
3731
destination: ./_site
3832
- name: Upload artifact
39-
uses: actions/upload-pages-artifact@v3
33+
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
4034

41-
# Deployment job
4235
deploy:
4336
environment:
4437
name: github-pages
@@ -48,4 +41,4 @@ jobs:
4841
steps:
4942
- name: Deploy to GitHub Pages
5043
id: deployment
51-
uses: actions/deploy-pages@v4
44+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4

.github/workflows/npm-bun-blocker.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
# SPDX-License-Identifier: PMPL-1.0
2+
# SPDX-FileCopyrightText: 2025 Jonathan D.A. Jewell
13
name: NPM/Bun Blocker
24
on: [push, pull_request]
5+
6+
permissions: read-all
7+
38
jobs:
49
check:
510
runs-on: ubuntu-latest
611
steps:
7-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
813
- name: Block npm/bun
914
run: |
1015
if [ -f "package-lock.json" ] || [ -f "bun.lockb" ] || [ -f ".npmrc" ]; then

.github/workflows/php-security.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
# SPDX-License-Identifier: PMPL-1.0
2+
# SPDX-FileCopyrightText: 2025 Jonathan D.A. Jewell
13
name: PHP Security Check
24
on: [push, pull_request]
5+
6+
permissions: read-all
7+
38
jobs:
49
security:
510
runs-on: ubuntu-latest
611
steps:
7-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
813
- name: PHP Security Scan
914
run: |
1015
# Check for dangerous functions
@@ -13,19 +18,19 @@ jobs:
1318
echo "⚠️ Potentially dangerous PHP functions found:"
1419
echo "$DANGEROUS"
1520
fi
16-
21+
1722
# Check for SQL injection patterns
1823
SQLI=$(grep -rE '\$_(GET|POST|REQUEST).*query|mysqli_query.*\$_' --include="*.php" . 2>/dev/null | grep -v 'vendor/' | head -5 || true)
1924
if [ -n "$SQLI" ]; then
2025
echo "⚠️ Potential SQL injection patterns:"
2126
echo "$SQLI"
2227
fi
23-
28+
2429
# Check for XSS patterns
2530
XSS=$(grep -rE 'echo\s+\$_(GET|POST|REQUEST)' --include="*.php" . 2>/dev/null | grep -v 'vendor/' | head -5 || true)
2631
if [ -n "$XSS" ]; then
2732
echo "⚠️ Potential XSS patterns (unescaped output):"
2833
echo "$XSS"
2934
fi
30-
35+
3136
echo "✅ PHP security scan completed"

.github/workflows/php.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# SPDX-License-Identifier: PMPL-1.0
2+
# SPDX-FileCopyrightText: 2025 Jonathan D.A. Jewell
13
name: PHP Composer
24

35
on:
@@ -6,23 +8,20 @@ on:
68
pull_request:
79
branches: [ "main" ]
810

9-
permissions:
10-
contents: read
11+
permissions: read-all
1112

1213
jobs:
1314
build:
14-
1515
runs-on: ubuntu-latest
16-
1716
steps:
18-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
1918

2019
- name: Validate composer.json and composer.lock
2120
run: composer validate --strict
2221

2322
- name: Cache Composer packages
2423
id: composer-cache
25-
uses: actions/cache@v3
24+
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
2625
with:
2726
path: vendor
2827
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
@@ -31,9 +30,3 @@ jobs:
3130
3231
- name: Install dependencies
3332
run: composer install --prefer-dist --no-progress
34-
35-
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
36-
# Docs: https://getcomposer.org/doc/articles/scripts.md
37-
38-
# - name: Run test suite
39-
# run: composer run-script test

0 commit comments

Comments
 (0)