mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
110 lines
2.8 KiB
YAML
110 lines
2.8 KiB
YAML
name: Security Scan
|
|
|
|
# Scans code and dependencies for security vulnerabilities
|
|
# Runs on: push, pull requests, or manual trigger
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
schedule:
|
|
- cron: '0 0 * * 1' # Weekly on Monday
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
security-events: write
|
|
|
|
jobs:
|
|
dependency-scan:
|
|
name: Dependency Security Scan
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install security tools
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install safety pip-audit
|
|
continue-on-error: true
|
|
|
|
- name: Install project dependencies
|
|
run: |
|
|
pip install -e ".[dev]"
|
|
continue-on-error: true
|
|
|
|
- name: Run pip-audit
|
|
run: |
|
|
echo "Running pip-audit security scan..."
|
|
pip-audit --format json --output pip-audit-report.json 2>&1 || true
|
|
pip-audit 2>&1 || true
|
|
echo "pip-audit scan completed"
|
|
continue-on-error: true
|
|
|
|
- name: Run safety check
|
|
run: |
|
|
echo "Running safety security check..."
|
|
safety check --json --output safety-report.json 2>&1 || true
|
|
safety check 2>&1 || true
|
|
echo "Safety check completed"
|
|
continue-on-error: true
|
|
|
|
- name: Upload security reports
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: security-reports
|
|
path: |
|
|
pip-audit-report.json
|
|
safety-report.json
|
|
retention-days: 30
|
|
if-no-files-found: ignore
|
|
|
|
code-scan:
|
|
name: Code Security Scan
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Run Trivy vulnerability scanner
|
|
uses: aquasecurity/trivy-action@master
|
|
with:
|
|
scan-type: 'fs'
|
|
scan-ref: '.'
|
|
format: 'sarif'
|
|
output: 'trivy-results.sarif'
|
|
severity: 'CRITICAL,HIGH'
|
|
continue-on-error: true
|
|
|
|
- name: Upload Trivy results to GitHub Security
|
|
if: always() && hashFiles('trivy-results.sarif') != ''
|
|
uses: github/codeql-action/upload-sarif@v2
|
|
with:
|
|
sarif_file: 'trivy-results.sarif'
|
|
continue-on-error: true
|
|
|
|
secret-scan:
|
|
name: Secret Scanning
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Run Gitleaks
|
|
uses: gitleaks/gitleaks-action@v2
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
continue-on-error: true
|
|
|