Skip to content

Commit ecd3c9c

Browse files
committed
Resolve merge conflicts
2 parents 01306a4 + e6c7337 commit ecd3c9c

File tree

24 files changed

+1541
-32
lines changed

24 files changed

+1541
-32
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.20 on 2019-05-24 18:22
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('dojo', '0004_cve_field'),
12+
]
13+
14+
operations = [
15+
migrations.AlterField(
16+
model_name='engagement',
17+
name='source_code_management_uri',
18+
field=models.URLField(blank=True, help_text=b'Resource link to source code', max_length=600, null=True, verbose_name=b'Repo'),
19+
),
20+
]

dojo/endpoint/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def delete_endpoint(request, eid):
228228
messages.SUCCESS,
229229
'Endpoint and relationships removed.',
230230
extra_tags='alert-success')
231-
return HttpResponseRedirect(reverse('view_endpoint', args=(product.id,)))
231+
return HttpResponseRedirect(reverse('view_product', args=(product.id,)))
232232

233233
collector = NestedObjects(using=DEFAULT_DB_ALIAS)
234234
collector.collect([endpoint])

dojo/fixtures/test_type.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,5 +312,12 @@
312312
},
313313
"model": "dojo.test_type",
314314
"pk": 52
315+
},
316+
{
317+
"fields": {
318+
"name": "Sonatype Application Scan"
319+
},
320+
"model": "dojo.test_type",
321+
"pk": 53
315322
}
316323
]

dojo/forms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ class ImportScanForm(forms.Form):
293293
("Bundler-Audit Scan", "Bundler-Audit Scan"),
294294
("Twistlock Image Scan", "Twistlock Image Scan"),
295295
("Kiuwan Scan", "Kiuwan Scan"),
296-
("Blackduck Hub Scan", "Blackduck Hub Scan"))
296+
("Blackduck Hub Scan", "Blackduck Hub Scan"),
297+
("Sonatype Application Scan", "Sonatype Application Scan"))
297298

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

dojo/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ class Engagement(models.Model):
787787
null=True, blank=True, help_text="Tag or branch of the product the engagement tested.", verbose_name="Branch/Tag")
788788
build_server = models.ForeignKey(Tool_Configuration, verbose_name="Build Server", help_text="Build server responsible for CI/CD test", null=True, blank=True, related_name='build_server')
789789
source_code_management_server = models.ForeignKey(Tool_Configuration, null=True, blank=True, verbose_name="SCM Server", help_text="Source code server for CI/CD test", related_name='source_code_management_server')
790-
source_code_management_uri = models.CharField(max_length=600, null=True, blank=True, verbose_name="Repo", help_text="Resource link to source code")
790+
source_code_management_uri = models.URLField(max_length=600, null=True, blank=True, editable=True, verbose_name="Repo", help_text="Resource link to source code")
791791
orchestration_engine = models.ForeignKey(Tool_Configuration, verbose_name="Orchestration Engine", help_text="Orchestration service responsible for CI/CD test", null=True, blank=True, related_name='orchestration')
792792
deduplication_on_engagement = models.BooleanField(default=False)
793793

