Skip to content

Commit 36437ec

Browse files
authored
Merge pull request #1118 from dr3dd589/add_kiuwan_support
Add Kiuwan Importer
2 parents 7ce115f + 228d559 commit 36437ec

File tree

9 files changed

+330
-0
lines changed

9 files changed

+330
-0
lines changed

dojo/forms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ class ImportScanForm(forms.Form):
292292
("Anchore Engine Scan", "Anchore Engine Scan"),
293293
("Bundler-Audit Scan", "Bundler-Audit Scan"),
294294
("Twistlock Image Scan", "Twistlock Image Scan"),
295+
("Kiuwan Scan", "Kiuwan Scan"),
295296
("Blackduck Hub Scan", "Blackduck Hub Scan"))
296297

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

dojo/templates/dojo/import_scan_results.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ <h3> Add Tests</h3>
7373
<li><b>Veracode Detailed XML Report</b></li>
7474
<li><b>Zed Attack Proxy</b> - ZAP XML report format.</li>
7575
<li><b>Acunetix Scanner</b> - XML format.</li>
76+
<li><b>Kiuwan Scanner</b> - Import Kiuwan Scan in CSV format. Export as CSV Results on Kiuwan.</li>
77+
7678
</ul>
7779

7880
{% if additional_message %}

dojo/tools/factory.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from dojo.tools.anchore_engine.parser import AnchoreEngineScanParser
4545
from dojo.tools.bundler_audit.parser import BundlerAuditParser
4646
from dojo.tools.twistlock.parser import TwistlockParser
47+
from dojo.tools.kiuwan.parser import KiuwanCSVParser
4748
from dojo.tools.blackduck.parser import BlackduckHubCSVParser
4849

4950
__author__ = 'Jay Paz'
@@ -148,6 +149,8 @@ def import_parser_factory(file, test, scan_type=None):
148149
parser = BundlerAuditParser(file, test)
149150
elif scan_type == 'Twistlock Image Scan':
150151
parser = TwistlockParser(file, test)
152+
elif scan_type == 'Kiuwan Scan':
153+
parser = KiuwanCSVParser(file, test)
151154
elif scan_type == 'Blackduck Hub Scan':
152155
parser = BlackduckHubCSVParser(file, test)
153156
else:

dojo/tools/kiuwan/__init__.py

Whitespace-only changes.

dojo/tools/kiuwan/parser.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import StringIO
2+
import csv
3+
import hashlib
4+
from dojo.models import Finding
5+
6+
__author__ = 'dr3dd589'
7+
8+
9+
class Severityfilter():
10+
def __init__(self):
11+
self.severity_mapping = {'Normal': 'Info',
12+
'Low': 'Low',
13+
'Medium': 'Medium',
14+
'High': 'High',
15+
'Very High': 'Critical'
16+
}
17+
self.severity = None
18+
19+
def eval_column(self, column_value):
20+
if column_value in self.severity_mapping.keys():
21+
self.severity = self.severity_mapping[column_value]
22+
else:
23+
self.severity = 'Info'
24+
25+
26+
class KiuwanCSVParser(object):
27+
def __init__(self, filename, test):
28+
self.dupes = dict()
29+
self.items = ()
30+
31+
if filename is None:
32+
self.items = ()
33+
return
34+
35+
content = filename.read()
36+
reader = csv.DictReader(StringIO.StringIO(content), delimiter=',', quotechar='"')
37+
csvarray = []
38+
39+
for row in reader:
40+
csvarray.append(row)
41+
42+
for row in csvarray:
43+
finding = Finding(test=test)
44+
findingdict = {}
45+
severityfilter = Severityfilter()
46+
severityfilter.eval_column(row['Priority'])
47+
findingdict['severity'] = severityfilter.severity
48+
findingdict['title'] = row['Rule']
49+
findingdict['description'] = "**Source file** : " + row['Source file'] + "\n\n" + \
50+
"**Vulnerability type** : " + row['Vulnerability type'] + "\n\n" + \
51+
"**Status** : " + row['Status'] + "\n\n" + \
52+
"**CWE Scope** : " + row['CWE Scope'] + "\n\n" + \
53+
"**Line text** : " + row['Line text'] + "\n\n" + \
54+
"**Normative** : " + row['Normative'] + "\n\n" + \
55+
"**Line number** : " + row['Line number'] + "\n\n" + \
56+
"**Rule code** : " + row['Rule code'] + "\n\n" + \
57+
"**File** : " + row['File'] + "\n\n" + \
58+
"**Source line text** : " + row['Source line text'] + "\n\n" + \
59+
"**Source line number** : " + row['Source line number'] + "\n"
60+
61+
finding.title = findingdict['title']
62+
finding.description = findingdict['description']
63+
finding.references = "Not provided!"
64+
finding.mitigation = "Not provided!"
65+
finding.severity = findingdict['severity']
66+
finding.cwe = row['CWE']
67+
68+
if finding is not None:
69+
if finding.title is None:
70+
finding.title = ""
71+
if finding.description is None:
72+
finding.description = ""
73+
74+
key = hashlib.md5(finding.severity + '|' + finding.title + '|' + finding.description).hexdigest()
75+
76+
if key not in self.dupes:
77+
self.dupes[key] = finding
78+
79+
self.items = self.dupes.values()

0 commit comments

Comments
 (0)