Skip to content

Commit aa09641

Browse files
Update msdo-trufflehog.yml
Fix json error where it wasn't handling json imports and decoding errors
1 parent 1823166 commit aa09641

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

.github/workflows/msdo-trufflehog.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
git clone https://github.com/${{ github.repository }} .
2525
git checkout ${{ github.ref_name }}
2626
27-
- name: Install TruffleHog and SARIF tools
27+
- name: Install TruffleHog
2828
run: |
2929
pip install trufflehog
3030
@@ -37,8 +37,12 @@ jobs:
3737
run: |
3838
echo "import json" > convert_to_sarif.py
3939
echo "" >> convert_to_sarif.py
40-
echo "with open('trufflehog-findings.json') as f:" >> convert_to_sarif.py
41-
echo " findings = json.load(f)" >> convert_to_sarif.py
40+
echo "try:" >> convert_to_sarif.py
41+
echo " with open('trufflehog-findings.json') as f:" >> convert_to_sarif.py
42+
echo " findings = json.load(f)" >> convert_to_sarif.py
43+
echo "except Exception as e:" >> convert_to_sarif.py
44+
echo " print('Failed to parse findings:', e)" >> convert_to_sarif.py
45+
echo " findings = []" >> convert_to_sarif.py
4246
echo "" >> convert_to_sarif.py
4347
echo "sarif = {" >> convert_to_sarif.py
4448
echo " 'version': '2.1.0'," >> convert_to_sarif.py
@@ -94,7 +98,3 @@ jobs:
9498
-H "Content-Type: application/json" \
9599
https://api.github.com/repos/${{ github.repository }}/code-scanning/sarifs \
96100
-d "{\"commit_sha\": \"${{ github.sha }}\",\"ref\": \"${{ github.ref }}\",\"sarif\": \"$encoded_sarif\",\"checkout_uri\": \"https://github.com/${{ github.repository }}\",\"tool_name\": \"TruffleHog\"}"
97-
98-
-H "Content-Type: application/json" \
99-
https://api.github.com/repos/${{ github.repository }}/code-scanning/sarifs \
100-
-d "{\n \"commit_sha\": \"${{ github.sha }}\",\n \"ref\": \"${{ github.ref }}\",\n \"sarif\": \"$encoded_sarif\",\n \"checkout_uri\": \"https://github.com/${{ github.repository }}\",\n \"tool_name\": \"TruffleHog\"\n }"

0 commit comments

Comments
 (0)