-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (121 loc) · 5.1 KB
/
Copy pathsecurity-review.yml
File metadata and controls
141 lines (121 loc) · 5.1 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Security Review for Dependencies
on:
pull_request:
types: [opened, synchronize]
paths:
- 'client-ts/package.json'
- 'client-ts/package-lock.json'
- 'TaskManagerApp.csproj'
- '.github/workflows/*.yml'
jobs:
security-review:
name: Security Review
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'security-review-required')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: client-ts/package-lock.json
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Install frontend dependencies
working-directory: ./client-ts
run: npm ci
- name: Run npm audit (frontend)
working-directory: ./client-ts
run: |
echo "🔍 Running npm audit for security vulnerabilities..."
npm audit --audit-level moderate --json > audit-results.json || true
- name: Check for high/critical vulnerabilities
working-directory: ./client-ts
run: |
echo "🚨 Checking for high/critical vulnerabilities..."
if npm audit --audit-level high; then
echo "✅ No high/critical vulnerabilities found"
else
echo "❌ HIGH/CRITICAL vulnerabilities detected!"
echo "::warning::High or critical security vulnerabilities found in npm packages"
exit 1
fi
- name: Run dotnet list package vulnerabilities (backend)
run: |
echo "🔍 Checking .NET package vulnerabilities..."
dotnet list package --vulnerable --include-transitive || true
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'table'
exit-code: '1'
ignore-unfixed: true
- name: Check package integrity (npm)
working-directory: ./client-ts
run: |
echo "🔐 Verifying package integrity..."
npm ci --audit --fund=false
- name: Verify package signatures
run: |
echo "🔍 Checking for suspicious package changes..."
# Check if any packages were added/removed
if [ -f "client-ts/package.json" ]; then
echo "📦 Frontend packages detected"
fi
if [ -f "TaskManagerApp.csproj" ]; then
echo "📦 Backend packages detected"
fi
- name: Security summary
run: |
echo "## 🔒 Security Review Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ✅ Security Checks Completed:" >> $GITHUB_STEP_SUMMARY
echo "- npm audit scan" >> $GITHUB_STEP_SUMMARY
echo "- .NET vulnerability check" >> $GITHUB_STEP_SUMMARY
echo "- Trivy filesystem scan" >> $GITHUB_STEP_SUMMARY
echo "- Package integrity verification" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ⚠️ Manual Review Required:" >> $GITHUB_STEP_SUMMARY
echo "- Review all package changes manually" >> $GITHUB_STEP_SUMMARY
echo "- Verify package sources and maintainers" >> $GITHUB_STEP_SUMMARY
echo "- Test functionality after merge" >> $GITHUB_STEP_SUMMARY
- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('🔒 Security Review')
);
if (!botComment) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## 🔒 Security Review Required
This PR contains dependency updates that require manual security review.
### ⚠️ Please verify:
- [ ] Package sources are trusted
- [ ] No suspicious package additions
- [ ] Version changes are reasonable
- [ ] No breaking changes introduced
- [ ] Test the application after merge
### 🔍 Automated checks completed:
- npm audit scan
- .NET vulnerability check
- Trivy security scan
- Package integrity verification
**Do not merge until manual review is complete.**`
});
}