name: SqC CERT C Analysis
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build SqC
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Cargo registry and build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build SqC
run: cargo build --release
- name: Upload SqC binary
uses: actions/upload-artifact@v4
with:
name: sqc-binary
path: target/release/sqc
retention-days: 1
analyze-pr:
name: Analyze PR (diff only)
if: github.event_name == 'pull_request'
needs: build
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download SqC binary
uses: actions/download-artifact@v4
with:
name: sqc-binary
- name: Make SqC executable
run: chmod +x sqc
- name: Run SqC (diff mode)
run: |
./sqc . --diff \
--min-severity Medium \
--fail-on-severity High \
--export results.sarif
- name: Upload SARIF to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: results.sarif
analyze-full:
name: Full Analysis
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
- name: Download SqC binary
uses: actions/download-artifact@v4
with:
name: sqc-binary
- name: Make SqC executable
run: chmod +x sqc
- name: Run SqC (full scan)
run: |
./sqc . -d . \
--min-severity Medium \
--fail-on-severity High \
--export results.sarif
- name: Upload SARIF to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: results.sarif