diff --git a/src/vunnel/providers/oracle/parser.py b/src/vunnel/providers/oracle/parser.py index f5c98ab3..8c466823 100644 --- a/src/vunnel/providers/oracle/parser.py +++ b/src/vunnel/providers/oracle/parser.py @@ -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"]) diff --git a/tests/unit/providers/oracle/test-fixtures/snapshots/ol:5/elsa-2007-0057.json b/tests/unit/providers/oracle/test-fixtures/snapshots/ol:5/elsa-2007-0057.json new file mode 100644 index 00000000..7500924a --- /dev/null +++ b/tests/unit/providers/oracle/test-fixtures/snapshots/ol:5/elsa-2007-0057.json @@ -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":[]}}} diff --git a/tests/unit/providers/oracle/test-fixtures/snapshots/ol:6/elsa-2018-4250.json b/tests/unit/providers/oracle/test-fixtures/snapshots/ol:6/elsa-2018-4250.json new file mode 100644 index 00000000..f1e58976 --- /dev/null +++ b/tests/unit/providers/oracle/test-fixtures/snapshots/ol:6/elsa-2018-4250.json @@ -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":[]}}} diff --git a/tests/unit/providers/oracle/test_oracle.py b/tests/unit/providers/oracle/test_oracle.py index da4d00f3..c64d2b90 100644 --- a/tests/unit/providers/oracle/test_oracle.py +++ b/tests/unit/providers/oracle/test_oracle.py @@ -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()