-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (84 loc) · 3.05 KB
/
codeql-analysis.yml
File metadata and controls
98 lines (84 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: CodeQL Security Analysis
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
schedule:
# Run at 02:00 UTC every Monday
- cron: '0 2 * * 1'
workflow_dispatch:
permissions:
actions: read
contents: read
security-events: write
jobs:
analyze:
name: CodeQL Analysis
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
language: ['javascript']
# CodeQL supports: 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift'
# Learn more: https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# If you want to specify custom queries, you can do so here
# queries: security-extended,security-and-quality
config-file: ./.github/codeql-config.yml
- name: Install dependencies (for better analysis)
run: |
npm ci || echo "Dependency install failed, continuing with available code"
cd webapp && npm ci || echo "Webapp dependency install failed"
continue-on-error: true
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# For JavaScript/TypeScript, autobuild will install dependencies and build if a build script exists
- name: Autobuild
uses: github/codeql-action/autobuild@v4
continue-on-error: true
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{ matrix.language }}"
upload: true
- name: Upload SARIF results
if: always()
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: ../results
continue-on-error: true
- name: Check for high severity alerts
if: always()
uses: actions/github-script@v8
with:
script: |
const { data: alerts } = await github.rest.codeScanning.listAlertsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
severity: 'high'
});
const criticalAlerts = alerts.filter(a => a.rule.severity === 'error' || a.rule.severity === 'warning');
if (criticalAlerts.length > 0) {
console.log(`⚠️ Found ${criticalAlerts.length} high/critical severity alerts`);
core.warning(`Found ${criticalAlerts.length} high/critical severity CodeQL alerts. Please review in the Security tab.`);
} else {
console.log('✅ No high/critical severity alerts found');
}
continue-on-error: true