-
Notifications
You must be signed in to change notification settings - Fork 0
283 lines (241 loc) · 8.87 KB
/
Copy pathsecurity.yml
File metadata and controls
283 lines (241 loc) · 8.87 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
name: Security & MSRV
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
# Run security audit daily at 2 AM UTC
- cron: '0 2 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'schedule' && github.run_id || github.ref }}
cancel-in-progress: ${{ github.event_name != 'schedule' }}
env:
CARGO_TERM_COLOR: always
jobs:
msrv-check:
name: Minimum Supported Rust Version
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install MSRV Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.92.0 # Flight Hub MSRV
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: msrv-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Linux HID build deps
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
- name: Check MSRV compilation
run: |
echo "🦀 Testing compilation with Rust 1.92.0 (MSRV)"
cargo check --workspace --all-targets
echo "✅ MSRV check passed"
security-audit:
name: Security Audit
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-audit
run: cargo +stable install --locked cargo-audit
- name: Install cargo-deny
run: cargo +stable install --locked cargo-deny
- name: Run security audit
run: |
echo "🔒 Running security audit"
if [ "${{ github.event_name }}" = "pull_request" ]; then
cargo audit --deny warnings || echo "::warning::Security audit reported issues (report-only on pull_request)."
else
cargo audit --deny warnings
fi
echo "✅ Security audit passed"
- name: Run cargo-deny
run: |
echo "🚫 Running cargo-deny checks"
if [ "${{ github.event_name }}" = "pull_request" ]; then
cargo deny check --hide-inclusion-graph || echo "::warning::cargo-deny reported issues (report-only on pull_request)."
else
cargo deny check --hide-inclusion-graph
fi
echo "✅ Cargo-deny checks passed"
license-check:
name: License Compliance
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deny
run: cargo +stable install --locked cargo-deny
- name: Check licenses
run: |
echo "📄 Checking license compliance"
if [ "${{ github.event_name }}" = "pull_request" ]; then
cargo deny check licenses || echo "::warning::License check reported issues (report-only on pull_request)."
else
cargo deny check licenses
fi
echo "✅ License check passed"
- name: Generate license report
run: |
echo "📋 Generating license report"
cargo deny list --format json > licenses.json
echo "## 📄 License Report" >> $GITHUB_STEP_SUMMARY
echo "| Crate | License | Version |" >> $GITHUB_STEP_SUMMARY
echo "|-------|---------|---------|" >> $GITHUB_STEP_SUMMARY
# Parse JSON and create markdown table (simplified)
echo "License report generated in licenses.json"
supply-chain:
name: Supply Chain Security
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install nightly for scripts (no default switch)
run: rustup toolchain install nightly --profile minimal --no-self-update
- name: Install audit tools
run: |
echo "🛠️ Installing supply chain audit tools"
cargo +stable install --locked cargo-audit cargo-deny cargo-license
echo "✅ Audit tools installed"
- name: Run comprehensive supply chain audit
run: |
echo "🔍 Running comprehensive supply chain audit"
if [ "${{ github.event_name }}" = "pull_request" ]; then
cargo +nightly -Zscript scripts/supply_chain_audit.rs || echo "::warning::Supply-chain audit script reported issues (report-only on pull_request)."
else
cargo +nightly -Zscript scripts/supply_chain_audit.rs
fi
echo "✅ Supply chain audit completed"
- name: Upload audit artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: supply-chain-audit-${{ github.sha }}
path: |
SUPPLY_CHAIN_AUDIT.md
THIRD_PARTY_LICENSES.md
spdx/
retention-days: 30
- name: Check for banned crates
run: |
echo "🔍 Checking for banned/vulnerable crates"
if [ "${{ github.event_name }}" = "pull_request" ]; then
cargo deny check bans || echo "::warning::Banned crate check reported issues (report-only on pull_request)."
else
cargo deny check bans
fi
echo "✅ Supply chain check passed"
- name: Check for duplicate dependencies
run: |
echo "🔍 Checking for duplicate dependencies"
cargo tree --duplicates
echo "ℹ️ Duplicate dependency check completed"
- name: Validate SPDX documents
run: |
echo "📋 Validating SPDX documents"
if [ -d "spdx" ]; then
for spdx_file in spdx/*.spdx; do
if [ -f "$spdx_file" ]; then
echo " Validating $(basename "$spdx_file")"
# Basic SPDX validation - check required fields
if grep -q "SPDXVersion:" "$spdx_file" && \
grep -q "DataLicense:" "$spdx_file" && \
grep -q "PackageName:" "$spdx_file"; then
echo " ✅ $(basename "$spdx_file") is valid"
else
echo " ❌ $(basename "$spdx_file") is invalid"
exit 1
fi
fi
done
fi
echo "✅ SPDX validation completed"
semver-check:
name: Semantic Versioning
runs-on: ubuntu-latest
timeout-minutes: 20
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for semver check
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-semver-checks
run: cargo +stable install --locked cargo-semver-checks
- name: Check semantic versioning
run: |
echo "📦 Checking semantic versioning compliance"
# Check each public crate for breaking changes
for crate in flight-core flight-scheduler flight-virtual; do
echo "Checking $crate..."
cargo semver-checks check-release --package $crate || echo "⚠️ Breaking changes detected in $crate"
done
echo "✅ Semver check completed"
dependency-review:
name: Dependency Review
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.event_name == 'pull_request'
steps:
- name: Dependency Review
id: dependency_review
continue-on-error: true
uses: actions/dependency-review-action@v4
with:
fail-on-severity: moderate
allow-licenses: MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC
- name: Note unavailable dependency review
if: steps.dependency_review.outcome != 'success'
run: echo "::warning::Dependency review is unavailable for this repository configuration."
supply-chain-gate:
name: Supply Chain Security Gate
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [security-audit, license-check, supply-chain]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install nightly for scripts (no default switch)
run: rustup toolchain install nightly --profile minimal --no-self-update
- name: Install audit tools
run: |
cargo +stable install --locked cargo-audit cargo-deny cargo-license
- name: Run CI Supply Chain Security Gate
run: |
echo "🚪 Running CI Supply Chain Security Gate"
if [ "${{ github.event_name }}" = "pull_request" ]; then
cargo +nightly -Zscript scripts/ci_supply_chain_gate.rs || echo "::warning::Supply-chain security gate reported issues (report-only on pull_request)."
else
cargo +nightly -Zscript scripts/ci_supply_chain_gate.rs
fi
echo "✅ All supply chain security gates passed"
- name: Upload gate results
uses: actions/upload-artifact@v4
if: always()
with:
name: supply-chain-gate-results-${{ github.sha }}
path: |
SUPPLY_CHAIN_AUDIT.md
THIRD_PARTY_LICENSES.md
spdx/
retention-days: 90