119 lines
2.7 KiB
YAML
119 lines
2.7 KiB
YAML
name: Security Scanning
|
|
|
|
on:
|
|
push:
|
|
branches: ["main", "develop"]
|
|
pull_request:
|
|
branches: ["main", "develop"]
|
|
schedule:
|
|
# Run weekly on Monday at 00:00 UTC
|
|
- cron: '0 0 * * 1'
|
|
|
|
permissions:
|
|
contents: read
|
|
security-events: write
|
|
actions: read
|
|
|
|
jobs:
|
|
dependency-scanning:
|
|
name: Dependency Vulnerability Scanning
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install pip-audit
|
|
run: pip install pip-audit
|
|
|
|
- name: Run pip-audit
|
|
run: |
|
|
pip-audit --requirement requirements.txt --format json --output pip-audit.json || true
|
|
pip-audit --requirement requirements.txt
|
|
|
|
- name: Upload pip-audit results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: pip-audit-results
|
|
path: pip-audit.json
|
|
retention-days: 30
|
|
|
|
secret-scanning:
|
|
name: Secret Scanning
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Run Gitleaks
|
|
uses: gitleaks/gitleaks-action@v2
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
codeql-analysis:
|
|
name: CodeQL Analysis
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
actions: read
|
|
contents: read
|
|
security-events: write
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
language: ['python']
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Initialize CodeQL
|
|
uses: github/codeql-action/init@v3
|
|
with:
|
|
languages: ${{ matrix.language }}
|
|
queries: security-and-quality
|
|
|
|
- name: Autobuild
|
|
uses: github/codeql-action/autobuild@v3
|
|
|
|
- name: Perform CodeQL Analysis
|
|
uses: github/codeql-action/analyze@v3
|
|
with:
|
|
category: "/language:${{ matrix.language }}"
|
|
|
|
sbom-generation:
|
|
name: SBOM Generation
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
- name: Generate SBOM with pip-licenses
|
|
run: |
|
|
pip install pip-licenses
|
|
pip-licenses --format=json --output-file=sbom.json
|
|
|
|
- name: Upload SBOM
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sbom
|
|
path: sbom.json
|
|
retention-days: 90
|