Skip to content

Commit

Permalink
add oracle snapshot tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman committed Oct 18, 2023
1 parent 2f4fc7a commit 1c0cf43
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/vunnel/providers/oracle/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def filter(self, vuln_dict: dict) -> dict: # noqa: A003
if fixes:
pre_filter_fix_count = len(fixes)

# sort dictionary by "Name" and "Version" keys
fixes = sorted(fixes, key=lambda k: (k["Name"], k["Version"]))

vuln["Vulnerability"]["FixedIn"] = [fix for fix in fixes if not self._is_ksplice_version(fix.get("Version", ""))]

post_filter_count = len(vuln["Vulnerability"]["FixedIn"])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"ol:5/elsa-2007-0057","item":{"Vulnerability":{"Severity":"Medium","NamespaceName":"ol:5","FixedIn":[{"Name":"bind","Version":"30:9.3.3-8.el5","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:5"},{"Name":"bind-chroot","Version":"30:9.3.3-8.el5","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:5"},{"Name":"bind-devel","Version":"30:9.3.3-8.el5","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:5"},{"Name":"bind-libbind-devel","Version":"30:9.3.3-8.el5","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:5"},{"Name":"bind-libs","Version":"30:9.3.3-8.el5","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:5"},{"Name":"bind-sdb","Version":"30:9.3.3-8.el5","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:5"},{"Name":"bind-utils","Version":"30:9.3.3-8.el5","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:5"},{"Name":"caching-nameserver","Version":"30:9.3.3-8.el5","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:5"}],"Link":"http://linux.oracle.com/errata/ELSA-2007-0057.html","Description":"","Metadata":{"Issued":"2007-06-26","RefId":"ELSA-2007-0057","CVE":[{"Name":"CVE-2007-0493","Link":"http://linux.oracle.com/cve/CVE-2007-0493.html"},{"Name":"CVE-2007-0494","Link":"http://linux.oracle.com/cve/CVE-2007-0494.html"}]},"Name":"ELSA-2007-0057","CVSS":[]}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"ol:6/elsa-2018-4250","item":{"Vulnerability":{"Severity":"High","NamespaceName":"ol:6","FixedIn":[{"Name":"kernel-uek","Version":"0:2.6.39-400.302.2.el6uek","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:6"},{"Name":"kernel-uek-debug","Version":"0:2.6.39-400.302.2.el6uek","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:6"},{"Name":"kernel-uek-debug-devel","Version":"0:2.6.39-400.302.2.el6uek","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:6"},{"Name":"kernel-uek-devel","Version":"0:2.6.39-400.302.2.el6uek","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:6"},{"Name":"kernel-uek-doc","Version":"0:2.6.39-400.302.2.el6uek","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:6"},{"Name":"kernel-uek-firmware","Version":"0:2.6.39-400.302.2.el6uek","Module":null,"VersionFormat":"rpm","NamespaceName":"ol:6"}],"Link":"http://linux.oracle.com/errata/ELSA-2018-4250.html","Description":"","Metadata":{"Issued":"2018-10-12","RefId":"ELSA-2018-4250","CVE":[{"Name":"CVE-2018-7566","Link":"http://linux.oracle.com/cve/CVE-2018-7566.html"},{"Name":"CVE-2017-13695","Link":"http://linux.oracle.com/cve/CVE-2017-13695.html"},{"Name":"CVE-2018-16658","Link":"http://linux.oracle.com/cve/CVE-2018-16658.html"},{"Name":"CVE-2018-7492","Link":"http://linux.oracle.com/cve/CVE-2018-7492.html"}]},"Name":"ELSA-2018-4250","CVSS":[]}}}
24 changes: 24 additions & 0 deletions tests/unit/providers/oracle/test_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,27 @@ def mock_download():

assert workspace.num_result_entries() == 2
assert workspace.result_schemas_valid(require_entries=True)


def test_provider_via_snapshot(helpers, disable_get_requests, monkeypatch):
workspace = helpers.provider_workspace_helper(name=Provider.name())

c = Config()
# keep all of the default values for the result store, but override the strategy
c.runtime.result_store = result.StoreStrategy.FLAT_FILE
p = Provider(
root=workspace.root,
config=c,
)

mock_data_path = helpers.local_dir("test-fixtures/mock_data")
shutil.copy(mock_data_path, workspace.input_dir / "com.oracle.elsa-all.xml")

def mock_download():
return None

monkeypatch.setattr(p.parser, "_download", mock_download)

p.update(None)

workspace.assert_result_snapshots()

0 comments on commit 1c0cf43

Please sign in to comment.