-
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (108 loc) · 3.77 KB
/
codeql.yml
File metadata and controls
126 lines (108 loc) · 3.77 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
# CodeQL Security Scanning Workflow for WRAITH Protocol
# Analyzes code for security vulnerabilities and code quality issues
# Documentation: https://docs.github.com/en/code-security/code-scanning
name: "CodeQL Security Scan"
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
schedule:
# Run weekly on Monday at 09:00 UTC
- cron: '0 9 * * 1'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
analyze:
name: CodeQL Analysis
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
# Required for CodeQL to upload results to GitHub Security tab
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
# CodeQL has experimental Rust support; we'll use it for basic analysis
# Note: Rust support in CodeQL is limited compared to other languages
language: ['rust']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-codeql-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-codeql-
${{ runner.os }}-cargo-
# Initialize CodeQL tools for scanning
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# Use security-extended query suite for comprehensive security analysis
queries: security-extended
# Optional: Add custom queries
# config-file: ./.github/codeql/codeql-config.yml
# Build the project (required for compiled languages like Rust)
# CodeQL needs the build to understand the code structure
- name: Build project
run: |
cargo build --workspace --all-features --release
# Perform CodeQL Analysis
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{ matrix.language }}"
# Fail the workflow if high or critical severity issues are found
# Commented out by default to avoid breaking builds initially
# fail-on: critical,high
# Additional Rust-specific security scanning with cargo-audit
rust-security:
name: Rust Security Audit
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-audit-${{ hashFiles('**/Cargo.lock') }}
# Install cargo-audit for RustSec advisory database scanning
- name: Install cargo-audit
run: cargo install cargo-audit --locked
# Check for security vulnerabilities in dependencies
- name: Run cargo audit
run: cargo audit --deny warnings
# Check for outdated dependencies with known security issues
- name: Run cargo outdated
continue-on-error: true
run: |
cargo install cargo-outdated --locked
cargo outdated --root-deps-only --format json > outdated-deps.json || true
# Upload results as artifacts for review
- name: Upload audit results
if: always()
uses: actions/upload-artifact@v5
with:
name: security-audit-results
path: |
outdated-deps.json
retention-days: 30