Skip to content

Commit d6eff46

Browse files
reeshika-hclaude
andcommitted
ci: split SCA scan into read-only scan and write-enabled policy jobs
Addresses Copilot review: only the sca-policy step needs pull-requests: write, so the Snyk scan now runs in a read-only job and hands snyk.json to a dependent security-sca job. All action refs are pinned to commit SHAs. The policy job keeps the security-sca name used by the required check. Refs DX-20927 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7dad343 commit d6eff46

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

‎.github/workflows/sca-scan.yml‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,43 @@ name: Source Composition Analysis Scan
22
on:
33
pull_request:
44
types: [opened, synchronize, reopened]
5+
permissions: {}
56
jobs:
6-
security-sca:
7+
# Runs the scan with a read-only token; third-party actions never see a write token.
8+
snyk-scan:
79
runs-on: ubuntu-latest
810
permissions:
911
contents: read
10-
pull-requests: write
1112
steps:
12-
- uses: actions/checkout@master
13+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
1314
- name: Run Dotnet Restore
1415
run: |
1516
dotnet restore ./contentstack.model.generator/contentstack.model.generator.sln
1617
dotnet restore ./contentstack.model.generator.tests/contentstack.model.generator.tests.csproj
1718
- name: Run Snyk to check for vulnerabilities
18-
uses: snyk/actions/dotnet@master
19+
uses: snyk/actions/dotnet@12140f4059e244892ae643824a95459a102120dd # master
1920
env:
2021
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
2122
with:
2223
args: --fail-on=all --all-projects --json-file-output=snyk.json
23-
json: true
2424
continue-on-error: true
25-
- uses: contentstack/sca-policy@main
25+
- name: Upload Snyk results
26+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
27+
with:
28+
name: snyk-results
29+
path: snyk.json
30+
if-no-files-found: error
31+
retention-days: 1
32+
33+
# Evaluates the results and comments on the PR; only this job gets pull-requests: write.
34+
security-sca:
35+
needs: snyk-scan
36+
runs-on: ubuntu-latest
37+
permissions:
38+
pull-requests: write
39+
steps:
40+
- name: Download Snyk results
41+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
42+
with:
43+
name: snyk-results
44+
- uses: contentstack/sca-policy@673d5e9df08f06a9e3a30beb31065c750c64cb24 # main

0 commit comments

Comments
 (0)