Skip to content

Commit a183e41

Browse files
wip
1 parent 79e6688 commit a183e41

File tree

1 file changed

+64
-15
lines changed

1 file changed

+64
-15
lines changed

.github/workflows/ci.yml

Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,34 @@ jobs:
3939
uses: davelosert/vitest-coverage-report-action@v2
4040

4141
semgrep_scan:
42-
name: Semgrep Security Scan
42+
name: semgrep/ci
4343
runs-on: ubuntu-latest
44+
container:
45+
image: returntocorp/semgrep
46+
# Skip any PR created by dependabot to avoid permission issues:
47+
if: (github.actor != 'dependabot[bot]')
48+
permissions:
49+
security-events: write
50+
actions: read
51+
contents: read
4452
steps:
4553
- name: Checkout repository
4654
uses: actions/checkout@v4
4755

48-
- name: Setup Python
49-
uses: actions/setup-python@v5
50-
with:
51-
python-version: '3.x'
52-
53-
- name: Install Semgrep CLI
54-
run: |
55-
python -m pip install --upgrade pip
56-
pip install --upgrade semgrep
56+
- name: Perform Semgrep Analysis (fails on findings)
57+
run: semgrep scan -q --error --config auto --sarif -o semgrep-results.sarif .
5758

58-
- name: Run Semgrep and generate SARIF
59-
run: |
60-
semgrep --config p/security-audit --error --timeout 5m --sarif -o semgrep.sarif || true
59+
- name: Save SARIF results as artifact
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: semgrep-scan-results
63+
path: semgrep-results.sarif
6164

62-
- name: Upload Semgrep SARIF to Code Scanning
65+
- name: Upload SARIF result to the GitHub Security Dashboard
66+
if: always() && hashFiles('semgrep-results.sarif') != ''
6367
uses: github/codeql-action/upload-sarif@v3
6468
with:
65-
sarif_file: semgrep.sarif
69+
sarif_file: semgrep-results.sarif
6670

6771
gitleaks_scan:
6872
name: Gitleaks Secret Scan
@@ -96,3 +100,48 @@ jobs:
96100

97101
- name: Audit dependencies (high severity and above)
98102
run: npx --yes audit-ci --package-manager yarn --severity high
103+
104+
codeql_sast:
105+
name: CodeQL SAST
106+
runs-on: ubuntu-latest
107+
steps:
108+
- name: Checkout repository
109+
uses: actions/checkout@v4
110+
111+
- name: Initialize CodeQL
112+
uses: github/codeql-action/init@v3
113+
with:
114+
languages: javascript-typescript
115+
queries: security-extended,security-and-quality
116+
117+
- name: Autobuild
118+
uses: github/codeql-action/autobuild@v3
119+
120+
- name: Perform CodeQL Analysis (generate SARIF)
121+
uses: github/codeql-action/analyze@v3
122+
with:
123+
output: codeql-results
124+
upload: true
125+
wait-for-results: true
126+
127+
- name: Upload CodeQL SARIF as artifact
128+
if: always()
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: codeql-scan-results
132+
path: codeql-results/*.sarif
133+
134+
- name: Fail if CodeQL alerts found
135+
run: |
136+
set -euo pipefail
137+
files=(codeql-results/*.sarif)
138+
if [ ${#files[@]} -eq 0 ]; then
139+
echo "No SARIF files found in codeql-results; skipping fail check."
140+
exit 0
141+
fi
142+
total=$(jq '[.runs[].results | length] | add // 0' ${files[@]})
143+
echo "CodeQL alerts: $total"
144+
if [ "$total" -gt 0 ]; then
145+
echo "Failing due to CodeQL alerts."
146+
exit 1
147+
fi

0 commit comments

Comments
 (0)