Beispiel #1
0
def test_non_comparable_versions(python_pkg1_100, python_pkg1_101,
                                 monkeypatch_distros):
    """
    Tests matching where fixed and vuln records use a version format that doesn't support comparators beyond equality (e.g CPEs)
    :return:
    """
    assert isinstance(python_pkg1_100, ImagePackage)
    assert isinstance(python_pkg1_101, ImagePackage)

    v1 = Vulnerability()
    v1.id = "CVE-100"
    v1.namespace_name = "nvdv2:cves"
    v1.severity = "high"
    v1.fixed_in = []
    v1.vulnerable_in = []
    v1.created_at = v1.updated_at = datetime.datetime.utcnow()

    vuln1 = VulnerableArtifact()
    vuln1.created_at = vuln1.updated_at = v1.created_at
    vuln1.namespace_name = v1.namespace_name
    vuln1.name = python_pkg1_100.name
    vuln1.vulnerability_id = v1.id
    vuln1.parent = v1
    vuln1.version = python_pkg1_100.version
    vuln1.include_previous_versions = True
    vuln1.epochless_version = vuln1.version
    vuln1.version_format = (
        "static"  # Random string, but not in set of ['semver', 'rpm', 'deb', 'apk']
    )

    v1.vulnerable_in.append(vuln1)

    assert v1.vulnerable_in[0].match_and_vulnerable(python_pkg1_100)
    assert not v1.vulnerable_in[0].match_and_vulnerable(python_pkg1_101)
Beispiel #2
0
def empty_semver_vulnerability():
    v = Vulnerability()
    v.id = "CVE-2000"
    v.namespace_name = "github:npm"
    v.description = "test vulnerability for semver handling"
    v.metadata_json = {}
    v.created_at = datetime.datetime.utcnow()
    v.updated_at = datetime.datetime.utcnow()
    v.fixed_in = []
    v.vulnerable_in = []
    v.severity = "high"
    v.link = "somelink"
    return v
Beispiel #3
0
def empty_vulnerability():
    v = Vulnerability()
    v.id = 'CVE-1'
    v.namespace_name = 'rhel:8'
    v.description = 'test vulnerability'
    v.metadata_json = {}
    v.created_at = datetime.datetime.utcnow()
    v.updated_at = datetime.datetime.utcnow()
    v.fixed_in = []
    v.vulnerable_in = []
    v.severity = 'high'
    v.link = 'somelink'
    return v
Beispiel #4
0
def empty_vulnerability():
    v = Vulnerability()
    v.id = "CVE-1"
    v.namespace_name = "rhel:8"
    v.description = "test vulnerability"
    v.metadata_json = {}
    v.created_at = datetime.datetime.utcnow()
    v.updated_at = datetime.datetime.utcnow()
    v.fixed_in = []
    v.vulnerable_in = []
    v.severity = "high"
    v.link = "somelink"
    return v
def empty_semver_vulnerability():
    v = Vulnerability()
    v.id = 'CVE-2000'
    v.namespace_name = 'github:npm'
    v.description = 'test vulnerability for semver handling'
    v.metadata_json = {}
    v.created_at = datetime.datetime.utcnow()
    v.updated_at = datetime.datetime.utcnow()
    v.fixed_in = []
    v.vulnerable_in = []
    v.severity = 'high'
    v.link = 'somelink'
    return v