You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`unittests/scans/<parser_dir>/{many_vulns,no_vuln,one_vuln}.json` | Sample files containing meaningful data for unit tests. The minimal set.
38
38
|`unittests/tools/test_<parser_name>_parser.py` | Unit tests of the parser.
39
39
|`dojo/settings/settings.dist.py` | If you want to use a modern hashcode based deduplication algorithm
40
-
|`docs/content/en/connecting_your_tools/parsers/<file/api>/<parser_file>.md` | Documentation, what kind of file format is required and how it should be obtained
41
-
40
+
|`docs/content/en/connecting_your_tools/parsers/<file/api>/<parser_file>.md` | Documentation, what kind of file format is required and how it should be obtained
41
+
42
42
43
43
## Factory contract
44
44
@@ -145,7 +145,7 @@ Very bad example:
145
145
Various file formats are handled through libraries. In order to keep DefectDojo slim and also don't extend the attack surface, keep the number of libraries used minimal and take other parsers as an example.
146
146
147
147
#### defusedXML in favour of lxml
148
-
As xml is by default an unsecure format, the information parsed from various xml output has to be parsed in a secure way. Within an evaluation, we determined that defusedXML is the library which we will use in the future to parse xml files in parsers as this library is rated more secure. Thus, we will only accept PRs with the defusedxml library.
148
+
As xml is by default an unsecure format, the information parsed from various xml output has to be parsed in a secure way. Within an evaluation, we determined that defusedXML is the library which we will use in the future to parse xml files in parsers as this library is rated more secure. Thus, we will only accept PRs with the defusedxml library.
149
149
150
150
### Not all attributes are mandatory
151
151
@@ -168,14 +168,22 @@ Good example:
168
168
### Do not parse CVSS by hand (vector, score or severity)
169
169
170
170
Data can have `CVSS` vectors or scores. Don't write your own CVSS score algorithm.
171
-
For parser, we rely on module `cvss`.
171
+
For parser, we rely on module `cvss`. But we also have a helper method to validate the vector and extract the base score and severity from it.
finding.severity = vectors[0].severities()[0] # if your tool does generate severity
196
+
finding.severity = severity
197
+
finding.cvssv3_score = cvssv3_score
199
198
```
200
199
201
200
Bad example (DIY):
@@ -366,4 +365,3 @@ Please add a new .md file in [`docs/content/en/connecting_your_tools/parsers`] w
366
365
* A link to the scanner itself - (e.g. GitHub or vendor link)
367
366
368
367
Here is an example of a completed Parser documentation page: [https://github.com/DefectDojo/django-DefectDojo/blob/master/docs/content/en/connecting_your_tools/parsers/file/acunetix.md](https://github.com/DefectDojo/django-DefectDojo/blob/master/docs/content/en/connecting_your_tools/parsers/file/acunetix.md)
# cvssv3_regex = RegexValidator(regex=r"^AV:[NALP]|AC:[LH]|PR:[UNLH]|UI:[NR]|S:[UC]|[CIA]:[NLH]", message="CVSS must be entered in format: 'AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H'")
# use the environmental score, which is the most refined score
2707
-
self.cvssv3_score=cvss_object.scores()[2]
2705
+
self.cvssv3_score=cvss_vector.scores()[2]
2708
2706
exceptExceptionasex:
2709
-
logger.error("Can't compute cvssv3 score for finding id %i. Invalid cvssv3 vector found: '%s'. Exception: %s", self.id, self.cvssv3, ex)
2707
+
logger.warning("Can't compute cvssv3 score for finding id %i. Invalid cvssv3 vector found: '%s'. Exception: %s.", self.id, self.cvssv3, ex)
2708
+
# should we set self.cvssv3 to None here to avoid storing invalid vectors? it would also remove invalid vectors on existing findings...
2710
2709
2711
2710
self.set_hash_code(dedupe_option)
2712
2711
@@ -3519,8 +3518,6 @@ class Finding_Template(models.Model):
3519
3518
blank=False,
3520
3519
verbose_name="Vulnerability Id",
3521
3520
help_text="An id of a vulnerability in a security advisory associated with this finding. Can be a Common Vulnerabilities and Exposures (CVE) or from other sources.")
3522
-
# cvssv3_regex = RegexValidator(regex=r"^AV:[NALP]|AC:[LH]|PR:[UNLH]|UI:[NR]|S:[UC]|[CIA]:[NLH]", message="CVSS must be entered in format: 'AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H'")
cvssv3=models.TextField(help_text=_("Common Vulnerability Scoring System version 3 (CVSSv3) score associated with this finding."), validators=[cvss3_validator], max_length=117, null=True, verbose_name=_("CVSS v3 vector"))
0 commit comments