@@ -1289,6 +1289,9 @@ def save(self, dedupe_option=True, false_history=False, rules_option=True, *args
12891289
except:
12901290
async_false_history.delay(self, *args, **kwargs)
12911291
pass
1292+
# Title Casing
1293+
from titlecase import titlecase
1294+
self.title = titlecase(self.title)
12921295

12931296
from dojo.utils import calculate_grade
12941297
calculate_grade(self.test.engagement.product)

dojo/templates/dojo/import_scan_results.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ <h3> Add Tests</h3>
2626

2727
<p>DefectDojo accepts:</p>
2828
<ul>
29+
<li><b>Acunetix Scanner</b> - XML format.</li>
2930
<li><b>Anchore-Engine</b> - Anchore-CLI JSON vulnerability report format.</li>
3031
<li><b>AWS Scout2 Scanner</b> - JS file in scout2-report/inc-awsconfig/aws_config.js.</li>
3132
<li><b>AWS Prowler Scanner</b> - Prowler file can be imported as a CSV file (-M csv).</li>
@@ -46,6 +47,7 @@ <h3> Add Tests</h3>
4647
<li><b>Dependency Check</b> - OWASP Dependency Check output can be imported in Xml format.</li>
4748
<li><b>Generic Findings Import</b> - Import Generic findings in CSV format.</li>
4849
<li><b>Gosec Scanner </b> - Import Gosec Scanner findings in JSON format.</li>
50+
<li><b>Kiuwan Scanner</b> - Import Kiuwan Scan in CSV format. Export as CSV Results on Kiuwan.</li>
4951
<li><b>MobSF Scanner </b> - Export a JSON file using the API, api/v1/report_json.</li>
5052
<li><b>Nessus (Tenable)</b> - Reports can be imported as CSV or .nessus (XML) report formats.</li>
5153
<li><b>Netsparker Scanner</b> - Netsparker JSON format.</li>
@@ -64,6 +66,7 @@ <h3> Add Tests</h3>
6466
<li><b>SKF Scan</b> - Output of SKF Sprint summary export.</li>
6567
<li><b>Snyk</b> - Snyk output file (snyk test --json > snyk.json) can be imported in JSON format.</li>
6668
<!----<li><b>SonarQube</b> - SonarQube output file can be imported in HTML format.</li>-->
69+
<li><b>Sonatype Application Scan</b> - Can be imported in JSON format</li>
6770
<li><b>SpotBugs</b> - XML report of textui cli.</li>
6871
<li><b>SSL Labs</b> - JSON Output of ssllabs-scan cli.</li>
6972
<li><b>Trufflehog</b> - JSON Output of Trufflehog.</li>
@@ -72,8 +75,6 @@ <h3> Add Tests</h3>
7275
<li><b>Visual Code Grepper (VCG)</b> - VCG output can be imported in CSV or Xml formats.</li>
7376
<li><b>Veracode Detailed XML Report</b></li>
7477
<li><b>Zed Attack Proxy</b> - ZAP XML report format.</li>
75-
<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>
7778

7879
</ul>
7980

dojo/tools/anchore_engine/parser.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,21 @@ def __init__(self, filename, test):
2121
title = ''
2222
group = ''
2323
status = ''
24+
cve = ''
2425

2526
title = item['vuln'] + ' - ' + item['package'] + '(' + item['package_type'] + ')'
2627

28+
if item['vuln']:
29+
cve = item['vuln']
30+
2731
# Finding details information
28-
findingdetail += 'Image hash: ' + data['imageDigest'] + '\n'
29-
findingdetail += 'Package: ' + item['package'] + '\n'
30-
findingdetail += 'Package path: ' + item['package_path'] + '\n'
31-
findingdetail += 'Package type: ' + item['package_type'] + '\n'
32-
findingdetail += 'Feed: ' + item['feed'] + '/' + item['feed_group'] + '\n'
33-
findingdetail += 'CVE: ' + item['vuln'] + '\n'
34-
findingdetail += 'CPE: ' + item['package_cpe'] + '\n'
32+
findingdetail += 'Image hash: ' + data['imageDigest'] + '\n\n'
33+
findingdetail += 'Package: ' + item['package'] + '\n\n'
34+
findingdetail += 'Package path: ' + item['package_path'] + '\n\n'
35+
findingdetail += 'Package type: ' + item['package_type'] + '\n\n'
36+
findingdetail += 'Feed: ' + item['feed'] + '/' + item['feed_group'] + '\n\n'
37+
findingdetail += 'CVE: ' + item['vuln'] + '\n\n'
38+
findingdetail += 'CPE: ' + item['package_cpe'] + '\n\n'
3539

3640
sev = item['severity']
3741
if sev == "Negligible" or sev == "Unknown":
@@ -54,6 +58,7 @@ def __init__(self, filename, test):
5458
test=test,
5559
active=False,
5660
verified=False,
61+
cve=cve,
5762
description=findingdetail,
5863
severity=sev,
5964
numerical_severity=Finding.get_numerical_severity(sev),

dojo/tools/blackduck/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(self, filename, test):
6363

6464
finding = Finding(title=title,
6565
cwe=int(cwe),
66+
cve=cve,
6667
test=test,
6768
active=False,
6869
verified=False,

dojo/tools/factory.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from dojo.tools.twistlock.parser import TwistlockParser
4747
from dojo.tools.kiuwan.parser import KiuwanCSVParser
4848
from dojo.tools.blackduck.parser import BlackduckHubCSVParser
49+
from dojo.tools.sonatype.parser import SonatypeJSONParser
4950

5051
__author__ = 'Jay Paz'
5152

@@ -153,6 +154,8 @@ def import_parser_factory(file, test, scan_type=None):
153154
parser = KiuwanCSVParser(file, test)
154155
elif scan_type == 'Blackduck Hub Scan':
155156
parser = BlackduckHubCSVParser(file, test)
157+
elif scan_type == 'Sonatype Application Scan':
158+
parser = SonatypeJSONParser(file, test)
156159
else:
157160
raise ValueError('Unknown Test Type')
158161

dojo/tools/gosec/parser.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,38 @@ def __init__(self, filename, test):
1717
title = ''
1818
group = ''
1919
status = ''
20+
filename = item.get("file")
21+
line = item.get("line")
22+
scanner_confidence = item.get("confidence")
2023

21-
title = item["details"] + "-" + item["rule_id"]
24+
title = item["details"] + " - rule " + item["rule_id"]
2225

2326
# Finding details information
24-
findingdetail += "Filename: " + item["file"] + "\n"
25-
findingdetail += "Line number: " + str(item["line"]) + "\n"
26-
findingdetail += "Issue Confidence: " + item["confidence"] + "\n\n"
27-
findingdetail += "Code:\n"
28-
findingdetail += item["code"] + "\n"
27+
findingdetail += "Filename: {}\n\n".format(filename)
28+
findingdetail += "Line number: {}\n\n".format(str(line))
29+
findingdetail += "Issue Confidence: {}\n\n".format(scanner_confidence)
30+
findingdetail += "Code:\n\n"
31+
findingdetail += "```{}```".format(item["code"])
2932

3033
sev = item["severity"]
31-
# mitigation = item["issue_text"]
3234
mitigation = "coming soon"
33-
# references = item["test_id"]
34-
referencesxs = "coming soon"
35+
# Best attempt at ongoing documentation provided by gosec, based on rule id
36+
references = "https://securego.io/docs/rules/{}.html".format(item['rule_id']).lower()
3537

36-
dupe_key = title + item["file"] + str(item["line"])
38+
if scanner_confidence:
39+
# Assign integer value to confidence.
40+
if scanner_confidence == "HIGH":
41+
scanner_confidence = 1
42+
elif scanner_confidence == "MEDIUM":
43+
scanner_confidence = 4
44+
elif scanner_confidence == "LOW":
45+
scanner_confidence = 7
46+
47+
if '-' in line:
48+
# if this is a range, only point to the beginning.
49+
line = line.split('-', 1)[0]
50+
51+
dupe_key = title + item["file"] + str(line)
3752

3853
if dupe_key in dupes:
3954
find = dupes[dupe_key]
@@ -50,9 +65,10 @@ def __init__(self, filename, test):
5065
mitigation=mitigation,
5166
impact=impact,
5267
references=references,
53-
file_path=item["file"],
54-
# line = item["line"],
68+
file_path=filename,
69+
line=line,
5570
url='N/A',
71+
scanner_confidence=scanner_confidence,
5672
static_finding=True)
5773

5874
dupes[dupe_key] = find

0 commit comments

Comments
 (0)