Skip to content

Commit 0411fe6

Browse files
committed
update
1 parent 9126206 commit 0411fe6

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/codeaudit/ci_workflowscan.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,23 @@
1414
"""
1515

1616
import sys
17+
import json
1718
from codeaudit.api_interfaces import filescan
1819
from codeaudit.dashboard_reports import SAST_REPORT_CSS
1920

21+
PYTHON_CODE_AUDIT_TEXT = '<a href="https://github.com/nocomplexity/codeaudit" target="_blank"><b>Python Code Audit</b></a>'
22+
DISCLAIMER_TEXT = (
23+
'<div class="sast-report"><p><b>Disclaimer:</b> <i>This SAST tool '
24+
+ PYTHON_CODE_AUDIT_TEXT
25+
+ " provides a powerful, automatic security analysis for Python source code. However, it's not a substitute for human review in combination with business knowledge. Undetected vulnerabilities may still exist.</i></p></div>"
26+
)
27+
FOOTER_TEXT = (
28+
'<div class="sast-report"><p>Check the <a href="https://nocomplexity.com/documents/codeaudit/intro.html" '
29+
'target="_blank">documentation</a> for help on found issues.<br></p></div>'
30+
)
31+
32+
NOSEC_WARNING = '<div class="sast-report"><p><b>INFO</b>: The --nosec flag is active. Security findings with in-line suppressions will be excluded from the report.</p></div>'
33+
2034

2135
def ci_scan(input_path, output="text", nosec=True):
2236
"""Basic SAST scan to be used in CI workflows
@@ -39,6 +53,8 @@ def ci_scan(input_path, output="text", nosec=True):
3953
print(result)
4054
elif output == "html":
4155
result, security_status = report_result_html(scanresult)
56+
if nosec:
57+
result = NOSEC_WARNING + result
4258
print(result)
4359
elif output == "json":
4460
result, security_status = report_result_json(scanresult)
@@ -72,8 +88,9 @@ def report_result_json(scanresult):
7288
raise TypeError("Expected scanresult to be a dictionary")
7389
file_security_info = scanresult.get("file_security_info")
7490
files_with_findings_count = 0
75-
76-
return file_security_info, files_with_findings_count
91+
# Add brackets and parse
92+
json_text = json.dumps(file_security_info, indent=4)
93+
return json_text, files_with_findings_count
7794

7895

7996
def report_result_txt(scanresult):
@@ -270,4 +287,5 @@ def safe_line(x):
270287
html += "</tbody></table>"
271288
html += "</details><br>"
272289
html += "</div>"
290+
html += DISCLAIMER_TEXT + FOOTER_TEXT
273291
return html, 1

0 commit comments

Comments
 (0)