-
Notifications
You must be signed in to change notification settings - Fork 2
94 lines (79 loc) · 2.49 KB
/
Copy pathcontainer-scan-trivy.yml
File metadata and controls
94 lines (79 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: "Security Scanning"
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 2 * * 1' # Weekly on Mondays at 2 AM
permissions:
contents: read
security-events: write
jobs:
container-scan:
name: Container Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image for scanning
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: security-scan:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@v0.35.0
with:
image-ref: 'security-scan:latest'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
exit-code: 0
ignore-unfixed: true
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: 'trivy-results.sarif'
category: 'container-scan'
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@v4
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install safety bandit semgrep
- name: Run Safety (Python dependency vulnerability scanner)
run: |
uv export --no-hashes > /tmp/requirements.txt
safety check -r /tmp/requirements.txt --json --output safety-results.json || true
- name: Run Bandit (Python security linter)
working-directory: ./backend
run: |
bandit -r . -f json -o bandit-results.json || true
- name: Run Semgrep (Static analysis for security bugs)
run: |
semgrep --config=auto --json --output=semgrep-results.json . || true
- name: Upload scan artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: security-scan-results
path: |
safety-results.json
backend/bandit-results.json
semgrep-results.json