예제 #1
0
    def test_parse_file_with_multiple_vuln_has_multiple_findings(self):
        testfile = open(
            "unittests/scans/harbor_vulnerability/harbor-5-vuln.json")
        parser = HarborVulnerabilityParser()
        findings = parser.get_findings(testfile, Test())
        self.assertEqual(5, len(findings))

        finding = findings[1]
        self.assertEqual(finding.severity, 'High')
        self.assertIsNone(finding.mitigation)
        self.assertIsNone(finding.references)
    def test_parse_file_with_one_vuln_has_one_findings(self):
        testfile = open(
            "dojo/unittests/scans/harbor_vulnerability/harbor-1-vuln.json")
        parser = HarborVulnerabilityParser()
        findings = parser.get_findings(testfile, Test())
        self.assertEqual(1, len(findings))

        findings = findings[0]
        self.assertEqual(findings.title,
                         "CVE-YYYY-NNN - package (exploitable-version)")
        self.assertEqual(
            findings.description,
            "This is a sample description for sample description from Harbor API.",
        )
        self.assertEqual(
            findings.severity,
            "Informational")  # Negligible is translated to Informational
예제 #3
0
    def test_parse_file_with_one_vuln_has_one_findings(self):
        testfile = open(
            "unittests/scans/harbor_vulnerability/harbor-1-vuln.json")
        parser = HarborVulnerabilityParser()
        findings = parser.get_findings(testfile, Test())
        self.assertEqual(1, len(findings))

        finding = findings[0]
        self.assertEqual(finding.title,
                         "CVE-YYYY-NNN - package (exploitable-version)")
        self.assertEqual(
            finding.description,
            "This is a sample description for sample description from Harbor API.",
        )
        self.assertEqual(finding.severity, 'Info')
        self.assertEqual(finding.mitigation,
                         'Upgrade package to version unexploitable-version')
        self.assertEqual(finding.cve, 'CVE-YYYY-NNN')
        self.assertEqual(finding.component_name, 'package')
        self.assertEqual(finding.component_version, 'exploitable-version')
        self.assertEqual(finding.references,
                         'https://github.com/goharbor/harbor\n')
예제 #4
0
 def test_parse_file_with_no_vuln_has_no_findings(self):
     testfile = open(
         "unittests/scans/harbor_vulnerability/harbor-0-vuln.json")
     parser = HarborVulnerabilityParser()
     findings = parser.get_findings(testfile, Test())
     self.assertEqual(0, len(findings))