@@ -1339,27 +1339,6 @@ jobs:
13391339 path : trivy-results.sarif
13401340
13411341
1342- - name : Run Trivy vulnerability scanner against ${{ matrix.requirements }} (json Report)
1343- if : github.event_name != 'schedule'
1344- uses : aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
1345- with :
1346- scan-type : ' fs'
1347- ignore-unfixed : false
1348- format : ' json'
1349- output : ' scan-results.json'
1350- severity : ' LOW,MEDIUM,HIGH,CRITICAL'
1351- scan-ref : ${{ matrix.requirements }}
1352- exit-code : 0
1353-
1354-
1355- - name : Upload scan results ${{ matrix.requirements }}(json Report)
1356- if : github.event_name != 'schedule'
1357- uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
1358- with :
1359- name : python-scan-results-${{ matrix.requirements }}-json
1360- path : scan-results.json
1361-
1362-
13631342
13641343 vulnerability-report :
13651344 name : Create Reports
@@ -1375,127 +1354,61 @@ jobs:
13751354 steps :
13761355
13771356
1378- - name : Fetch scan results ${{ matrix.requirements }}(json Report)
1357+ - name : Fetch scan results ${{ matrix.requirements }}(sarif Report)
13791358 uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1
13801359 with :
1381- name : python-scan-results-${{ matrix.requirements }}-json
1382-
1383-
1384- - name : Create Vulnerabilities (Critical/High)
1385- run : |
1386- echo "[Debug] jq -r '.Results'=$(jq -r '.Results' scan-results.json)";
1387-
1388- if [ "$(jq -r '.Results' scan-results.json)" != 'null' ] && [ "0$(jq -r '.Results' scan-results.json)" != '0' ]; then
1389-
1390- if [ "$(jq -r '.Results[] | .Vulnerabilities' scan-results.json)" != 'null' ] && [ "0$(jq -r '.Results[] | .Vulnerabilities' scan-results.json)" != '0' ]; then
1391-
1392- not_empty="$(jq -r '.Results[] | .Vulnerabilities[]' scan-results.json)";
1393-
1394- else
1395-
1396- not_empty="";
1397-
1398- fi
1399-
1400- else
1401-
1402- not_empty="";
1403-
1404- fi
1360+ name : python-scan-results-${{ matrix.requirements }}-sarif
14051361
1406- echo "[Debug] not_empty=${not_empty}";
1407-
1408- jq -r '
1409- [
1410- "# Python Scan Results (${{ matrix.requirements }})",
1411- "",
1412- "**Scan Date:** _" + ( .CreatedAt // "" ) + "_",
1413- "**File:** _" + ( .ArtifactName // "" ) + "_",
1414- ""
1415- ] | join("\n")
1416- ' scan-results.json > vulnerability-report.md
1417-
1418- if [ "$not_empty" ]; then
1419- jq -r '
1420- def hr(severity):
1421- if severity == "HIGH" or severity == "CRITICAL" then true else false end;
1422- def to_md:
1423- "| " + (.VulnerabilityID // "") + " | " + (.PkgName // "") + " | " + (.InstalledVersion // "") + " | " + (.Severity // "") + " | " + (.Title // "") + " |";
1424- [
1425- "## High and Critical Vulnerabilities - ${{ matrix.requirements }}",
1426- "",
1427- "| Vulnerability ID | Package | Version | Severity | Description |",
1428- "| --------- | ----- | ----- | ----- | -------|",
1429- (.Results[] | .Vulnerabilities[] | select(hr(.Severity)) | to_md),
1430- ""
1431- ] | join("\n")
1432- ' scan-results.json >> vulnerability-report.md
14331362
1434- else
1435-
1436- echo "**Nothing Found**" >> vulnerability-report.md
1363+ - run : |
1364+ echo "${PWD}" || echo "couldnt PWD";
14371365
1438- fi ;
1366+ echo "1" ;
14391367
1368+ ls -la;
14401369
1370+ echo "2";
14411371
1442- - name : Create Full Vulnerabilities
1443- run : |
1444- echo "[Debug] jq -r '.Results'=$(jq -r '.Results' scan-results.json)";
1372+ mkdir -p ${{ runner.temp }}/_github_home/ || echo "could not make";
14451373
1446- if [ "$(jq -r '.Results' scan-results.json)" != 'null' ] && [ "0$(jq -r '.Results' scan-results.json)" != '0' ]; then
1374+ echo "2.1";
14471375
1448- if [ "$(jq -r '.Results[] | .Vulnerabilities' scan-results.json)" != 'null' ] && [ "0$(jq -r '.Results[] | .Vulnerabilities' scan-results.json)" != '0' ]; then
1376+ ls -la ${{ runner.temp }}/_github_home/;
14491377
1450- not_empty="$(jq -r '.Results[] | .Vulnerabilities[]' scan-results.json) ";
1378+ echo "3 ";
14511379
1452- else
1380+ mv -f trivy-results.sarif ${{ runner.temp }}/_github_home/trivy-results.sarif;
14531381
1454- not_empty=" ";
1382+ echo "4 ";
14551383
1456- fi
1384+ ls -la ${{ runner.temp }}/_github_home/;
14571385
1458- else
14591386
1460- not_empty="";
14611387
1462- fi
1388+ - name : Convert Sarif -> Markdown
1389+ if : success() || failure()
1390+ id : sarif-to-markdown
1391+ uses : 11notes/action-sarif-to-markdown@bc689850bd33a1037ea1d0a609ab4ea14b3c4396 # v1.2.0
1392+ with :
1393+ sarif_file : trivy-results.sarif
14631394
14641395
1465- echo "[Debug] not_empty=${not_empty}";
1466-
1467-
1468- jq -r '
1469- [
1470- "# Full Scan Results - ${{ matrix.requirements }}",
1471- "",
1472- "**Scan Date:** _" + ( .CreatedAt // "" ) + "_",
1473- "**File:** _" + ( .ArtifactName // "" ) + "_",
1474- ""
1475- ] | join("\n")
1476- ' scan-results.json > full-vulnerability-report.md
1477-
1478- if [ "$not_empty" ]; then
1479- jq -r '
1480- def hr(severity):
1481- if severity == "HIGH" or severity == "CRITICAL" then true else true end;
1482- def to_md:
1483- "| " + (.VulnerabilityID // "") + " | " + (.PkgName // "") + " | " + (.InstalledVersion // "") + " | " + (.Severity // "") + " | " + (.Title // "") + " |";
1484- [
1485- "## Vulnerabilities",
1486- "",
1487- "| Vulnerability ID | Package | Version | Severity | Description |",
1488- "| --------- | ----- | ----- | ----- | -------|",
1489- (.Results[] | .Vulnerabilities[] | select(.Severity) | to_md),
1490- ""
1491- ] | join("\n")
1492- ' scan-results.json >> full-vulnerability-report.md
1396+ - name : Print Report
1397+ run : echo ${{ steps.sarif-to-markdown.outputs.markdown }}
14931398
1494- else
14951399
1496- echo "**Nothing Found**" >> full-vulnerability-report.md
1400+ - name : Create Report Artifact
1401+ run : |
1402+ ls -la ${{ runner.temp }}/_github_home/sarif.md;
14971403
1498- fi;
1404+ echo "## PIP File Scan of \`${{ matrix.requirements }}\`" > vulnerability-report.md;
1405+ echo "" >> vulnerability-report.md;
1406+ echo ">[!tip]" >> vulnerability-report.md;
1407+ echo ">" >> vulnerability-report.md;
1408+ echo "> _If this report shows nothing, it means there was nothing found._" >> vulnerability-report.md;
1409+ echo "" >> vulnerability-report.md;
1410+ echo -n "#" >> vulnerability-report.md;
1411+ cat ${{ runner.temp }}/_github_home/sarif.md >> vulnerability-report.md;
14991412
15001413
15011414 - name : Upload scan results
@@ -1505,20 +1418,6 @@ jobs:
15051418 path : vulnerability-report.md
15061419
15071420
1508- - name : Upload scan results
1509- uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
1510- with :
1511- name : python-vulnerability-report-full-${{ matrix.requirements }}
1512- path : full-vulnerability-report.md
1513-
1514-
1515- - uses : dtinth/markdown-report-action@v1
1516- with :
1517- name : Python Vulnerability Report - ${{ matrix.requirements }}
1518- title : Python Vulnerability Report - ${{ matrix.requirements }}
1519- body-file : full-vulnerability-report.md
1520-
1521-
15221421
15231422 pull-request-report-comment :
15241423 if : ${{ github.ref_type != 'tag' && github.event_name != 'schedule' }}
0 commit comments