-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (96 loc) · 3.37 KB
/
Copy pathsecurity.yml
File metadata and controls
119 lines (96 loc) · 3.37 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Security & Quality
on:
push:
branches: ["**"]
pull_request:
branches: [main]
permissions:
contents: read
security-events: write # needed to upload SARIF results to GitHub Security tab
actions: read
jobs:
# ── SAST: ESLint with security-focused rules ──────────────────────────────
sast-eslint:
name: SAST – ESLint (security + code smells)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run ESLint (human-readable)
run: npm run lint
- name: Run ESLint (SARIF for GitHub Code Scanning)
run: npm run lint:sarif
- name: Upload ESLint SARIF to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always() && hashFiles('**/eslint-results.sarif') != ''
with:
sarif_file: eslint-results.sarif
category: eslint-sast
# ── SAST: CodeQL ──────────────────────────────────────────────────────────
sast-codeql:
name: SAST – CodeQL
runs-on: ubuntu-latest
permissions:
security-events: write
actions: read
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: javascript
# Use the default security-extended query suite
queries: security-extended
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: codeql-js
# ── DAST: OWASP ZAP Baseline scan ────────────────────────────────────────
dast-zap:
name: DAST – OWASP ZAP Baseline
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
issues: write # ZAP action may create/update an issue with findings
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Start static test server
run: |
node tests/e2e/server.js &
echo "SERVER_PID=$!" >> "$GITHUB_ENV"
# Wait until server is ready
for i in $(seq 1 10); do
curl -sf http://localhost:3456/options.html > /dev/null && break
sleep 1
done
- name: ZAP Baseline Scan
uses: zaproxy/action-baseline@v0.14.0
with:
target: "http://localhost:3456"
rules_file_name: ".zap/rules.tsv"
fail_action: false # report only, never fail the build
allow_issue_writing: false # don't create GitHub issues from findings
artifact_name: zap-baseline-report
- name: Stop test server
if: always()
run: kill "$SERVER_PID" 2>/dev/null || true