Skip to content

Commit 40188fd

Browse files
CI: add CodeQL workflow and harden Actions workflows
- Add codeql.yml scanning actions + python on push/PR/weekly - spec_update.yml: migrate ::set-output to $GITHUB_OUTPUT; pass interpolated values via env: to avoid shell injection - pypiupload.yml: add least-privilege top-level permissions
1 parent 75ec373 commit 40188fd

3 files changed

Lines changed: 54 additions & 8 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
schedule:
11+
- cron: 0 0 * * 1
12+
13+
permissions: # least privilege
14+
contents: read
15+
16+
jobs:
17+
analyze:
18+
name: Analyze (${{ matrix.language }})
19+
runs-on: ubuntu-latest
20+
permissions:
21+
security-events: write # required to upload CodeQL results
22+
contents: read
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
language: ["actions", "python"]
27+
28+
steps:
29+
- uses: actions/checkout@v7
30+
31+
- name: Initialize CodeQL
32+
uses: github/codeql-action/init@v3
33+
with:
34+
languages: ${{ matrix.language }}
35+
36+
- name: Perform CodeQL Analysis
37+
uses: github/codeql-action/analyze@v3
38+
with:
39+
category: "/language:${{ matrix.language }}"

.github/workflows/pypiupload.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
types: [created]
99
workflow_dispatch: # Allow manual trigger for testing
1010

11+
permissions: # least privilege; the deploy job overrides this for OIDC
12+
contents: read
13+
1114
jobs:
1215
deploy:
1316
runs-on: ubuntu-latest

.github/workflows/spec_update.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,29 @@ jobs:
2828
git submodule update --remote --recursive
2929
- name: Generate Branch Name
3030
id: git-branch
31+
env:
32+
FORMATTED_TIME: ${{ steps.current-time.outputs.formattedTime }}
3133
run: |
32-
echo "::set-output name=branch::spec_update_${{ steps.current-time.outputs.formattedTime }}"
34+
echo "branch=spec_update_${FORMATTED_TIME}" >> "$GITHUB_OUTPUT"
3335
- name: Generate Num Diffs
3436
id: git-diff-num
3537
run: |
3638
diffs=$(git diff --submodule spec | grep ">" | wc -l)
3739
echo "Number of Spec diffs: $diffs"
38-
echo "::set-output name=num-diff::$diffs"
40+
echo "num-diff=$diffs" >> "$GITHUB_OUTPUT"
3941
- name: Generate Diff
4042
id: git-diff
43+
env:
44+
NUM_DIFF: ${{ steps.git-diff-num.outputs.num-diff }}
4145
run: |
4246
cd spec
43-
gitdiff=$(git log -n ${{ steps.git-diff-num.outputs.num-diff }} --pretty="format:%n %H %n%n %b")
47+
gitdiff=$(git log -n "$NUM_DIFF" --pretty="format:%n %H %n%n %b")
4448
commit="Automated Spec Update $gitdiff"
45-
commit="${commit//'%'/'%25'}"
46-
commit="${commit//$'\n'/'%0A'}"
47-
commit="${commit//$'\r'/'%0D'}"
48-
echo "Commit Message: $commit"
49-
echo "::set-output name=commit::$commit"
49+
{
50+
echo "commit<<SPEC_UPDATE_EOF"
51+
echo "$commit"
52+
echo "SPEC_UPDATE_EOF"
53+
} >> "$GITHUB_OUTPUT"
5054
cd ..
5155
- name: Generate New Routes
5256
run: |

0 commit comments

Comments
 (0)