@@ -23,74 +23,105 @@ jobs:
2323 with :
2424 fetch-depth : 0
2525
26+ # Create docs/reports directory if it doesn't exist
27+ - name : Ensure docs/reports directory exists
28+ run : mkdir -p ./docs/reports
29+
2630 - name : TruffleHog OSS
2731 uses : trufflesecurity/trufflehog@v3.63.7
2832 with :
2933 path : ./
30- extra_args : --debug
34+ extra_args : --debug --json
35+
36+ # Generate TruffleHog report in docs/reports
37+ - name : Generate TruffleHog report
38+ run : |
39+ echo "Running TruffleHog scan manually to save report"
40+ docker run --rm -v $(pwd):/pwd trufflesecurity/trufflehog:latest github --repo file:///pwd --json > ./docs/reports/trufflehog-results.json || true
41+
42+ # Upload TruffleHog results as artifact
43+ - name : Upload TruffleHog results
44+ uses : actions/upload-artifact@v4
45+ if : always()
46+ with :
47+ name : trufflehog-results
48+ path : ./docs/reports/trufflehog-results.json
3149
3250 sast-scanning :
33- name : Static Application Security Testing
51+ name : Static Application Security Testing (CodeQL)
3452 runs-on : ubuntu-latest
3553 needs : secrets-scanning
3654 steps :
3755 - name : Checkout code
3856 uses : actions/checkout@v4
3957 with :
4058 token : ${{ github.token }}
41-
42- - name : Semgrep scan
43- uses : semgrep/semgrep-action@v1
44- continue-on-error : true
59+
60+ # Create docs/reports directory
61+ - name : Ensure docs/reports directory exists
62+ run : mkdir -p ./docs/reports
63+
64+ # Initialize CodeQL
65+ - name : Initialize CodeQL
66+ uses : github/codeql-action/init@v3
4567 with :
46- config : >-
47- p/javascript
48- p/typescript
49- p/react
50- r/typescript.angular.security.audit.angular-allow-trusted-dynamic-script.angular-allow-trusted-dynamic-script
51- ./xss/semgrep.yaml
52- ./semgrep-custom-rules.yaml
53- output : semgrep-results.sarif
68+ languages : javascript, typescript
69+ queries : security-and-quality
70+
71+ # Autobuild (attempts to automatically build any compiled languages)
72+ - name : Autobuild
73+ uses : github/codeql-action/autobuild@v3
5474
55- - name : Create empty SARIF file if it doesn't exist
75+ # Run CodeQL Analysis
76+ - name : Perform CodeQL Analysis
77+ uses : github/codeql-action/analyze@v3
78+ with :
79+ category : " /language:javascript,typescript"
80+ output : ./docs/reports/codeql-results.sarif
81+
82+ # Copy results to docs/reports directory
83+ - name : Copy SARIF results to reports directory
5684 run : |
57- if [ ! -f "semgrep-results.sarif" ]; then
85+ if [ -f "./docs/reports/codeql-results.sarif" ]; then
86+ echo "CodeQL SARIF file exists at ./docs/reports/codeql-results.sarif"
87+ ls -la ./docs/reports/codeql-results.sarif
88+ echo "First 20 lines of SARIF file:"
89+ head -n 20 ./docs/reports/codeql-results.sarif
90+ else
91+ echo "CodeQL SARIF file not found, creating placeholder"
5892 echo '{
5993 "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
6094 "version": "2.1.0",
6195 "runs": [
6296 {
6397 "tool": {
6498 "driver": {
65- "name": "Semgrep ",
99+ "name": "CodeQL ",
66100 "version": "placeholder",
67101 "rules": []
68102 }
69103 },
70104 "results": []
71105 }
72106 ]
73- }' > semgrep-results.sarif
74- echo "Created empty SARIF file as semgrep scan failed"
75- fi
76-
77- - name : Check SARIF file
78- run : |
79- echo "Checking if SARIF file exists and is valid"
80- if [ -f "semgrep-results.sarif" ]; then
81- ls -la semgrep-results.sarif
82- echo "SARIF file exists. Displaying first 20 lines:"
83- head -n 20 semgrep-results.sarif
84- else
85- echo "SARIF file does not exist!"
107+ }' > ./docs/reports/codeql-results.sarif
86108 fi
87109
88- - name : Upload SARIF file
110+ # Upload SARIF file to GitHub Security
111+ - name : Upload SARIF to GitHub
89112 uses : github/codeql-action/upload-sarif@v3
90113 if : always()
91114 with :
92- sarif_file : semgrep-results.sarif
93- category : semgrep
115+ sarif_file : ./docs/reports/codeql-results.sarif
116+ category : codeql
117+
118+ # Save SARIF as artifact
119+ - name : Upload SARIF as artifact
120+ uses : actions/upload-artifact@v4
121+ if : always()
122+ with :
123+ name : codeql-results
124+ path : ./docs/reports/codeql-results.sarif
94125
95126 sca-scanning :
96127 name : Software Composition Analysis
@@ -103,15 +134,15 @@ jobs:
103134 token : ${{ github.token }}
104135
105136 - name : Create reports directory
106- run : mkdir -p ./reports
137+ run : mkdir -p ./docs/ reports
107138
108139 - name : OWASP Dependency-Check Scan - Backend
109140 uses : dependency-check/Dependency-Check_Action@main
110141 with :
111142 project : ' Angular-XSS-Backend'
112143 path : ' ./xss/api'
113144 format : ' SARIF'
114- out : ' ./reports'
145+ out : ' ./docs/ reports'
115146 args : >-
116147 --suppression ./dependency-check-suppressions.xml
117148 --failOnCVSS 11
@@ -122,27 +153,27 @@ jobs:
122153 project : ' Angular-XSS-Frontend'
123154 path : ' ./xss/frontend'
124155 format : ' SARIF'
125- out : ' ./reports'
156+ out : ' ./docs/ reports'
126157 args : >-
127158 --suppression ./dependency-check-suppressions.xml
128159 --failOnCVSS 11
129160
130161 - name : Check SARIF files
131162 run : |
132- echo "Checking if SARIF files exist in reports directory"
133- if [ -d "./reports" ]; then
134- ls -la ./reports/
135- echo "Found files in reports directory"
136- sarifCount=$(find ./reports -name "*.sarif" | wc -l)
163+ echo "Checking if SARIF files exist in docs/ reports directory"
164+ if [ -d "./docs/ reports" ]; then
165+ ls -la ./docs/ reports/
166+ echo "Found files in docs/ reports directory"
167+ sarifCount=$(find ./docs/ reports -name "*.sarif" | wc -l)
137168
138169 if [ "$sarifCount" -gt 0 ]; then
139- find ./reports -name "*.sarif" | while read file; do
170+ find ./docs/ reports -name "*.sarif" | while read file; do
140171 echo "Found SARIF file: $file"
141172 echo "File contents (first 20 lines):"
142173 head -n 20 "$file"
143174 done
144175 else
145- echo "No SARIF files found in reports directory. Creating placeholder."
176+ echo "No SARIF files found in docs/ reports directory. Creating placeholder."
146177 echo '{
147178 "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
148179 "version": "2.1.0",
@@ -158,11 +189,11 @@ jobs:
158189 "results": []
159190 }
160191 ]
161- }' > ./reports/dependency-check-placeholder.sarif
192+ }' > ./docs/ reports/dependency-check-placeholder.sarif
162193 fi
163194 else
164195 echo "Reports directory does not exist!"
165- mkdir -p ./reports
196+ mkdir -p ./docs/ reports
166197 echo '{
167198 "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
168199 "version": "2.1.0",
@@ -178,16 +209,16 @@ jobs:
178209 "results": []
179210 }
180211 ]
181- }' > ./reports/dependency-check-placeholder.sarif
212+ }' > ./docs/ reports/dependency-check-placeholder.sarif
182213 fi
183214
184215 - name : Find SARIF files
185216 id : find-sarif
186217 run : |
187- SARIF_FILES=$(find ./reports -name "*.sarif" | tr '\n' ',' | sed 's/,$//')
218+ SARIF_FILES=$(find ./docs/ reports -name "*.sarif" | tr '\n' ',' | sed 's/,$//')
188219 if [ -z "$SARIF_FILES" ]; then
189220 echo "No SARIF files found, using placeholder"
190- SARIF_FILES="./reports/dependency-check-placeholder.sarif"
221+ SARIF_FILES="./docs/ reports/dependency-check-placeholder.sarif"
191222 fi
192223 echo "sarif_files=$SARIF_FILES" >> $GITHUB_OUTPUT
193224 echo "Found SARIF files: $SARIF_FILES"
@@ -199,6 +230,14 @@ jobs:
199230 sarif_file : ${{ steps.find-sarif.outputs.sarif_files }}
200231 category : dependency-check
201232
233+ # Copy SARIF to artifact directory for persistent storage
234+ - name : Upload SCA Results as Artifact
235+ uses : actions/upload-artifact@v4
236+ if : always()
237+ with :
238+ name : sca-results
239+ path : ./docs/reports/
240+
202241 sbom-generation :
203242 name : Software Bill of Materials
204243 runs-on : ubuntu-latest
@@ -207,17 +246,21 @@ jobs:
207246 - name : Checkout code
208247 uses : actions/checkout@v4
209248
249+ # Create docs/reports directory if it doesn't exist
250+ - name : Ensure docs/reports directory exists
251+ run : mkdir -p ./docs/reports
252+
210253 - name : Generate SBOM with CycloneDX
211254 uses : CycloneDX/gh-node-module-generatebom@master
212255 with :
213256 path : ' ./xss'
214- output : ' ./angular-xss-sbom.json'
257+ output : ' ./docs/reports/ angular-xss-sbom.json'
215258
216259 - name : Upload SBOM as artifact
217260 uses : actions/upload-artifact@v4
218261 with :
219262 name : angular-xss-sbom
220- path : ' ./angular-xss-sbom.json'
263+ path : ' ./docs/reports/ angular-xss-sbom.json'
221264
222265 dast-scanning :
223266 name : Dynamic Application Security Testing
@@ -235,6 +278,10 @@ jobs:
235278 # Wait for application to be ready
236279 sleep 60
237280
281+ # Create docs/reports directory if it doesn't exist
282+ - name : Ensure docs/reports directory exists
283+ run : mkdir -p ./docs/reports
284+
238285 - name : ZAP Baseline Scan
239286 uses : zaproxy/action-baseline@v0.11.0
240287 with :
@@ -255,14 +302,23 @@ jobs:
255302 issue_title : ' ZAP Full Scan Report'
256303 markdown_report : true
257304
305+ # Copy ZAP reports to docs/reports directory
306+ - name : Copy ZAP reports to docs/reports
307+ run : |
308+ if [ -f "baseline-report.md" ]; then
309+ cp baseline-report.md ./docs/reports/
310+ fi
311+
312+ if [ -f "full-scan-report.md" ]; then
313+ cp full-scan-report.md ./docs/reports/
314+ fi
315+
258316 - name : Upload ZAP Report
259317 uses : actions/upload-artifact@v4
260318 if : always()
261319 with :
262320 name : zap-reports
263- path : |
264- baseline-report.md
265- full-scan-report.md
321+ path : ./docs/reports/
266322
267323 - name : Stop Docker Containers
268324 if : always()
@@ -282,6 +338,20 @@ jobs:
282338 uses : actions/download-artifact@v4
283339 with :
284340 path : ./artifacts
341+
342+ # Copy artifacts to docs/reports for local usage
343+ - name : Copy artifacts to docs/reports
344+ run : |
345+ mkdir -p ./docs/reports
346+
347+ # Try to copy any existing reports from artifacts
348+ find ./artifacts -type f -name "*.sarif" -o -name "*.json" -o -name "*.md" | while read file; do
349+ cp "$file" ./docs/reports/
350+ done
351+
352+ # List all files in docs/reports for verification
353+ echo "Files in docs/reports directory:"
354+ ls -la ./docs/reports/
285355
286356 - name : Import to DefectDojo
287357 run : |
@@ -295,3 +365,4 @@ jobs:
295365 DEFECTDOJO_URL : ${{ secrets.DEFECTDOJO_URL }}
296366 DEFECTDOJO_API_KEY : ${{ secrets.DEFECTDOJO_API_KEY }}
297367 DEFECTDOJO_ENGAGEMENT_ID : ${{ secrets.DEFECTDOJO_ENGAGEMENT_ID }}
368+
0 commit comments