Skip to content

Commit 7a916f6

Browse files
fix(security): eliminate CI injection vectors and pin actions (#1)
- Move all github.event.* expressions from run: to env: blocks (CWE-94) - spell-check.yml: changed_files via env var - markdown-link-check.yml: changed_files via temp file input - ai-spec-drafter.yml: issue.number via env var - ai-test-generator.yml: pull_request.number via env var - ai-release-notes.yml: release.tag_name via env var - sbom.yml: release.tag_name via env var - Redact secret scanner output to prevent secret leaks to CI logs (CWE-200) - SHA-pin dtolnay/rust-toolchain (the only unpinned action) (CWE-829) - Add missing permissions: block to markdown-link-check.yml (CWE-250) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e2592fc commit 7a916f6

File tree

8 files changed

+24
-11
lines changed

8 files changed

+24
-11
lines changed

.github/workflows/ai-release-notes.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ jobs:
3232
id: prs
3333
env:
3434
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
EVENT_TAG: ${{ github.event.release.tag_name }}
36+
INPUT_TAG: ${{ inputs.tag }}
3537
run: |
36-
TAG="${{ github.event.release.tag_name || inputs.tag }}"
38+
TAG="${EVENT_TAG:-$INPUT_TAG}"
3739
if [ -z "$TAG" ]; then
3840
TAG=$(gh release list --limit 1 --json tagName -q '.[0].tagName' 2>/dev/null || echo "")
3941
fi

.github/workflows/ai-spec-drafter.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ jobs:
125125
- name: Comment on issue
126126
env:
127127
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
ISSUE_NUMBER: ${{ github.event.issue.number }}
128129
run: |
129-
gh issue comment ${{ github.event.issue.number }} \
130+
gh issue comment "$ISSUE_NUMBER" \
130131
--body "🤖 An engineering spec has been drafted and a PR created. Please review the PR for the full specification." \
131132
|| true

.github/workflows/ai-test-generator.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ jobs:
4444
id: changes
4545
env:
4646
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
PR_NUMBER: ${{ github.event.pull_request.number }}
4748
run: |
48-
FILES=$(gh pr diff ${{ github.event.pull_request.number }} --name-only \
49+
FILES=$(gh pr diff "$PR_NUMBER" --name-only \
4950
| grep -E '^packages/[^/]+/src/.*\.py$' || true)
5051
if [ -z "$FILES" ]; then
5152
echo "skip=true" >> "$GITHUB_OUTPUT"

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ jobs:
403403
runs-on: ubuntu-latest
404404
steps:
405405
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
406-
- uses: dtolnay/rust-toolchain@stable
406+
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
407407
- name: Build
408408
working-directory: packages/agent-mesh/sdks/rust/agentmesh
409409
run: cargo build --release

.github/workflows/markdown-link-check.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- '**/*.md'
77
workflow_dispatch:
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
link-check:
1114
runs-on: ubuntu-latest
@@ -20,12 +23,15 @@ jobs:
2023
files: |
2124
**/*.md
2225
26+
- name: Write changed files list
27+
if: steps.changed-files.outputs.any_changed == 'true'
28+
env:
29+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
30+
run: printf '%s\n' $CHANGED_FILES > "$RUNNER_TEMP/changed-md-files.txt"
31+
2332
- name: Run Link Checker
2433
if: steps.changed-files.outputs.any_changed == 'true'
2534
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0
2635
with:
27-
# Configuration is defined here directly in YAML (no JSON file needed)
28-
# --exclude-loopback: ignores localhost/127.0.0.1
29-
# --verbose: shows details in the logs
30-
args: --verbose --no-progress --exclude-loopback ${{ steps.changed-files.outputs.all_changed_files }}
36+
args: --verbose --no-progress --exclude-loopback --input "${{ runner.temp }}/changed-md-files.txt"
3137
fail: true

.github/workflows/sbom.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ jobs:
4949
if: github.event_name == 'release'
5050
env:
5151
GH_TOKEN: ${{ github.token }}
52+
RELEASE_TAG: ${{ github.event.release.tag_name }}
5253
run: |
53-
gh release upload "${{ github.event.release.tag_name }}" \
54+
gh release upload "$RELEASE_TAG" \
5455
sbom.spdx.json \
5556
sbom.cdx.json \
5657
--clobber

.github/workflows/secret-scanning.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
2>/dev/null || true)
5656
if [ -n "$MATCHES" ]; then
5757
echo "::warning::Potential secrets found matching pattern: $pattern"
58-
echo "$MATCHES" | head -5
58+
echo "$MATCHES" | head -5 | sed 's/:.*/:***REDACTED***/'
5959
FOUND=1
6060
fi
6161
done

.github/workflows/spell-check.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ jobs:
3333

3434
- name: Check spelling
3535
if: steps.changed-markdown.outputs.any_changed == 'true'
36-
run: cspell --config .cspell.json --no-progress ${{ steps.changed-markdown.outputs.all_changed_files }}
36+
env:
37+
CHANGED_FILES: ${{ steps.changed-markdown.outputs.all_changed_files }}
38+
run: cspell --config .cspell.json --no-progress $CHANGED_FILES

0 commit comments

Comments
 (0)