-
Notifications
You must be signed in to change notification settings - Fork 65
155 lines (128 loc) · 4.42 KB
/
Copy pathsecurity.yml
File metadata and controls
155 lines (128 loc) · 4.42 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Security
on:
push:
branches: [ main, develop ]
pull_request:
schedule:
# Weekly full scan, Mondays at 06:00 UTC
- cron: '0 6 * * 1'
permissions:
contents: read
jobs:
# ─── CodeQL Static Analysis (SAST) ───────────────────────────────
codeql:
name: CodeQL (${{ matrix.language }})
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
include:
- language: javascript-typescript
build-mode: none
- language: rust
build-mode: none
steps:
- uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
config-file: .github/codeql/codeql-config.yml
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
continue-on-error: true
with:
category: "/language:${{ matrix.language }}"
# ─── Secret Scanning ─────────────────────────────────────────────
# Uses the open-source gitleaks binary directly (the gitleaks-action
# wrapper requires a paid license for organization-owned repos).
secret-scan:
name: Secret Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run gitleaks
continue-on-error: true
uses: docker://ghcr.io/gitleaks/gitleaks:latest
with:
args: detect --source=/github/workspace --no-git --redact --verbose --no-banner
# ─── Dependency Review (PRs only) ────────────────────────────────
# Requires the Dependency Graph feature to be enabled in repository
# settings; kept non-blocking so it does not fail PRs when disabled.
dependency-review:
name: Dependency Review
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
continue-on-error: true
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Dependency Review
continue-on-error: true
uses: actions/dependency-review-action@v4
with:
fail-on-severity: high
comment-summary-in-pr: always
# ─── npm audit (backend + frontend) ──────────────────────────────
npm-audit:
name: npm audit (${{ matrix.package }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: [ backend, frontend ]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Audit ${{ matrix.package }} (high/critical)
continue-on-error: true
run: cd ${{ matrix.package }} && npm audit --audit-level=high
# ─── cargo audit (contracts) ─────────────────────────────────────
cargo-audit:
name: cargo audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.85.0
- name: Install cargo-audit
run: cargo install cargo-audit --locked
- name: Audit contract dependencies
continue-on-error: true
run: cd contracts && cargo audit
# ─── Container / Filesystem Scan (Trivy) ─────────────────────────
trivy-scan:
name: Trivy Scan
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: Run Trivy filesystem scan
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
ignore-unfixed: true
- name: Upload Trivy results to Security tab
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'