Skip to content

Commit cbaf772

Browse files
fix typos
1 parent 6a3c7c4 commit cbaf772

File tree

7 files changed

+22
-12
lines changed

7 files changed

+22
-12
lines changed

dojo/models.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from pathlib import Path
1111
from uuid import uuid4
1212

13-
import cvss.parser
1413
import dateutil
1514
import hyperlink
1615
import tagulous.admin
@@ -2700,9 +2699,12 @@ def save(self, dedupe_option=True, rules_option=True, product_grading_option=Tru
27002699
# Synchronize cvssv3 score using cvssv3 vector
27012700
if self.cvssv3:
27022701
try:
2703-
cvss_vector = cvss.parser.parse_cvss_from_text(self.cvssv3)
2704-
# use the environmental score, which is the most refined score
2705-
self.cvssv3_score = cvss_vector.scores()[2]
2702+
2703+
cvss_data = parse_cvss_data(self.cvssv3)
2704+
if cvss_data:
2705+
self.cvss3 = cvss_data.get("vector")
2706+
self.cvssv3_score = cvss_data.get("score")
2707+
27062708
except Exception as ex:
27072709
logger.warning("Can't compute cvssv3 score for finding id %i. Invalid cvssv3 vector found: '%s'. Exception: %s.", self.id, self.cvssv3, ex)
27082710
# should we set self.cvssv3 to None here to avoid storing invalid vectors? it would also remove invalid vectors on existing findings...
@@ -4635,7 +4637,11 @@ def __str__(self):
46354637
auditlog.register(Notification_Webhooks, exclude_fields=["header_name", "header_value"])
46364638

46374639

4638-
from dojo.utils import calculate_grade, to_str_typed # noqa: E402 # there is issue due to a circular import
4640+
from dojo.utils import ( # noqa: E402 # there is issue due to a circular import
4641+
calculate_grade,
4642+
parse_cvss_data,
4643+
to_str_typed,
4644+
)
46394645

46404646
tagulous.admin.register(Product.tags)
46414647
tagulous.admin.register(Test.tags)

dojo/tools/qualys/csv_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def build_findings_from_dict(report_findings: [dict]) -> [Finding]:
232232
# Make sure vector is valid
233233
cvss_data = parse_cvss_data(cvssv3)
234234
if cvss_data:
235-
finding.cvss3 = cvss_data.get("vector")
235+
finding.cvssv3 = cvss_data.get("vector")
236236
finding.cvssv3_score = cvss_data.get("score")
237237

238238
# Qualys reports regression findings as active, but with a Date Last

dojo/tools/qualys/parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,14 @@ def parse_finding(host, tree):
352352
finding.mitigated = temp["mitigation_date"]
353353
finding.is_mitigated = temp["mitigated"]
354354
finding.active = temp["active"]
355+
logger.debug("CVSS_Vector: %s", temp.get("CVSS_vector"))
355356
if temp.get("CVSS_vector") is not None:
357+
logger.debug("CVSS_Vector: %s", temp.get("CVSS_vector"))
356358
cvss_data = parse_cvss_data(temp.get("CVSS_vector"))
359+
logger.debug("cvss_data: %s", cvss_data)
357360
if cvss_data:
358-
finding.cvss3 = cvss_data.get("vector")
359-
finding.cvss3_score = cvss_data.get("score")
361+
finding.cvssv3 = cvss_data.get("vector")
362+
finding.cvssv3_score = cvss_data.get("score")
360363

361364
if temp.get("CVSS_value") is not None:
362365
finding.cvssv3_score = temp.get("CVSS_value")

dojo/tools/sysdig_cli/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def parse_json(self, data, test):
108108
finding.cvssv3_score = vulnCvssScore
109109
vectors = cvss.parser.parse_cvss_from_text(vulnCvssVector)
110110
if len(vectors) > 0 and isinstance(vectors[0], CVSS3):
111-
finding.cvss = vectors[0].clean_vector()
111+
finding.cvssv3 = vectors[0].clean_vector()
112112
except ValueError:
113113
continue
114114

@@ -164,7 +164,7 @@ def parse_csv(self, arr_data, test):
164164
finding.cvssv3_score = float(row.cvss_score)
165165
vectors = cvss.parser.parse_cvss_from_text(row.cvss_vector)
166166
if len(vectors) > 0 and isinstance(vectors[0], CVSS3):
167-
finding.cvss = vectors[0].clean_vector()
167+
finding.cvssv3 = vectors[0].clean_vector()
168168
except ValueError:
169169
continue
170170
finding.risk_accepted = row.risk_accepted

dojo/tools/sysdig_reports/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def parse_csv(self, arr_data, test):
221221
finding.cvssv3_score = float(row.cvss_score)
222222
vectors = cvss.parser.parse_cvss_from_text(row.cvss_vector)
223223
if len(vectors) > 0 and isinstance(vectors[0], CVSS3):
224-
finding.cvss = vectors[0].clean_vector()
224+
finding.cvssv3 = vectors[0].clean_vector()
225225
except ValueError:
226226
continue
227227
finding.risk_accepted = row.risk_accepted

dojo/tools/trivy/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def get_result_items(self, test, results, service_name=None, artifact_name=""):
167167
severity_source = vuln.get("SeveritySource", None)
168168
cvss = vuln.get("CVSS", None)
169169
cvssv3 = None
170+
cvssv3_score = None
170171
if severity_source is not None and cvss is not None:
171172
cvssclass = cvss.get(severity_source, None)
172173
if cvssclass is not None:

dojo/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2666,7 +2666,7 @@ def parse_cvss_data(cvss_vector_string: str) -> dict:
26662666
if len(vectors) > 0 and type(vectors[0]) is CVSS3:
26672667
return {
26682668
"vector": vectors[0].clean_vector(),
2669-
"score": vectors[0].scores()[0],
2669+
"score": vectors[0].scores()[2], # environmental score is the most detailed one
26702670
"severity": vectors[0].severities()[0],
26712671
}
26722672
logger.debug("No valid CVSS3 vector found in %s", cvss_vector_string)

0 commit comments

Comments
 (0)