From 11687666017126d9689d706529cd83d32fef2a3f Mon Sep 17 00:00:00 2001 From: Will Murphy Date: Wed, 18 Oct 2023 10:00:26 -0400 Subject: [PATCH] chore: test alpine provider via snapshots Signed-off-by: Will Murphy --- .../snapshots/3.15/cve-2018-1071.json | 1 + .../snapshots/3.15/cve-2018-1083.json | 1 + .../snapshots/3.15/cve-2018-25032.json | 1 + .../snapshots/3.15/cve-2019-11922.json | 1 + .../snapshots/3.15/cve-2019-13132.json | 1 + .../snapshots/3.15/cve-2019-20044.json | 1 + .../snapshots/3.15/cve-2019-6250.json | 1 + .../snapshots/3.15/cve-2019-9210.json | 1 + .../snapshots/3.15/cve-2020-14929.json | 1 + .../snapshots/3.15/cve-2020-15166.json | 1 + .../snapshots/3.15/cve-2021-24031.json | 1 + .../snapshots/3.15/cve-2021-24032.json | 1 + .../snapshots/3.15/cve-2021-38370.json | 1 + .../snapshots/3.15/cve-2021-45444.json | 1 + .../snapshots/3.15/cve-2022-1271.json | 1 + .../snapshots/3.15/cve-2022-37434.json | 1 + tests/unit/providers/alpine/test_alpine.py | 26 +++++++++++++++++++ 17 files changed, 42 insertions(+) create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-1071.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-1083.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-25032.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-11922.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-13132.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-20044.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-6250.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-9210.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2020-14929.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2020-15166.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-24031.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-24032.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-38370.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-45444.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2022-1271.json create mode 100644 tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2022-37434.json diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-1071.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-1071.json new file mode 100644 index 00000000..3a351ba2 --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-1071.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2018-1071","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zsh","Version":"5.4.2-r1"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-1071","Description":"","Metadata":{},"Name":"CVE-2018-1071","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-1083.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-1083.json new file mode 100644 index 00000000..7f0df0d4 --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-1083.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2018-1083","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zsh","Version":"5.4.2-r1"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-1083","Description":"","Metadata":{},"Name":"CVE-2018-1083","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-25032.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-25032.json new file mode 100644 index 00000000..0fab00f1 --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2018-25032.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2018-25032","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zlib","Version":"1.2.12-r0"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-25032","Description":"","Metadata":{},"Name":"CVE-2018-25032","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-11922.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-11922.json new file mode 100644 index 00000000..907138d4 --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-11922.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2019-11922","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zstd","Version":"1.3.8-r0"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-11922","Description":"","Metadata":{},"Name":"CVE-2019-11922","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-13132.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-13132.json new file mode 100644 index 00000000..0bfd1859 --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-13132.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2019-13132","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zeromq","Version":"4.3.2-r0"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-13132","Description":"","Metadata":{},"Name":"CVE-2019-13132","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-20044.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-20044.json new file mode 100644 index 00000000..30ebe2b6 --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-20044.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2019-20044","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zsh","Version":"5.8-r0"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-20044","Description":"","Metadata":{},"Name":"CVE-2019-20044","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-6250.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-6250.json new file mode 100644 index 00000000..1b2fd415 --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-6250.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2019-6250","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zeromq","Version":"4.3.1-r0"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-6250","Description":"","Metadata":{},"Name":"CVE-2019-6250","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-9210.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-9210.json new file mode 100644 index 00000000..5691a077 --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2019-9210.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2019-9210","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"advancecomp","Version":"2.1-r2"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-9210","Description":"","Metadata":{},"Name":"CVE-2019-9210","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2020-14929.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2020-14929.json new file mode 100644 index 00000000..5cda07d4 --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2020-14929.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2020-14929","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"alpine","Version":"2.23-r0"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-14929","Description":"","Metadata":{},"Name":"CVE-2020-14929","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2020-15166.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2020-15166.json new file mode 100644 index 00000000..d70102ab --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2020-15166.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2020-15166","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zeromq","Version":"4.3.3-r0"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-15166","Description":"","Metadata":{},"Name":"CVE-2020-15166","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-24031.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-24031.json new file mode 100644 index 00000000..f62c3632 --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-24031.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2021-24031","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zstd","Version":"1.4.1-r0"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-24031","Description":"","Metadata":{},"Name":"CVE-2021-24031","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-24032.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-24032.json new file mode 100644 index 00000000..1beed87a --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-24032.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2021-24032","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zstd","Version":"1.4.9-r0"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-24032","Description":"","Metadata":{},"Name":"CVE-2021-24032","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-38370.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-38370.json new file mode 100644 index 00000000..86170a6c --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-38370.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2021-38370","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"alpine","Version":"2.25-r0"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-38370","Description":"","Metadata":{},"Name":"CVE-2021-38370","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-45444.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-45444.json new file mode 100644 index 00000000..5eb9fd2f --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2021-45444.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2021-45444","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zsh","Version":"5.8.1-r0"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-45444","Description":"","Metadata":{},"Name":"CVE-2021-45444","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2022-1271.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2022-1271.json new file mode 100644 index 00000000..77de3acb --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2022-1271.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2022-1271","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"xz","Version":"5.2.5-r1"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-1271","Description":"","Metadata":{},"Name":"CVE-2022-1271","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2022-37434.json b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2022-37434.json new file mode 100644 index 00000000..5e830665 --- /dev/null +++ b/tests/unit/providers/alpine/test-fixtures/snapshots/3.15/cve-2022-37434.json @@ -0,0 +1 @@ +{"schema":"https://raw.githubusercontent.com/anchore/vunnel/main/schema/vulnerability/os/schema-1.0.0.json","identifier":"3.15/cve-2022-37434","item":{"Vulnerability":{"Severity":"Unknown","NamespaceName":"alpine:3.15","FixedIn":[{"VersionFormat":"apk","NamespaceName":"alpine:3.15","Name":"zlib","Version":"1.2.12-r2"}],"Link":"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-37434","Description":"","Metadata":{},"Name":"CVE-2022-37434","CVSS":[]}}} diff --git a/tests/unit/providers/alpine/test_alpine.py b/tests/unit/providers/alpine/test_alpine.py index c577b223..d8137916 100644 --- a/tests/unit/providers/alpine/test_alpine.py +++ b/tests/unit/providers/alpine/test_alpine.py @@ -220,3 +220,29 @@ def mock_download(): assert workspace.num_result_entries() == 16 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(), + input_fixture="test-fixtures/input", + ) + + 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, + ) + + def mock_download(): + return None + + monkeypatch.setattr(p.parser, "_download", mock_download) + monkeypatch.setattr(p.parser, "_download_metadata_url", mock_download) + monkeypatch.setattr(p.parser, "_download_url", mock_download) + + p.update(None) + + workspace.assert_result_snapshots()