Skip to content

Commit f0f52ba

Browse files
Update msdo-trufflehog.yml
1 parent 1fd8ef8 commit f0f52ba

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

.github/workflows/msdo-trufflehog.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ jobs:
3434
if: github.repository_visibility == 'public' && success()
3535
run: |
3636
pip install sarif-tools
37-
python3 -c """
38-
import json
37+
cat <<EOF > convert_to_sarif.py
38+
import json
3939

4040
with open('trufflehog-findings.json') as f:
4141
findings = json.load(f)
4242

43-
sarif = {
44-
'version': '2.1.0',
43+
sarif = {
44+
'version': '2.1.0',
4545
'runs': [{
4646
'tool': {
4747
'driver': {
@@ -79,25 +79,23 @@ for finding in findings:
7979

8080
with open('trufflehog.sarif', 'w') as out:
8181
json.dump(sarif, out)
82-
"""
82+
EOF
83+
python3 convert_to_sarif.py
8384

8485
- name: Upload TruffleHog SARIF to GitHub Code Scanning
8586
if: github.repository_visibility == 'public' && success()
8687
run: |
8788
gzip -c trufflehog.sarif | base64 -w 0 > trufflehog.sarif.base64
8889
encoded_sarif=$(cat trufflehog.sarif.base64)
8990
90-
curl -s -X POST \
91+
echo '{
92+
"commit_sha": "'"${{ github.sha }}"'",
93+
"ref": "'"${{ github.ref }}"'",
94+
"sarif": "'$encoded_sarif'",
95+
"checkout_uri": "https://github.com/${{ github.repository }}",
96+
"tool_name": "TruffleHog"
97+
}' | curl -s -X POST \
9198
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
9299
-H "Accept: application/vnd.github+json" \
93100
-H "Content-Type: application/json" \
94-
https://api.github.com/repos/${{ github.repository }}/code-scanning/sarifs \
95-
-d @- <<EOF
96-
{
97-
"commit_sha": "${{ github.sha }}",
98-
"ref": "${{ github.ref }}",
99-
"sarif": "$encoded_sarif",
100-
"checkout_uri": "https://github.com/${{ github.repository }}",
101-
"tool_name": "TruffleHog"
102-
}
103-
EOF
101+
https://api.github.com/repos/${{ github.repository }}/code-scanning/sarifs

0 commit comments

Comments
 (0)