Skip to content

Commit cc83143

Browse files
authored
Merge pull request DefectDojo#1017 from jaguasch/bundle-audit
Bundle-audit tool output importer
2 parents 6e18f3a + f8fc85f commit cc83143

File tree

6 files changed

+86
-3
lines changed

6 files changed

+86
-3
lines changed

dojo/fixtures/test_type.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,21 @@
270270
},
271271
"model": "dojo.test_type",
272272
"pk": 39
273-
},
273+
},
274274
{
275275
"fields": {
276276
"name": "Anchore Engine Scan"
277277
},
278278
"model": "dojo.test_type",
279279
"pk": 40
280-
},
280+
},
281+
{
282+
"fields": {
283+
"name": "Bundler-Audit Scan"
284+
},
285+
"model": "dojo.test_type",
286+
"pk": 41
287+
},
281288
{
282289
"fields": {
283290
"name": "Netsparker Scanner"

dojo/forms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ class ImportScanForm(forms.Form):
282282
("PHP Security Audit v2", "PHP Security Audit v2"),
283283
("Safety Scan", "Safety Scan"),
284284
("DawnScanner Scan", "DawnScanner Scan"),
285-
("Anchore Engine Scan", "Anchore Engine Scan"))
285+
("Anchore Engine Scan", "Anchore Engine Scan"),
286+
("Bundler-Audit Scan", "Bundler-Audit Scan"))
286287

287288
SORTED_SCAN_TYPE_CHOICES = sorted(SCAN_TYPE_CHOICES, key=lambda x: x[1])
288289

dojo/templates/dojo/import_scan_results.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ <h3> Add Tests</h3>
3232
<li><b>Arachni Scanner</b> - Arachni JSON report format.</li>
3333
<li><b>AppSpider (Rapid7)</b> - Use the VulnerabilitiesSummary.xml file found in the zipped report download.</li>
3434
<li><b>Bandit</b> - JSON report format</li>
35+
<li><b>Bundler-Audit Scan</b> - 'bundler-audit check' output (in plain text)</li>
3536
<li><b>Burp XML</b> - When the Burp report is generated, the recommended option is Base64 encoding both the request and
3637
response fields. These fields will be processed and made available in the 'Finding View' page.</li>
3738
<li><b>Brakeman Scan</b> - Import Brakeman Scanner findings in JSON format.</li>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__author__ = 'jaguasch'

dojo/tools/bundler_audit/parser.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
__author__ = 'jaguasch'
2+
3+
import hashlib
4+
from datetime import datetime
5+
from dojo.models import Finding
6+
7+
8+
class BundlerAuditParser(object):
9+
def __init__(self, filename, test):
10+
lines = filename.read()
11+
dupes = dict()
12+
find_date = datetime.now()
13+
warnings = lines.split('\n\n')
14+
15+
for warning in warnings:
16+
if not warning.startswith('Name'):
17+
continue
18+
19+
gem_report_fields = warning.split('\n')
20+
for field in gem_report_fields:
21+
if field.startswith('Name'):
22+
gem_name = field.replace('Name: ', '')
23+
elif field.startswith('Version'):
24+
gem_version = field.replace('Version: ', '')
25+
elif field.startswith('Advisory'):
26+
advisory_cve = field.replace('Advisory: ', '')
27+
elif field.startswith('Criticality'):
28+
criticality = field.replace('Criticality: ', '')
29+
if criticality.lower() == 'unknown':
30+
sev = "Medium"
31+
else:
32+
sev = criticality
33+
elif field.startswith('URL'):
34+
advisory_url = field.replace('URL: ', '')
35+
elif field.startswith('Title'):
36+
advisory_title = field.replace('Title: ', '')
37+
elif field.startswith('Solution'):
38+
advisory_solution = field.replace('Solution: ', '')
39+
40+
title = "Gem " + gem_name + ": " + advisory_title + " [" + advisory_cve + "]"
41+
findingdetail = "Gem **" + gem_name + "** has known security issues:\n"
42+
findingdetail += '**Name**: ' + gem_name + '\n'
43+
findingdetail += '**Version**: ' + gem_version + '\n'
44+
findingdetail += '**Advisory**: ' + advisory_cve + '\n'
45+
mitigation = advisory_solution
46+
references = advisory_url
47+
fingerprint = "bundler-audit" + gem_name + gem_version + advisory_cve + sev
48+
dupe_key = hashlib.md5(fingerprint).hexdigest()
49+
if dupe_key in dupes:
50+
find = dupes[dupe_key]
51+
else:
52+
dupes[dupe_key] = True
53+
54+
find = Finding(
55+
title=title,
56+
test=test,
57+
active=False,
58+
verified=False,
59+
description=findingdetail,
60+
severity=sev,
61+
numerical_severity=Finding.get_numerical_severity(sev),
62+
mitigation=mitigation,
63+
references=references,
64+
url='N/A',
65+
date=find_date,
66+
static_finding=True)
67+
68+
dupes[dupe_key] = find
69+
70+
self.items = dupes.values()

dojo/tools/factory.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from dojo.tools.clair_klar.parser import ClairKlarParser
4242
from dojo.tools.dawnscanner.parser import DawnScannerParser
4343
from dojo.tools.anchore_engine.parser import AnchoreEngineScanParser
44+
from dojo.tools.bundler_audit.parser import BundlerAuditParser
4445

4546
__author__ = 'Jay Paz'
4647

@@ -138,6 +139,8 @@ def import_parser_factory(file, test, scan_type=None):
138139
parser = DawnScannerParser(file, test)
139140
elif scan_type == 'Anchore Engine Scan':
140141
parser = AnchoreEngineScanParser(file, test)
142+
elif scan_type == 'Bundler-Audit Scan':
143+
parser = BundlerAuditParser(file, test)
141144
else:
142145
raise ValueError('Unknown Test Type')
143146

0 commit comments

Comments
 (0)