Skip to content

Commit 6767ad0

Browse files
committed
upload semgrep results to GitHub Security tab
1 parent d475786 commit 6767ad0

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

.github/workflows/devsecops-pipeline.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ jobs:
8080
sast-semgrep:
8181
name: SAST - Semgrep
8282
runs-on: ubuntu-latest
83+
permissions:
84+
contents: read
85+
security-events: write
8386

8487
steps:
8588
- name: Checkout code
@@ -88,17 +91,37 @@ jobs:
8891
- name: Install Semgrep
8992
run: pip3 install semgrep
9093

91-
- name: Run Semgrep scan
94+
- name: Run Semgrep scan - JSON output
95+
continue-on-error: true
96+
run: |
97+
semgrep --config "p/security-audit" --config "p/nodejs" --config "p/owasp-top-ten" --config "p/javascript" --json --output semgrep-results.json . || echo "Semgrep JSON scan completed"
98+
99+
- name: Run Semgrep scan - SARIF output
100+
continue-on-error: true
101+
run: |
102+
semgrep --config "p/security-audit" --config "p/nodejs" --config "p/owasp-top-ten" --config "p/javascript" --sarif --output semgrep-results.sarif . || echo "Semgrep SARIF scan completed"
103+
104+
- name: Run Semgrep scan - Text output
92105
continue-on-error: true
93106
run: |
94-
semgrep --config "p/security-audit" --config "p/nodejs" --config "p/owasp-top-ten" --config "p/javascript" --json --output semgrep-results.json . || echo "Semgrep scan completed"
107+
semgrep --config "p/security-audit" --config "p/nodejs" --config "p/owasp-top-ten" --config "p/javascript" --text . > semgrep-results.txt 2>&1 || echo "Semgrep text scan completed"
108+
109+
- name: Upload Semgrep results to GitHub Security
110+
uses: github/codeql-action/upload-sarif@v3
111+
if: always()
112+
with:
113+
sarif_file: 'semgrep-results.sarif'
114+
category: 'semgrep'
95115

96116
- name: Upload Semgrep results
97117
if: always()
98118
uses: actions/upload-artifact@v4
99119
with:
100120
name: semgrep-results
101-
path: semgrep-results.json
121+
path: |
122+
semgrep-results.json
123+
semgrep-results.sarif
124+
semgrep-results.txt
102125
103126
# Stage 6: Dependency Scanning
104127
dependency-scan:

0 commit comments

Comments
 (0)