All,
out of curiosity I ran bandit (a SAST tool for python) against sanic:master this morning and got a few gems.
First, my execution path
(sanic-T0ioAge5) [ssadowski@host |git: (master)| sanic]$bandit -s B104 -x tests/ -r ./
This effectively tells bandit to run recursively, skip check for B104 (hardcoded bind to all interfaces) and exclude the tests directory
The report, pretty good overall imho:
Code scanned:
Total lines of code: 5105
Total lines skipped (#nosec): 0
Run metrics:
Total issues (by severity):
Undefined: 0.0
Low: 7.0
Medium: 2.0
High: 0.0
Total issues (by confidence):
Undefined: 0.0
Low: 1.0
Medium: 0.0
High: 8.0
Files skipped (0):
One of the mediums I believe is ignorable:
>> Issue: [B102:exec_used] Use of exec detected.
Severity: Medium Confidence: High
Location: ./sanic/config.py:84
More Info: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
83 with open(filename) as config_file:
84 exec(
85 compile(config_file.read(), filename, "exec"),
86 module.__dict__,
87 )
The other we may want to correct:
>> Issue: [B604:any_other_function_with_shell_equals_true] Function call with shell=True parameter identified, possible security issue.
Severity: Medium Confidence: Low
Location: ./sanic/reloader_helpers.py:54
More Info: https://bandit.readthedocs.io/en/latest/plugins/b604_any_other_function_with_shell_equals_true.html
53 args=(cmd,),
54 kwargs=dict(shell=True, env=new_environ),
55 )
I’m open to thoughts, but I think it would be nice if we got a report about our basic code security with every PR/Merge