@@ -26,118 +26,45 @@ jobs:
2626
2727 # CodeQL Analysis
2828 - name : Initialize CodeQL
29- uses : github/codeql-action/init@v2
29+ uses : github/codeql-action/init@v3
3030 with :
3131 languages : python, javascript, rust
3232 queries : security-extended,security-and-quality
3333
3434 - name : Perform CodeQL Analysis
35- uses : github/codeql-action/analyze@v2
35+ uses : github/codeql-action/analyze@v3
3636 with :
3737 category : " /language:python /language:javascript /language:rust"
3838
39- # Dependency Scanning
40- - name : Run Snyk to check for vulnerabilities
41- uses : snyk/actions/node@master
42- env :
43- SNYK_TOKEN : ${{ secrets.SNYK_TOKEN }}
44- with :
45- args : --severity-threshold=high
39+ # Dependency Review
40+ - name : Dependency Review
41+ uses : actions/dependency-review-action@v3
42+ if : github.event_name == 'pull_request'
4643
47- # Secret Scanning
48- - name : TruffleHog OSS
49- uses : trufflesecurity/trufflehog@main
44+ # Rust Security Audit
45+ - name : Run Rust Audit
46+ uses : actions-rs/audit-check@v1
5047 with :
51- path : ./
52- base : ${{ github.event.repository.default_branch }}
53- head : HEAD
54- extra_args : --debug --only-verified
48+ token : ${{ secrets.GITHUB_TOKEN }}
5549
56- # Container Scanning
57- - name : Run Trivy vulnerability scanner
58- uses : aquasecurity/trivy-action@master
59- with :
60- scan-type : ' fs'
61- scan-ref : ' .'
62- format : ' table'
63- exit-code : ' 1'
64- ignore-unfixed : true
65- severity : ' CRITICAL,HIGH'
50+ # NPM Audit
51+ - name : Run npm audit
52+ run : |
53+ if [ -f package.json ]; then
54+ npm audit
55+ fi
6656
67- # SAST
68- - name : SonarCloud Scan
69- uses : SonarSource/sonarcloud-github-action@master
70- env :
71- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
72- SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
57+ # Python dependency check
58+ - name : Run pip audit
59+ run : |
60+ if [ -f requirements.txt ]; then
61+ python -m pip install pip-audit
62+ pip-audit
63+ fi
7364
74- # Security Report Generation
75- - name : Generate Security Report
65+ # SARIF upload
66+ - name : Upload SARIF file
67+ uses : github/codeql-action/upload-sarif@v3
7668 if : always()
77- uses : actions/github-script@v6
78- with :
79- script : |
80- const fs = require('fs');
81-
82- const report = `## Security Scan Report
83-
84- ### 🔍 Scan Summary
85- - CodeQL Analysis: ${{ job.status }}
86- - Dependency Scan: ${{ steps.snyk.outcome }}
87- - Secret Scan: ${{ steps.trufflehog.outcome }}
88- - Container Scan: ${{ steps.trivy.outcome }}
89- - SAST Analysis: ${{ steps.sonarcloud.outcome }}
90-
91- ### 🚨 Critical Findings
92- ${fs.existsSync('trivy-results.json') ? require('./trivy-results.json').filter(f => f.Severity === 'CRITICAL').map(f => `- ${f.VulnerabilityID}: ${f.Title}`).join('\n') : 'No critical findings'}
93-
94- ### 📊 Metrics
95- - Code Coverage: ${fs.existsSync('sonar-results.json') ? require('./sonar-results.json').coverage : 'N/A'}
96- - Security Rating: ${fs.existsSync('sonar-results.json') ? require('./sonar-results.json').securityRating : 'N/A'}
97-
98- ### 🔐 Recommendations
99- 1. Review all critical and high severity findings
100- 2. Update vulnerable dependencies
101- 3. Address any identified secrets or credentials
102- `;
103-
104- // Create/update security report issue
105- const { data: issues } = await github.rest.issues.listForRepo({
106- owner: context.repo.owner,
107- repo: context.repo.repo,
108- labels: ['security-report'],
109- state: 'open'
110- });
111-
112- if (issues.length > 0) {
113- await github.rest.issues.update({
114- owner: context.repo.owner,
115- repo: context.repo.repo,
116- issue_number: issues[0].number,
117- body: report
118- });
119- } else {
120- await github.rest.issues.create({
121- owner: context.repo.owner,
122- repo: context.repo.repo,
123- title: 'Security Scan Report',
124- body: report,
125- labels: ['security-report']
126- });
127- }
128-
129- # Notify on Critical Issues
130- - name : Notify Security Team
131- if : failure()
132- uses : actions/github-script@v6
13369 with :
134- script : |
135- const message = `🚨 Critical security issues found in the latest scan!
136- Please review the security report immediately.`;
137-
138- await github.rest.issues.createComment({
139- owner: context.repo.owner,
140- repo: context.repo.repo,
141- issue_number: context.issue.number,
142- body: message
143- });
70+ sarif_file : results.sarif
0 commit comments