Skip to content

Commit 3ffa249

Browse files
committed
feat: Implement security scanning workflow, apply critical Docker image patches, and add security and deployment documentation.
1 parent 86d2ac2 commit 3ffa249

File tree

8 files changed

+950
-17
lines changed

8 files changed

+950
-17
lines changed

.dockerignore

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,77 @@
1-
local.settings.json
1+
# Azure Functions
2+
local.settings.json
3+
4+
# Git
5+
.git
6+
.gitignore
7+
.gitattributes
8+
9+
# IDE
10+
.vscode
11+
.idea
12+
*.swp
13+
*.swo
14+
*~
15+
16+
# Python
17+
__pycache__
18+
*.py[cod]
19+
*$py.class
20+
*.so
21+
.Python
22+
build/
23+
develop-eggs/
24+
dist/
25+
downloads/
26+
eggs/
27+
.eggs/
28+
lib/
29+
lib64/
30+
parts/
31+
sdist/
32+
var/
33+
wheels/
34+
*.egg-info/
35+
.installed.cfg
36+
*.egg
37+
MANIFEST
38+
39+
# Testing
40+
.pytest_cache/
41+
.coverage
42+
.coverage.*
43+
htmlcov/
44+
.tox/
45+
.nox/
46+
.hypothesis/
47+
48+
# Virtual environments
49+
.env
50+
.venv
51+
env/
52+
venv/
53+
ENV/
54+
env.bak/
55+
venv.bak/
56+
57+
# Documentation
58+
docs/_build/
59+
*.md
60+
README*
61+
62+
# OS
63+
.DS_Store
64+
Thumbs.db
65+
66+
# Logs
67+
*.log
68+
69+
# Temporary files
70+
*.tmp
71+
*.temp
72+
.cache/
73+
74+
# Docker
75+
Dockerfile*
76+
.dockerignore
77+
docker-compose*.yml
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Security Scan
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
schedule:
9+
# Run weekly on Mondays at 9 AM UTC
10+
- cron: "0 9 * * 1"
11+
workflow_dispatch:
12+
13+
jobs:
14+
security-scan:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Build Docker image
25+
uses: docker/build-push-action@v5
26+
with:
27+
context: .
28+
push: false
29+
load: true
30+
tags: wsi-slides-processor:${{ github.sha }}
31+
cache-from: type=gha
32+
cache-to: type=gha,mode=max
33+
34+
- name: Run Trivy vulnerability scanner
35+
uses: aquasecurity/trivy-action@master
36+
with:
37+
image-ref: wsi-slides-processor:${{ github.sha }}
38+
format: "sarif"
39+
output: "trivy-results.sarif"
40+
severity: "CRITICAL,HIGH"
41+
42+
- name: Upload Trivy results to GitHub Security
43+
uses: github/codeql-action/upload-sarif@v3
44+
if: always()
45+
with:
46+
sarif_file: "trivy-results.sarif"
47+
48+
- name: Run Trivy vulnerability scanner (table output)
49+
uses: aquasecurity/trivy-action@master
50+
with:
51+
image-ref: wsi-slides-processor:${{ github.sha }}
52+
format: "table"
53+
severity: "CRITICAL,HIGH"
54+
55+
- name: Check for critical vulnerabilities
56+
uses: aquasecurity/trivy-action@master
57+
with:
58+
image-ref: wsi-slides-processor:${{ github.sha }}
59+
format: "json"
60+
output: "trivy-results.json"
61+
severity: "CRITICAL"
62+
exit-code: "0" # Don't fail the build, just report
63+
64+
- name: Generate security report
65+
if: always()
66+
run: |
67+
echo "# Security Scan Report" >> $GITHUB_STEP_SUMMARY
68+
echo "" >> $GITHUB_STEP_SUMMARY
69+
echo "**Scan Date:** $(date -u)" >> $GITHUB_STEP_SUMMARY
70+
echo "**Image:** wsi-slides-processor:${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
71+
echo "" >> $GITHUB_STEP_SUMMARY
72+
73+
if [ -f trivy-results.json ]; then
74+
CRITICAL_COUNT=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity=="CRITICAL")] | length' trivy-results.json)
75+
HIGH_COUNT=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity=="HIGH")] | length' trivy-results.json)
76+
77+
echo "## Vulnerability Summary" >> $GITHUB_STEP_SUMMARY
78+
echo "" >> $GITHUB_STEP_SUMMARY
79+
echo "- 🔴 Critical: $CRITICAL_COUNT" >> $GITHUB_STEP_SUMMARY
80+
echo "- 🟠 High: $HIGH_COUNT" >> $GITHUB_STEP_SUMMARY
81+
echo "" >> $GITHUB_STEP_SUMMARY
82+
83+
if [ "$CRITICAL_COUNT" -gt 0 ]; then
84+
echo "⚠️ **Action Required:** Critical vulnerabilities detected!" >> $GITHUB_STEP_SUMMARY
85+
echo "" >> $GITHUB_STEP_SUMMARY
86+
echo "Review the detailed scan results and update dependencies." >> $GITHUB_STEP_SUMMARY
87+
else
88+
echo "✅ No critical vulnerabilities detected" >> $GITHUB_STEP_SUMMARY
89+
fi
90+
fi
91+
92+
- name: Upload scan results as artifact
93+
uses: actions/upload-artifact@v4
94+
if: always()
95+
with:
96+
name: security-scan-results
97+
path: |
98+
trivy-results.sarif
99+
trivy-results.json
100+
retention-days: 30

0 commit comments

Comments
 (0)