Skip to content

Commit 77f3456

Browse files
authored
Merge pull request #10851 from DefectDojo/bugfix
Bugfix -> Dev: Release 2.38.0
2 parents 4ff2aa2 + b63447c commit 77f3456

6 files changed

Lines changed: 84 additions & 7 deletions

File tree

dojo/importers/default_reimporter.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,13 @@ def process_matched_special_status_finding(
476476
):
477477
self.unchanged_items.append(existing_finding)
478478
return existing_finding, True
479+
# If the finding is risk accepted and inactive in Defectdojo we do not sync the status from the scanner
480+
# We also need to add the finding to 'unchanged_items' as otherwise it will get mitigated by the reimporter
481+
# (Risk accepted findings are not set to mitigated by Defectdojo)
482+
# We however do not exit the loop as we do want to update the endpoints (in case some endpoints were fixed)
483+
elif existing_finding.risk_accepted and not existing_finding.active:
484+
self.unchanged_items.append(existing_finding)
485+
return existing_finding, False
479486
# The finding was not an exact match, so we need to add more details about from the
480487
# new finding to the existing. Return False here to make process further
481488
return existing_finding, False

dojo/tools/npm_audit_7_plus/parser.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ def get_item(item_node, tree, test):
121121
elif item_node["via"] and isinstance(item_node["via"][0], dict):
122122
title = item_node["via"][0]["title"]
123123
component_name = item_node["nodes"][0]
124-
cwe = item_node["via"][0]["cwe"][0]
124+
if len(item_node["via"][0]["cwe"]) > 0:
125+
cwe = item_node["via"][0]["cwe"][0]
126+
else:
127+
cwe = None
125128
references.append(item_node["via"][0]["url"])
126129
unique_id_from_tool = str(item_node["via"][0]["source"])
127130
cvssv3 = item_node["via"][0]["cvss"]["vectorString"]
@@ -144,15 +147,11 @@ def get_item(item_node, tree, test):
144147
if isinstance(vuln, dict):
145148
references.append(vuln["url"])
146149

147-
if len(cwe):
148-
cwe = int(cwe.split("-")[1])
149-
150150
dojo_finding = Finding(
151151
title=title,
152152
test=test,
153153
severity=severity,
154154
description=description,
155-
cwe=cwe,
156155
mitigation=mitigation,
157156
references=", ".join(references),
158157
component_name=component_name,
@@ -166,6 +165,10 @@ def get_item(item_node, tree, test):
166165
vuln_id_from_tool=unique_id_from_tool,
167166
)
168167

168+
if cwe is not None:
169+
cwe = int(cwe.split("-")[1])
170+
dojo_finding.cwe = cwe
171+
169172
if (cvssv3 is not None) and (len(cvssv3) > 0):
170173
dojo_finding.cvssv3 = cvssv3
171174

helm/defectdojo/templates/initializer-job.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ spec:
5353
command:
5454
- '/bin/bash'
5555
- '-c'
56-
- '/wait-for-it.sh ${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432} -t 30 -s -- /bin/echo Database is up'
56+
- '/wait-for-it.sh ${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432} -t 300 -s -- /bin/echo Database is up'
5757
image: '{{ template "django.uwsgi.repository" . }}:{{ .Values.tag }}'
5858
imagePullPolicy: {{ .Values.imagePullPolicy }}
5959
{{- if .Values.securityContext.enabled }}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"auditReportVersion": 2,
3+
"vulnerabilities": {
4+
"got": {
5+
"name": "got",
6+
"severity": "moderate",
7+
"isDirect": false,
8+
"via": [
9+
{
10+
"source": 1088948,
11+
"name": "got",
12+
"dependency": "got",
13+
"title": "Got allows a redirect to a UNIX socket",
14+
"url": "https://github.com/advisories/GHSA-pfrx-2q88-qq97",
15+
"severity": "moderate",
16+
"cwe": [],
17+
"cvss": {
18+
"score": 5.3,
19+
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N"
20+
},
21+
"range": "<11.8.5"
22+
}
23+
],
24+
"effects": [
25+
],
26+
"range": "<11.8.5",
27+
"nodes": [
28+
"node_modules/got"
29+
],
30+
"fixAvailable": {
31+
"name": "nodemon",
32+
"version": "3.1.4",
33+
"isSemVerMajor": true
34+
}
35+
}
36+
},
37+
"metadata": {
38+
"vulnerabilities": {
39+
"info": 0,
40+
"low": 0,
41+
"moderate": 0,
42+
"high": 1,
43+
"critical": 0,
44+
"total": 1
45+
},
46+
"dependencies": {
47+
"prod": 98,
48+
"dev": 0,
49+
"optional": 0,
50+
"peer": 0,
51+
"peerOptional": 0,
52+
"total": 97
53+
}
54+
}
55+
}
56+

unittests/test_import_reimport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ def test_import_reimport_keep_false_positive_and_out_of_scope(self):
11151115
active_findings_before = self.get_test_findings_api(test_id, active=True)
11161116
self.assert_finding_count_json(0, active_findings_before)
11171117

1118-
with assertTestImportModelsCreated(self, reimports=1, affected_findings=1, created=1):
1118+
with assertTestImportModelsCreated(self, reimports=1, affected_findings=1, created=1, untouched=1):
11191119
reimport0 = self.reimport_scan_with_params(test_id, self.zap_sample0_filename)
11201120

11211121
self.assertEqual(reimport0["test"], test_id)

unittests/tools/test_npm_audit_7_plus_parser.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,14 @@ def test_npm_audit_7_plus_parser_with_many_vuln_has_many_findings(self):
4040
self.assertIsNotNone(finding.description)
4141
self.assertGreater(len(finding.description), 0)
4242
self.assertEqual("@vercel/fun", finding.title)
43+
44+
def test_npm_audit_7_plus_parser_issue_10801(self):
45+
testfile = open(path.join(path.dirname(__file__), "../scans/npm_audit_7_plus/issue_10801.json"), encoding="utf-8")
46+
parser = NpmAudit7PlusParser()
47+
findings = parser.get_findings(testfile, Test())
48+
testfile.close()
49+
self.assertEqual(1, len(findings))
50+
with self.subTest(i=0):
51+
finding = findings[0]
52+
self.assertEqual("Medium", finding.severity)
53+
self.assertEqual(0, finding.cwe)

0 commit comments

Comments
 (0)