|
4 | 4 |
|
5 | 5 | import pytest |
6 | 6 |
|
7 | | -from exasol.toolbox.tools.security import Issue |
| 7 | +from exasol.toolbox.tools import security |
| 8 | +from exasol.toolbox.tools.security import ( |
| 9 | + Issue, |
| 10 | + _issues_as_json_str, |
| 11 | +) |
8 | 12 | from exasol.toolbox.util.dependencies.audit import Vulnerability |
9 | 13 |
|
10 | 14 |
|
@@ -78,6 +82,87 @@ def security_issue(self) -> Issue: |
78 | 82 | ) |
79 | 83 |
|
80 | 84 |
|
| 85 | +class SampleMavenVulnerabilities: |
| 86 | + gturri_issue = security.Issue( |
| 87 | + cve="CVE-2020-36641", |
| 88 | + cwe="CWE-611", |
| 89 | + description="A vulnerability classified as problematic was found in " |
| 90 | + "gturri aXMLRPC up to 1.12.0. This vulnerability affects " |
| 91 | + "the function ResponseParser of the file " |
| 92 | + "src/main/java/de/timroes/axmlrpc/ResponseParser.java. The " |
| 93 | + "manipulation leads to xml external entity reference. " |
| 94 | + "Upgrading to version 1.12.1 is able to address this issue. " |
| 95 | + "The patch is identified as " |
| 96 | + "ad6615b3ec41353e614f6ea5fdd5b046442a832b. It is " |
| 97 | + "recommended to upgrade the affected component. VDB-217450 " |
| 98 | + "is the identifier assigned to this vulnerability.\n" |
| 99 | + "\n" |
| 100 | + "Sonatype's research suggests that this CVE's details " |
| 101 | + "differ from those defined at NVD. See " |
| 102 | + "https://ossindex.sonatype.org/vulnerability/CVE-2020-36641 " |
| 103 | + "for details", |
| 104 | + coordinates="fr.turri:aXMLRPC:jar:1.13.0:test", |
| 105 | + references=( |
| 106 | + "https://ossindex.sonatype.org/vulnerability/CVE-2020-36641?component-type=maven&component-name=fr.turri%2FaXMLRPC&utm_source=ossindex-client&utm_medium=integration&utm_content=1.8.1", |
| 107 | + "http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-36641", |
| 108 | + "https://www.tenable.com/cve/CVE-2020-36641", |
| 109 | + ), |
| 110 | + ) |
| 111 | + github_issue_url = "https://github.com/exasol/a-project/issues/123" |
| 112 | + |
| 113 | + @property |
| 114 | + def report_json(self) -> str: |
| 115 | + return json.dumps( |
| 116 | + { |
| 117 | + "vulnerable": { |
| 118 | + "fr.turri:aXMLRPC:jar:1.13.0:test": { |
| 119 | + "coordinates": "pkg:maven/fr.turri/[email protected]", |
| 120 | + "description": "Lightweight Java XML-RPC working also on Android.", |
| 121 | + "reference": "https://ossindex.sonatype.org/component/pkg:maven/fr.turri/[email protected]?utm_source=ossindex-client&utm_medium=integration&utm_content=1.8.1", |
| 122 | + "vulnerabilities": [ |
| 123 | + { |
| 124 | + "id": self.gturri_issue.cve, |
| 125 | + "displayName": self.gturri_issue.cve, |
| 126 | + "title": f"[{self.gturri_issue.cve}] {self.gturri_issue.cwe}: Improper Restriction of XML External Entity Reference ('XXE')", |
| 127 | + "description": self.gturri_issue.description, |
| 128 | + "cvssScore": 9.8, |
| 129 | + "cvssVector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", |
| 130 | + "cwe": self.gturri_issue.cwe, |
| 131 | + "cve": self.gturri_issue.cve, |
| 132 | + "reference": self.gturri_issue.references[0], |
| 133 | + "externalReferences": self.gturri_issue.references[1:], |
| 134 | + } |
| 135 | + ], |
| 136 | + }, |
| 137 | + }, |
| 138 | + } |
| 139 | + ) |
| 140 | + |
| 141 | + @property |
| 142 | + def issues(self) -> set[Issue]: |
| 143 | + return {self.gturri_issue} |
| 144 | + |
| 145 | + @property |
| 146 | + def issues_json(self) -> str: |
| 147 | + convert_to_json = list(_issues_as_json_str(self.issues)) |
| 148 | + return convert_to_json[0] |
| 149 | + |
| 150 | + @property |
| 151 | + def gh_security_issues(self): |
| 152 | + yield "I_kwDOKj3wMM50puMN", self.gturri_issue.cve |
| 153 | + |
| 154 | + @property |
| 155 | + def create_issues_json(self) -> str: |
| 156 | + issues_dict = json.loads(self.issues_json) |
| 157 | + issues_dict["issue_url"] = self.github_issue_url |
| 158 | + return json.dumps(issues_dict) |
| 159 | + |
| 160 | + |
81 | 161 | @pytest.fixture(scope="session") |
82 | 162 | def sample_vulnerability() -> SampleVulnerability: |
83 | 163 | return SampleVulnerability() |
| 164 | + |
| 165 | + |
| 166 | +@pytest.fixture(scope="session") |
| 167 | +def sample_maven_vulnerabilities() -> SampleMavenVulnerabilities: |
| 168 | + return SampleMavenVulnerabilities() |
0 commit comments