mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
- Add explicit permissions to all workflows (format, release, ci, test, label-issues, mark-answered) - Fix format.yml to have write permissions for PR creation - Add security.yml workflow for automated vulnerability scanning - Improve security posture with minimal permissions principle
96 lines
2.4 KiB
YAML
96 lines
2.4 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
|
|
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
|
|
|
|
- name: Run pip-audit
|
|
run: |
|
|
pip-audit --requirement pyproject.toml --format json --output pip-audit-report.json || true
|
|
pip-audit --requirement pyproject.toml || echo "pip-audit completed with issues"
|
|
continue-on-error: true
|
|
|
|
- name: Run safety check
|
|
run: |
|
|
safety check --json --output safety-report.json || true
|
|
safety check || echo "Safety check completed with issues"
|
|
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
|
|
|
|
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'
|
|
|
|
- name: Upload Trivy results to GitHub Security
|
|
uses: github/codeql-action/upload-sarif@v2
|
|
if: always()
|
|
with:
|
|
sarif_file: 'trivy-results.sarif'
|
|
|
|
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
|
|
|