Skip to content

Commit ed929da

Browse files
committed
DevSecOps test
1 parent 76b9098 commit ed929da

2 files changed

Lines changed: 39 additions & 14 deletions

File tree

.github/workflows/devsecops-pipeline.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,41 @@ jobs:
3535

3636
- name: Semgrep scan
3737
uses: semgrep/semgrep-action@v1
38+
continue-on-error: true
3839
with:
3940
config: >-
4041
p/javascript
41-
p/angular
42-
p/nodejsscan
42+
p/typescript
43+
p/react
44+
r/typescript.angular.security.audit.angular-allow-trusted-dynamic-script.angular-allow-trusted-dynamic-script
4345
./xss/semgrep.yaml
4446
./semgrep-custom-rules.yaml
4547
output: semgrep-results.sarif
48+
49+
- name: Create empty SARIF file if it doesn't exist
50+
run: |
51+
if [ ! -f "semgrep-results.sarif" ]; then
52+
echo '{
53+
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
54+
"version": "2.1.0",
55+
"runs": [
56+
{
57+
"tool": {
58+
"driver": {
59+
"name": "Semgrep",
60+
"version": "placeholder",
61+
"rules": []
62+
}
63+
},
64+
"results": []
65+
}
66+
]
67+
}' > semgrep-results.sarif
68+
echo "Created empty SARIF file as semgrep scan failed"
69+
fi
4670
4771
- name: Upload SARIF file
48-
uses: github/codeql-action/upload-sarif@v2
72+
uses: github/codeql-action/upload-sarif@v3
4973
if: always()
5074
with:
5175
sarif_file: semgrep-results.sarif
@@ -81,7 +105,7 @@ jobs:
81105
--scan-config ./dependency-check-config.json
82106
83107
- name: Upload SARIF files
84-
uses: github/codeql-action/upload-sarif@v2
108+
uses: github/codeql-action/upload-sarif@v3
85109
if: always()
86110
with:
87111
sarif_file: './reports/'

semgrep-custom-rules.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@ rules:
2727

2828
# Node.js API Vulnerabilities
2929
- id: express-no-helmet
30-
pattern: |
31-
import $EXPRESS from 'express';
32-
...
33-
const $APP = $EXPRESS();
34-
...
35-
pattern-not: |
36-
import $H from 'helmet';
37-
...
38-
$APP.use($H());
39-
...
30+
patterns:
31+
- pattern: |
32+
import $EXPRESS from 'express';
33+
...
34+
const $APP = $EXPRESS();
35+
...
36+
- pattern-not: |
37+
import $H from 'helmet';
38+
...
39+
$APP.use($H());
40+
...
4041
message: >
4142
Express application detected without Helmet middleware. Helmet helps secure
4243
Express apps by setting various HTTP headers. Consider adding

0 commit comments

Comments
 (0)