diff --git a/gcp/workers/oss_fuzz_worker/testdata/UpdateTest_update_bad_ecosystem_new.txt b/gcp/workers/oss_fuzz_worker/testdata/UpdateTest_update_bad_ecosystem_new.txt index d5828e36cba..38062cbd78a 100644 --- a/gcp/workers/oss_fuzz_worker/testdata/UpdateTest_update_bad_ecosystem_new.txt +++ b/gcp/workers/oss_fuzz_worker/testdata/UpdateTest_update_bad_ecosystem_new.txt @@ -3,5 +3,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '3000-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/oss_fuzz_worker/testdata/UpdateTest_update_partly_bad_ecosystem_delete.txt b/gcp/workers/oss_fuzz_worker/testdata/UpdateTest_update_partly_bad_ecosystem_delete.txt index 39b24a9dd51..bbe26736c10 100644 --- a/gcp/workers/oss_fuzz_worker/testdata/UpdateTest_update_partly_bad_ecosystem_delete.txt +++ b/gcp/workers/oss_fuzz_worker/testdata/UpdateTest_update_partly_bad_ecosystem_delete.txt @@ -3,5 +3,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '2021-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/RESTUpdateTest_update_no_introduced.txt b/gcp/workers/worker/testdata/RESTUpdateTest_update_no_introduced.txt index 15e5b16f2bb..8acf0e2cf80 100644 --- a/gcp/workers/worker/testdata/RESTUpdateTest_update_no_introduced.txt +++ b/gcp/workers/worker/testdata/RESTUpdateTest_update_no_introduced.txt @@ -217,5 +217,4 @@ 'id': 'CURL-CVE-2022-32221', 'modified': '3000-01-01T00:00:00Z', 'published': '2022-10-26T08:00:00Z', - 'schema_version': '1.7.3', 'summary': 'POST following PUT confusion'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_last_affected_git.txt b/gcp/workers/worker/testdata/UpdateTest_last_affected_git.txt index f528ee84c41..3b2ffe9ab28 100644 --- a/gcp/workers/worker/testdata/UpdateTest_last_affected_git.txt +++ b/gcp/workers/worker/testdata/UpdateTest_last_affected_git.txt @@ -8,5 +8,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '3000-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_normalized_pypi.txt b/gcp/workers/worker/testdata/UpdateTest_normalized_pypi.txt index f0dd9538315..ec1a1553a98 100644 --- a/gcp/workers/worker/testdata/UpdateTest_normalized_pypi.txt +++ b/gcp/workers/worker/testdata/UpdateTest_normalized_pypi.txt @@ -13,5 +13,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '3000-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability in an unnormalized package'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_normalized_pypi_pubsub_calls.txt b/gcp/workers/worker/testdata/UpdateTest_normalized_pypi_pubsub_calls.txt index dee3a939577..109622dc0d6 100644 --- a/gcp/workers/worker/testdata/UpdateTest_normalized_pypi_pubsub_calls.txt +++ b/gcp/workers/worker/testdata/UpdateTest_normalized_pypi_pubsub_calls.txt @@ -1 +1 @@ -[call('projects/test-osv/topics/pypi-bridge', data=b'{"id": "PYSEC-456", "summary": "A vulnerability in an unnormalized package", "details": "Blah blah blah\\nBlah\\n", "modified": "3000-01-01T00:00:00Z", "published": "3000-01-01T00:00:00Z", "references": [{"type": "WEB", "url": "https://ref.com/ref"}], "affected": [{"package": {"name": "scrapy", "ecosystem": "PyPI", "purl": "pkg:pypi/scrapy"}, "ranges": [{"type": "ECOSYSTEM", "events": [{"introduced": "1.14.2"}, {"fixed": "1.31.0"}]}, {"type": "GIT", "repo": "https://osv-test/repo/url", "events": [{"introduced": "eefe8ec3f1f90d0e684890e810f3f21e8500a4cd"}, {"fixed": "8d8242f545e9cec3e6d0d2e3f5bde8be1c659735"}]}], "versions": []}], "schema_version": "1.7.3"}')] \ No newline at end of file +[call('projects/test-osv/topics/pypi-bridge', data=b'{"id": "PYSEC-456", "summary": "A vulnerability in an unnormalized package", "details": "Blah blah blah\\nBlah\\n", "modified": "3000-01-01T00:00:00Z", "published": "3000-01-01T00:00:00Z", "references": [{"type": "WEB", "url": "https://ref.com/ref"}], "affected": [{"package": {"name": "scrapy", "ecosystem": "PyPI", "purl": "pkg:pypi/scrapy"}, "ranges": [{"type": "ECOSYSTEM", "events": [{"introduced": "1.14.2"}, {"fixed": "1.31.0"}]}, {"type": "GIT", "repo": "https://osv-test/repo/url", "events": [{"introduced": "eefe8ec3f1f90d0e684890e810f3f21e8500a4cd"}, {"fixed": "8d8242f545e9cec3e6d0d2e3f5bde8be1c659735"}]}], "versions": []}], "schema_version": "SCHEMA_VERSION"}')] \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_pypi_pubsub_calls.txt b/gcp/workers/worker/testdata/UpdateTest_pypi_pubsub_calls.txt index 32a1b96792f..51f4eaac423 100644 --- a/gcp/workers/worker/testdata/UpdateTest_pypi_pubsub_calls.txt +++ b/gcp/workers/worker/testdata/UpdateTest_pypi_pubsub_calls.txt @@ -1 +1 @@ -[call('projects/test-osv/topics/pypi-bridge', data=b'{"id": "PYSEC-123", "summary": "A vulnerability", "details": "Blah blah blah\\nBlah\\n", "modified": "3000-01-01T00:00:00Z", "published": "3000-01-01T00:00:00Z", "references": [{"type": "WEB", "url": "https://ref.com/ref"}], "affected": [{"package": {"name": "grpcio", "ecosystem": "PyPI", "purl": "pkg:pypi/grpcio"}, "ranges": [{"type": "ECOSYSTEM", "events": [{"introduced": "1.14.2"}, {"fixed": "1.31.0"}]}, {"type": "GIT", "repo": "https://osv-test/repo/url", "events": [{"introduced": "eefe8ec3f1f90d0e684890e810f3f21e8500a4cd"}, {"fixed": "8d8242f545e9cec3e6d0d2e3f5bde8be1c659735"}]}], "versions": ["1.14.2", "1.15.0", "1.15.0rc1", "1.16.0", "1.16.0rc1", "1.16.1", "1.17.0", "1.17.1", "1.18.0", "1.19.0", "1.20.0", "1.20.0rc1", "1.20.0rc2", "1.20.0rc3", "1.20.1", "1.21.0rc1", "1.21.1", "1.21.1rc1", "1.22.0", "1.22.0rc1", "1.22.1", "1.23.0", "1.23.0rc1", "1.23.1", "1.24.0", "1.24.0rc1", "1.24.1", "1.24.3", "1.25.0", "1.25.0rc1", "1.26.0", "1.26.0rc1", "1.27.0rc1", "1.27.0rc2", "1.27.1", "1.27.2", "1.28.0rc1", "1.28.0rc2", "1.28.1", "1.29.0", "1.30.0"]}], "schema_version": "1.7.3"}')] \ No newline at end of file +[call('projects/test-osv/topics/pypi-bridge', data=b'{"id": "PYSEC-123", "summary": "A vulnerability", "details": "Blah blah blah\\nBlah\\n", "modified": "3000-01-01T00:00:00Z", "published": "3000-01-01T00:00:00Z", "references": [{"type": "WEB", "url": "https://ref.com/ref"}], "affected": [{"package": {"name": "grpcio", "ecosystem": "PyPI", "purl": "pkg:pypi/grpcio"}, "ranges": [{"type": "ECOSYSTEM", "events": [{"introduced": "1.14.2"}, {"fixed": "1.31.0"}]}, {"type": "GIT", "repo": "https://osv-test/repo/url", "events": [{"introduced": "eefe8ec3f1f90d0e684890e810f3f21e8500a4cd"}, {"fixed": "8d8242f545e9cec3e6d0d2e3f5bde8be1c659735"}]}], "versions": ["1.14.2", "1.15.0", "1.15.0rc1", "1.16.0", "1.16.0rc1", "1.16.1", "1.17.0", "1.17.1", "1.18.0", "1.19.0", "1.20.0", "1.20.0rc1", "1.20.0rc2", "1.20.0rc3", "1.20.1", "1.21.0rc1", "1.21.1", "1.21.1rc1", "1.22.0", "1.22.0rc1", "1.22.1", "1.23.0", "1.23.0rc1", "1.23.1", "1.24.0", "1.24.0rc1", "1.24.1", "1.24.3", "1.25.0", "1.25.0rc1", "1.26.0", "1.26.0rc1", "1.27.0rc1", "1.27.0rc2", "1.27.1", "1.27.2", "1.28.0rc1", "1.28.0rc2", "1.28.1", "1.29.0", "1.30.0"]}], "schema_version": "SCHEMA_VERSION"}')] \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_ubuntu_severity_type.txt b/gcp/workers/worker/testdata/UpdateTest_ubuntu_severity_type.txt index a79a031c48b..a88d05b4e34 100644 --- a/gcp/workers/worker/testdata/UpdateTest_ubuntu_severity_type.txt +++ b/gcp/workers/worker/testdata/UpdateTest_ubuntu_severity_type.txt @@ -216,6 +216,5 @@ 'url': 'https://git.kernel.org/stable/c/aace6b63892ce8307e502a60fe2f5a4bc6e1cfe7'}, { 'type': 'REPORT', 'url': 'https://git.kernel.org/stable/c/c92d6089d8ad7d4d815ebcedee3f3907b539ff1f'}], - 'schema_version': '1.7.3', 'severity': [{'score': 'medium', 'type': 'Ubuntu'}], 'upstream': ['CVE-2025-38094']} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update.txt b/gcp/workers/worker/testdata/UpdateTest_update.txt index 11f21ecb72f..1d292b753b0 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update.txt @@ -17,7 +17,6 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '2021-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'severity': [ { 'score': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L', 'type': 'CVSS_V3'}], 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_alpine.txt b/gcp/workers/worker/testdata/UpdateTest_update_alpine.txt index bc29cb45861..efc78ac0121 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_alpine.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_alpine.txt @@ -506,5 +506,4 @@ { 'type': 'ARTICLE', 'url': 'https://lists.debian.org/debian-lts-announce/2022/09/msg00023.html'}, { 'type': 'WEB', - 'url': 'https://lists.debian.org/debian-lts-announce/2022/09/msg00023.html'}], - 'schema_version': '1.7.3'} \ No newline at end of file + 'url': 'https://lists.debian.org/debian-lts-announce/2022/09/msg00023.html'}]} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_bad_ecosystem_new.txt b/gcp/workers/worker/testdata/UpdateTest_update_bad_ecosystem_new.txt index d5828e36cba..38062cbd78a 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_bad_ecosystem_new.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_bad_ecosystem_new.txt @@ -3,5 +3,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '3000-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_bucket_0.txt b/gcp/workers/worker/testdata/UpdateTest_update_bucket_0.txt index 17143e52ecd..e2217dcf15e 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_bucket_0.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_bucket_0.txt @@ -33,5 +33,4 @@ { 'type': 'FIX', 'url': 'https://github.com/opencontainers/selinux/commit/03b517dc4fd57245b1cf506e8ba7b817b6d309da'}, { 'type': 'WEB', - 'url': 'https://github.com/opencontainers/runc/issues/2128'}], - 'schema_version': '1.7.3'} \ No newline at end of file + 'url': 'https://github.com/opencontainers/runc/issues/2128'}]} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_bucket_2.txt b/gcp/workers/worker/testdata/UpdateTest_update_bucket_2.txt index 053d0e49367..9030d64fac3 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_bucket_2.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_bucket_2.txt @@ -14,7 +14,6 @@ 'url': 'https://android.googlesource.com/platform/frameworks/av/+/084077feb6b8c961adcbe77b2bd76601ca54e534'}, { 'type': 'FIX', 'url': 'https://android.googlesource.com/platform/frameworks/av/+/cc2165840d524bb9553f9d73d1904633d20100a2'}], - 'schema_version': '1.7.3', 'summary': 'In multiple methods of AAudioService, there is a possible ' 'use-after-free due to a race condition. This could lead to ' 'local escalation of privilege with User execution privileges ' diff --git a/gcp/workers/worker/testdata/UpdateTest_update_bucket_cve.txt b/gcp/workers/worker/testdata/UpdateTest_update_bucket_cve.txt index 49fafa64d5c..cdded136948 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_bucket_cve.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_bucket_cve.txt @@ -105,6 +105,5 @@ 'url': 'https://vuldb.com/?ctiid.217549'}, { 'type': 'REPORT', 'url': 'https://vuldb.com/?id.217549'}], - 'schema_version': '1.7.3', 'severity': [ { 'score': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H', 'type': 'CVSS_V3'}]} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_debian.txt b/gcp/workers/worker/testdata/UpdateTest_update_debian.txt index b42b09b1107..51f473f1dc4 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_debian.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_debian.txt @@ -42,5 +42,4 @@ 'published': '2014-09-20T00:00:00Z', 'references': [ { 'type': 'ADVISORY', 'url': 'https://www.debian.org/security/2014/dsa-3029'}], - 'schema_version': '1.7.3', 'summary': 'nginx - security update'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_last_affected.txt b/gcp/workers/worker/testdata/UpdateTest_update_last_affected.txt index 545e9381ef5..d105d7ce73e 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_last_affected.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_last_affected.txt @@ -51,5 +51,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '3000-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_limit.txt b/gcp/workers/worker/testdata/UpdateTest_update_limit.txt index ded5ae60b02..d27a9357482 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_limit.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_limit.txt @@ -22,5 +22,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '3000-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_linux.txt b/gcp/workers/worker/testdata/UpdateTest_update_linux.txt index 8abe827660b..41cbd4b944c 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_linux.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_linux.txt @@ -8,5 +8,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '3000-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_maven.txt b/gcp/workers/worker/testdata/UpdateTest_update_maven.txt index b8f92df1d2f..547548a73aa 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_maven.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_maven.txt @@ -38,7 +38,6 @@ 'url': 'https://github.com/apache/any23'}, { 'type': 'WEB', 'url': 'https://lists.apache.org/thread.html/r589d1a9f94dbeee7a0f5dbe8513a0e300dfe669bd964ba2fbfe28e07%40%3Cannounce.apache.org%3E'}], - 'schema_version': '1.7.3', 'severity': [ { 'score': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N', 'type': 'CVSS_V3'}], 'summary': 'XML Injection in Any23'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_new.txt b/gcp/workers/worker/testdata/UpdateTest_update_new.txt index 1b333bd0a52..10c6a95803c 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_new.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_new.txt @@ -15,5 +15,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '3000-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_no_introduced.txt b/gcp/workers/worker/testdata/UpdateTest_update_no_introduced.txt index 9a6219d1cc8..0a7d19c15bf 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_no_introduced.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_no_introduced.txt @@ -15,5 +15,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '2021-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_partly_bad_ecosystem_delete.txt b/gcp/workers/worker/testdata/UpdateTest_update_partly_bad_ecosystem_delete.txt index 39b24a9dd51..bbe26736c10 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_partly_bad_ecosystem_delete.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_partly_bad_ecosystem_delete.txt @@ -3,5 +3,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '2021-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_partly_bad_ecosystem_new.txt b/gcp/workers/worker/testdata/UpdateTest_update_partly_bad_ecosystem_new.txt index 5e0f3a2b915..39fca90a01f 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_partly_bad_ecosystem_new.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_partly_bad_ecosystem_new.txt @@ -14,5 +14,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '3000-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/testdata/UpdateTest_update_pypi.txt b/gcp/workers/worker/testdata/UpdateTest_update_pypi.txt index 26c2f56db26..9c0cfca4e70 100644 --- a/gcp/workers/worker/testdata/UpdateTest_update_pypi.txt +++ b/gcp/workers/worker/testdata/UpdateTest_update_pypi.txt @@ -54,5 +54,4 @@ 'modified': '3000-01-01T00:00:00Z', 'published': '3000-01-01T00:00:00Z', 'references': [{'type': 'WEB', 'url': 'https://ref.com/ref'}], - 'schema_version': '1.7.3', 'summary': 'A vulnerability'} \ No newline at end of file diff --git a/gcp/workers/worker/worker_test.py b/gcp/workers/worker/worker_test.py index 15997c87142..e5b85842061 100644 --- a/gcp/workers/worker/worker_test.py +++ b/gcp/workers/worker/worker_test.py @@ -139,9 +139,9 @@ def test_git_ranges(self): } task_runner._source_update(message) - self.expect_dict_equal( - 'update_no_introduced', - MessageToDict(osv.gcs.get_by_id('CURL-CVE-2022-32221'))) + d = MessageToDict(osv.gcs.get_by_id('CURL-CVE-2022-32221')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_no_introduced', d) class UpdateTest(unittest.TestCase, tests.ExpectationTest(TEST_DATA_DIR)): @@ -276,8 +276,9 @@ def test_update(self): } task_runner._source_update(message) - self.expect_dict_equal('update', - MessageToDict(osv.gcs.get_by_id('OSV-123'))) + d = MessageToDict(osv.gcs.get_by_id('OSV-123')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update', d) affected_commits = list(osv.AffectedCommits.query()) self.assertEqual(1, len(affected_commits)) @@ -309,8 +310,9 @@ def test_update_limit(self): } task_runner._source_update(message) - self.expect_dict_equal('update_limit', - MessageToDict(osv.gcs.get_by_id('OSV-128'))) + d = MessageToDict(osv.gcs.get_by_id('OSV-128')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_limit', d) affected_commits = list(osv.AffectedCommits.query()) self.assertEqual(1, len(affected_commits)) @@ -340,8 +342,9 @@ def test_update_no_introduced(self): } task_runner._source_update(message) - self.expect_dict_equal('update_no_introduced', - MessageToDict(osv.gcs.get_by_id('OSV-127'))) + d = MessageToDict(osv.gcs.get_by_id('OSV-127')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_no_introduced', d) affected_commits = list(osv.AffectedCommits.query()) self.assertEqual(1, len(affected_commits)) @@ -387,8 +390,9 @@ def test_update_new(self): } task_runner._source_update(message) - self.expect_dict_equal('update_new', - MessageToDict(osv.gcs.get_by_id('OSV-126'))) + d = MessageToDict(osv.gcs.get_by_id('OSV-126')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_new', d) def test_update_delete(self): """Test deletion.""" @@ -463,8 +467,9 @@ def test_update_pypi(self): } task_runner._source_update(message) - self.expect_dict_equal('update_pypi', - MessageToDict(osv.gcs.get_by_id('PYSEC-123'))) + d = MessageToDict(osv.gcs.get_by_id('PYSEC-123')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_pypi', d) affected_commits = list(osv.AffectedCommits.query()) self.assertEqual(1, len(affected_commits)) @@ -478,7 +483,16 @@ def test_update_pypi(self): [codecs.encode(commit, 'hex') for commit in affected_commits.commits], ) - self.expect_equal('pypi_pubsub_calls', self.mock_publish.mock_calls) + # Normalize schema version in mock calls for comparison. + calls = [] + for call in self.mock_publish.mock_calls: + kwargs = call.kwargs.copy() + if 'data' in kwargs: + kwargs['data'] = kwargs['data'].replace( + f'"schema_version": "{osv.SCHEMA_VERSION}"'.encode(), + b'"schema_version": "SCHEMA_VERSION"') + calls.append(mock.call(*call.args, **kwargs)) + self.expect_equal('pypi_pubsub_calls', calls) def test_normalize_pypi(self): """Test a PyPI entry normalizes as expected.""" @@ -504,8 +518,9 @@ def test_normalize_pypi(self): } task_runner._source_update(message) - self.expect_dict_equal('normalized_pypi', - MessageToDict(osv.gcs.get_by_id('PYSEC-456'))) + d = MessageToDict(osv.gcs.get_by_id('PYSEC-456')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('normalized_pypi', d) affected_commits = list(osv.AffectedCommits.query()) self.assertEqual(1, len(affected_commits)) @@ -519,8 +534,16 @@ def test_normalize_pypi(self): [codecs.encode(commit, 'hex') for commit in affected_commits.commits], ) - self.expect_equal('normalized_pypi_pubsub_calls', - self.mock_publish.mock_calls) + # Normalize schema version in mock calls for comparison. + calls = [] + for call in self.mock_publish.mock_calls: + kwargs = call.kwargs.copy() + if 'data' in kwargs: + kwargs['data'] = kwargs['data'].replace( + f'"schema_version": "{osv.SCHEMA_VERSION}"'.encode(), + b'"schema_version": "SCHEMA_VERSION"') + calls.append(mock.call(*call.args, **kwargs)) + self.expect_equal('normalized_pypi_pubsub_calls', calls) def test_update_last_affected(self): """Test a PyPI entry.""" @@ -546,8 +569,9 @@ def test_update_last_affected(self): } task_runner._source_update(message) - self.expect_dict_equal('update_last_affected', - MessageToDict(osv.gcs.get_by_id('PYSEC-124'))) + d = MessageToDict(osv.gcs.get_by_id('PYSEC-124')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_last_affected', d) def test_update_maven(self): """Test updating maven.""" @@ -574,8 +598,9 @@ def test_update_maven(self): } task_runner._source_update(message) - self.expect_dict_equal( - 'update_maven', MessageToDict(osv.gcs.get_by_id('GHSA-838r-hvwh-24h8'))) + d = MessageToDict(osv.gcs.get_by_id('GHSA-838r-hvwh-24h8')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_maven', d) self.mock_publish.assert_not_called() @@ -603,8 +628,9 @@ def test_update_linux(self): } task_runner._source_update(message) - self.expect_dict_equal('update_linux', - MessageToDict(osv.gcs.get_by_id('GSD-123'))) + d = MessageToDict(osv.gcs.get_by_id('GSD-123')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_linux', d) affected_commits = list(osv.AffectedCommits.query()) self.assertEqual(1, len(affected_commits)) @@ -639,8 +665,9 @@ def test_update_bucket(self): } task_runner._source_update(message) - self.expect_dict_equal('update_bucket_0', - MessageToDict(osv.gcs.get_by_id('GO-2021-0085'))) + d = MessageToDict(osv.gcs.get_by_id('GO-2021-0085')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_bucket_0', d) def test_update_debian(self): """Test updating debian.""" @@ -666,8 +693,9 @@ def test_update_debian(self): } task_runner._source_update(message) - self.expect_dict_equal('update_debian', - MessageToDict(osv.gcs.get_by_id('DSA-3029-1'))) + d = MessageToDict(osv.gcs.get_by_id('DSA-3029-1')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_debian', d) self.mock_publish.assert_not_called() @@ -696,8 +724,9 @@ def test_update_alpine(self): } task_runner._source_update(message) - self.expect_dict_equal('update_alpine', - MessageToDict(osv.gcs.get_by_id('CVE-2022-27449'))) + d = MessageToDict(osv.gcs.get_by_id('CVE-2022-27449')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_alpine', d) def test_update_android(self): """Test updating Android through bucket entries.""" @@ -720,8 +749,9 @@ def test_update_android(self): } task_runner._source_update(message) - self.expect_dict_equal('update_bucket_2', - MessageToDict(osv.gcs.get_by_id('ASB-A-153358911'))) + d = MessageToDict(osv.gcs.get_by_id('ASB-A-153358911')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_bucket_2', d) def test_update_bad_ecosystem_new(self): """Test adding from an unsupported ecosystem.""" @@ -744,8 +774,9 @@ def test_update_bad_ecosystem_new(self): with self.assertLogs(level='WARNING'): task_runner._source_update(message) - self.expect_dict_equal('update_bad_ecosystem_new', - MessageToDict(osv.gcs.get_by_id('OSV-129'))) + d = MessageToDict(osv.gcs.get_by_id('OSV-129')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_bad_ecosystem_new', d) def test_update_partly_bad_ecosystem_new(self): """Test adding vuln with both supported and unsupported ecosystem.""" @@ -768,8 +799,9 @@ def test_update_partly_bad_ecosystem_new(self): with self.assertLogs(level='WARNING'): task_runner._source_update(message) - self.expect_dict_equal('update_partly_bad_ecosystem_new', - MessageToDict(osv.gcs.get_by_id('OSV-130'))) + d = MessageToDict(osv.gcs.get_by_id('OSV-130')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_partly_bad_ecosystem_new', d) def test_update_partly_bad_ecosystem_delete(self): """Test removal of only supported ecosystem in vulnerability with @@ -788,8 +820,9 @@ def test_update_partly_bad_ecosystem_delete(self): with self.assertLogs(level='WARNING'): task_runner._source_update(message) - self.expect_dict_equal('update_partly_bad_ecosystem_delete', - MessageToDict(osv.gcs.get_by_id('OSV-131'))) + d = MessageToDict(osv.gcs.get_by_id('OSV-131')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_partly_bad_ecosystem_delete', d) def test_update_bucket_cve(self): """Test a bucket entry that is a converted CVE and doesn't have an ecosystem.""" @@ -813,8 +846,9 @@ def test_update_bucket_cve(self): } task_runner._source_update(message) - self.expect_dict_equal('update_bucket_cve', - MessageToDict(osv.gcs.get_by_id('CVE-2016-15011'))) + d = MessageToDict(osv.gcs.get_by_id('CVE-2016-15011')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update_bucket_cve', d) def test_last_affected_git(self): """Basic last_affected GIT enumeration.""" @@ -843,9 +877,9 @@ def test_last_affected_git(self): } task_runner._source_update(message) - self.expect_dict_equal( - 'last_affected_git', - MessageToDict(osv.gcs.get_by_id('OSV-TEST-last-affected-01'))) + d = MessageToDict(osv.gcs.get_by_id('OSV-TEST-last-affected-01')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('last_affected_git', d) affected_commits = list(osv.AffectedCommits.query()) self.assertEqual(1, len(affected_commits)) @@ -908,9 +942,9 @@ def test_ubuntu_severity(self): } task_runner._source_update(message) - self.expect_dict_equal( - 'ubuntu_severity_type', - MessageToDict(osv.gcs.get_by_id('UBUNTU-CVE-2025-38094'))) + d = MessageToDict(osv.gcs.get_by_id('UBUNTU-CVE-2025-38094')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('ubuntu_severity_type', d) def test_update_skip_hash_check(self): """Test update with skip_hash_check=true.""" @@ -931,8 +965,9 @@ def test_update_skip_hash_check(self): task_runner._source_update(message) # Verify it updated (we can check GCS or just that it didn't return early) - self.expect_dict_equal('update', - MessageToDict(osv.gcs.get_by_id('OSV-123'))) + d = MessageToDict(osv.gcs.get_by_id('OSV-123')) + self.assertEqual(osv.SCHEMA_VERSION, d.pop('schema_version')) + self.expect_dict_equal('update', d) # Case 2: File missing, skip_hash_check=true -> should delete self.mock_repo.delete_file('OSV-123.yaml')