Skip to content

Security

Security #471

Workflow file for this run

name: Security
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
# Run security checks daily at 2 AM UTC
- cron: '0 2 * * *'
jobs:
security-audit:
runs-on: ubuntu-latest
name: Security Audit
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install safety bandit semgrep
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run Safety check (known vulnerabilities)
run: |
safety check --json --output safety-report.json || true
safety check || echo "Security vulnerabilities found"
- name: Run Bandit (security linter)
run: |
bandit -r . -f json -o bandit-report.json || true
bandit -r . || echo "Security issues found"
- name: Run Semgrep (static analysis)
run: |
semgrep --config=auto --json --output=semgrep-report.json . || true
semgrep --config=auto . || echo "Static analysis issues found"
- name: Upload security reports
uses: actions/upload-artifact@v4
if: always()
with:
name: security-reports
path: |
safety-report.json
bandit-report.json
semgrep-report.json
dependency-review:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Dependency Review
uses: actions/dependency-review-action@v4
with:
fail-on-severity: moderate
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 repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3