From 4606136880339e6a5e66eadc17e6916899202b1d Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Thu, 21 Nov 2024 13:40:36 +0100 Subject: [PATCH] feat(model): Extend `Identifier.toPurl()` with handling for `Bazel` See also [1]. [1]: https://github.com/package-url/purl-spec/pull/317 Signed-off-by: Frank Viernau --- model/src/main/kotlin/utils/PurlExtensions.kt | 1 + model/src/main/kotlin/utils/PurlUtils.kt | 1 + .../synthetic/bazel-7.2-expected-output.yml | 16 ++++---- ...bazel-expected-output-archive-override.yml | 40 +++++++++---------- .../bazel-expected-output-git-repository.yml | 2 +- ...el-expected-output-local-path-override.yml | 6 +-- ...-output-local-registry-with-local-path.yml | 6 +-- .../bazel-expected-output-local-registry.yml | 6 +-- .../bazel-expected-output-local-registry2.yml | 4 +- .../bazel-expected-output-no-lock-file.yml | 4 +- .../synthetic/bazel-expected-output.yml | 16 ++++---- 11 files changed, 52 insertions(+), 50 deletions(-) diff --git a/model/src/main/kotlin/utils/PurlExtensions.kt b/model/src/main/kotlin/utils/PurlExtensions.kt index 52468d0309cd0..12d39cbfe0493 100644 --- a/model/src/main/kotlin/utils/PurlExtensions.kt +++ b/model/src/main/kotlin/utils/PurlExtensions.kt @@ -38,6 +38,7 @@ import org.ossreviewtoolkit.model.VcsType */ fun Identifier.getPurlType() = when (type.lowercase()) { + "bazel" -> PurlType.BAZEL "bower" -> PurlType.BOWER "carthage" -> PurlType.CARTHAGE "composer" -> PurlType.COMPOSER diff --git a/model/src/main/kotlin/utils/PurlUtils.kt b/model/src/main/kotlin/utils/PurlUtils.kt index 9059ccf863664..52d9038f0003a 100644 --- a/model/src/main/kotlin/utils/PurlUtils.kt +++ b/model/src/main/kotlin/utils/PurlUtils.kt @@ -32,6 +32,7 @@ import org.ossreviewtoolkit.utils.common.percentEncode enum class PurlType(private val value: String) { ALPINE("alpine"), A_NAME("a-name"), + BAZEL("bazel"), BOWER("bower"), CARGO("cargo"), CARTHAGE("carthage"), diff --git a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-7.2-expected-output.yml b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-7.2-expected-output.yml index b15d1c98fabde..ce03f23905821 100644 --- a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-7.2-expected-output.yml +++ b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-7.2-expected-output.yml @@ -52,7 +52,7 @@ project: linkage: "STATIC" packages: - id: "Bazel::abseil-cpp:20230125.1" - purl: "pkg:generic/abseil-cpp@20230125.1" + purl: "pkg:bazel/abseil-cpp@20230125.1" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -78,7 +78,7 @@ packages: revision: "" path: "" - id: "Bazel::bazel_skylib:1.6.1" - purl: "pkg:generic/bazel_skylib@1.6.1" + purl: "pkg:bazel/bazel_skylib@1.6.1" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -104,7 +104,7 @@ packages: revision: "" path: "" - id: "Bazel::gflags:2.2.2" - purl: "pkg:generic/gflags@2.2.2" + purl: "pkg:bazel/gflags@2.2.2" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -130,7 +130,7 @@ packages: revision: "" path: "" - id: "Bazel::glog:0.5.0" - purl: "pkg:generic/glog@0.5.0" + purl: "pkg:bazel/glog@0.5.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -156,7 +156,7 @@ packages: revision: "" path: "" - id: "Bazel::googletest:1.14.0" - purl: "pkg:generic/googletest@1.14.0" + purl: "pkg:bazel/googletest@1.14.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -182,7 +182,7 @@ packages: revision: "" path: "" - id: "Bazel::platforms:0.0.9" - purl: "pkg:generic/platforms@0.0.9" + purl: "pkg:bazel/platforms@0.0.9" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -208,7 +208,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_cc:0.0.9" - purl: "pkg:generic/rules_cc@0.0.9" + purl: "pkg:bazel/rules_cc@0.0.9" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -234,7 +234,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_license:0.0.7" - purl: "pkg:generic/rules_license@0.0.7" + purl: "pkg:bazel/rules_license@0.0.7" declared_licenses: [] declared_licenses_processed: {} description: "" diff --git a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-archive-override.yml b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-archive-override.yml index 7acbb59fa7c88..5a53269bd7959 100644 --- a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-archive-override.yml +++ b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-archive-override.yml @@ -183,7 +183,7 @@ project: linkage: "STATIC" packages: - id: "Bazel::abseil-cpp:20230802.0.bcr.1" - purl: "pkg:generic/abseil-cpp@20230802.0.bcr.1" + purl: "pkg:bazel/abseil-cpp@20230802.0.bcr.1" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -209,7 +209,7 @@ packages: revision: "" path: "" - id: "Bazel::bazel_features:1.9.1" - purl: "pkg:generic/bazel_features@1.9.1" + purl: "pkg:bazel/bazel_features@1.9.1" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -235,7 +235,7 @@ packages: revision: "" path: "" - id: "Bazel::bazel_skylib:1.7.1" - purl: "pkg:generic/bazel_skylib@1.7.1" + purl: "pkg:bazel/bazel_skylib@1.7.1" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -261,7 +261,7 @@ packages: revision: "" path: "" - id: "Bazel::googletest:1.14.0" - purl: "pkg:generic/googletest@1.14.0" + purl: "pkg:bazel/googletest@1.14.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -287,7 +287,7 @@ packages: revision: "" path: "" - id: "Bazel::nanopb:0.4.9" - purl: "pkg:generic/nanopb@0.4.9" + purl: "pkg:bazel/nanopb@0.4.9" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -313,7 +313,7 @@ packages: revision: "" path: "" - id: "Bazel::platforms:0.0.10" - purl: "pkg:generic/platforms@0.0.10" + purl: "pkg:bazel/platforms@0.0.10" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -339,7 +339,7 @@ packages: revision: "" path: "" - id: "Bazel::protobuf:24.4" - purl: "pkg:generic/protobuf@24.4" + purl: "pkg:bazel/protobuf@24.4" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -365,7 +365,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_cc:0.0.9" - purl: "pkg:generic/rules_cc@0.0.9" + purl: "pkg:bazel/rules_cc@0.0.9" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -391,7 +391,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_cuda:0.1.1" - purl: "pkg:generic/rules_cuda@0.1.1" + purl: "pkg:bazel/rules_cuda@0.1.1" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -418,7 +418,7 @@ packages: path: "" is_modified: true - id: "Bazel::rules_java:7.1.0" - purl: "pkg:generic/rules_java@7.1.0" + purl: "pkg:bazel/rules_java@7.1.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -444,7 +444,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_jvm_external:5.1" - purl: "pkg:generic/rules_jvm_external@5.1" + purl: "pkg:bazel/rules_jvm_external@5.1" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -470,7 +470,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_license:0.0.7" - purl: "pkg:generic/rules_license@0.0.7" + purl: "pkg:bazel/rules_license@0.0.7" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -496,7 +496,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_pkg:0.7.0" - purl: "pkg:generic/rules_pkg@0.7.0" + purl: "pkg:bazel/rules_pkg@0.7.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -522,7 +522,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_proto:6.0.2" - purl: "pkg:generic/rules_proto@6.0.2" + purl: "pkg:bazel/rules_proto@6.0.2" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -548,7 +548,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_proto_grpc:5.0.0" - purl: "pkg:generic/rules_proto_grpc@5.0.0" + purl: "pkg:bazel/rules_proto_grpc@5.0.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -574,7 +574,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_python:0.34.0" - purl: "pkg:generic/rules_python@0.34.0" + purl: "pkg:bazel/rules_python@0.34.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -600,7 +600,7 @@ packages: revision: "" path: "" - id: "Bazel::stardoc:0.5.3" - purl: "pkg:generic/stardoc@0.5.3" + purl: "pkg:bazel/stardoc@0.5.3" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -626,7 +626,7 @@ packages: revision: "" path: "" - id: "Bazel::toolchains_protoc:0.3.1" - purl: "pkg:generic/toolchains_protoc@0.3.1" + purl: "pkg:bazel/toolchains_protoc@0.3.1" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -652,7 +652,7 @@ packages: revision: "" path: "" - id: "Bazel::upb:0.0.0-20230516-61a97ef" - purl: "pkg:generic/upb@0.0.0-20230516-61a97ef" + purl: "pkg:bazel/upb@0.0.0-20230516-61a97ef" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -678,7 +678,7 @@ packages: revision: "" path: "" - id: "Bazel::zlib:1.3" - purl: "pkg:generic/zlib@1.3" + purl: "pkg:bazel/zlib@1.3" declared_licenses: [] declared_licenses_processed: {} description: "" diff --git a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-git-repository.yml b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-git-repository.yml index fc13431bed4dd..7d1d6a348f90c 100644 --- a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-git-repository.yml +++ b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-git-repository.yml @@ -24,7 +24,7 @@ project: linkage: "STATIC" packages: - id: "Bazel::module_c:0.0.1" - purl: "pkg:generic/module_c@0.0.1" + purl: "pkg:bazel/module_c@0.0.1" declared_licenses: [] declared_licenses_processed: {} description: "" diff --git a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-path-override.yml b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-path-override.yml index c05c7cde321f0..3ac7286ce26c8 100644 --- a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-path-override.yml +++ b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-path-override.yml @@ -29,7 +29,7 @@ project: linkage: "STATIC" packages: - id: "Bazel::gflags:2.2.2" - purl: "pkg:generic/gflags@2.2.2" + purl: "pkg:bazel/gflags@2.2.2" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -55,7 +55,7 @@ packages: revision: "" path: "" - id: "Bazel::glog:0.5.0" - purl: "pkg:generic/glog@0.5.0" + purl: "pkg:bazel/glog@0.5.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -81,7 +81,7 @@ packages: revision: "" path: "" - id: "Bazel::test_module:0.0.1" - purl: "pkg:generic/test_module@0.0.1" + purl: "pkg:bazel/test_module@0.0.1" declared_licenses: [] declared_licenses_processed: {} description: "" diff --git a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry-with-local-path.yml b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry-with-local-path.yml index d4f04e2fde784..d2ce8e943c9df 100644 --- a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry-with-local-path.yml +++ b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry-with-local-path.yml @@ -29,7 +29,7 @@ project: linkage: "STATIC" packages: - id: "Bazel::gflags:2.2.2" - purl: "pkg:generic/gflags@2.2.2" + purl: "pkg:bazel/gflags@2.2.2" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -55,7 +55,7 @@ packages: revision: "" path: "" - id: "Bazel::glog:0.5.0" - purl: "pkg:generic/glog@0.5.0" + purl: "pkg:bazel/glog@0.5.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -81,7 +81,7 @@ packages: revision: "" path: "" - id: "Bazel::test_module:0.0.1" - purl: "pkg:generic/test_module@0.0.1" + purl: "pkg:bazel/test_module@0.0.1" declared_licenses: [] declared_licenses_processed: {} description: "" diff --git a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry.yml b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry.yml index bea3bf16b6556..90869aeb001e2 100644 --- a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry.yml +++ b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry.yml @@ -29,7 +29,7 @@ project: linkage: "STATIC" packages: - id: "Bazel::gflags:2.2.2" - purl: "pkg:generic/gflags@2.2.2" + purl: "pkg:bazel/gflags@2.2.2" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -55,7 +55,7 @@ packages: revision: "" path: "" - id: "Bazel::glog:0.5.0" - purl: "pkg:generic/glog@0.5.0" + purl: "pkg:bazel/glog@0.5.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -81,7 +81,7 @@ packages: revision: "" path: "" - id: "Bazel::test_module:0.0.1" - purl: "pkg:generic/test_module@0.0.1" + purl: "pkg:bazel/test_module@0.0.1" declared_licenses: [] declared_licenses_processed: {} description: "" diff --git a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry2.yml b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry2.yml index 06ec9f122821f..ae5af2b1547f2 100644 --- a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry2.yml +++ b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry2.yml @@ -53,7 +53,7 @@ analyzer: linkage: "STATIC" packages: - id: "Bazel::module_a:0.0.1" - purl: "pkg:generic/module_a@0.0.1" + purl: "pkg:bazel/module_a@0.0.1" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -79,7 +79,7 @@ analyzer: revision: "" path: "" - id: "Bazel::module_b:0.0.1" - purl: "pkg:generic/module_b@0.0.1" + purl: "pkg:bazel/module_b@0.0.1" declared_licenses: [] declared_licenses_processed: {} description: "" diff --git a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-no-lock-file.yml b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-no-lock-file.yml index 0b5f7aa72718d..d65214e06ea8e 100644 --- a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-no-lock-file.yml +++ b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-no-lock-file.yml @@ -27,7 +27,7 @@ project: linkage: "STATIC" packages: - id: "Bazel::gflags:2.2.2" - purl: "pkg:generic/gflags@2.2.2" + purl: "pkg:bazel/gflags@2.2.2" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -53,7 +53,7 @@ packages: revision: "" path: "" - id: "Bazel::glog:0.5.0" - purl: "pkg:generic/glog@0.5.0" + purl: "pkg:bazel/glog@0.5.0" declared_licenses: [] declared_licenses_processed: {} description: "" diff --git a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output.yml b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output.yml index a15ed1fdf85eb..7aa152d3913b9 100644 --- a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output.yml +++ b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output.yml @@ -52,7 +52,7 @@ project: linkage: "STATIC" packages: - id: "Bazel::abseil-cpp:20230125.1" - purl: "pkg:generic/abseil-cpp@20230125.1" + purl: "pkg:bazel/abseil-cpp@20230125.1" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -78,7 +78,7 @@ packages: revision: "" path: "" - id: "Bazel::bazel_skylib:1.4.1" - purl: "pkg:generic/bazel_skylib@1.4.1" + purl: "pkg:bazel/bazel_skylib@1.4.1" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -104,7 +104,7 @@ packages: revision: "" path: "" - id: "Bazel::gflags:2.2.2" - purl: "pkg:generic/gflags@2.2.2" + purl: "pkg:bazel/gflags@2.2.2" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -130,7 +130,7 @@ packages: revision: "" path: "" - id: "Bazel::glog:0.5.0" - purl: "pkg:generic/glog@0.5.0" + purl: "pkg:bazel/glog@0.5.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -156,7 +156,7 @@ packages: revision: "" path: "" - id: "Bazel::googletest:1.14.0" - purl: "pkg:generic/googletest@1.14.0" + purl: "pkg:bazel/googletest@1.14.0" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -182,7 +182,7 @@ packages: revision: "" path: "" - id: "Bazel::platforms:0.0.7" - purl: "pkg:generic/platforms@0.0.7" + purl: "pkg:bazel/platforms@0.0.7" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -208,7 +208,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_cc:0.0.9" - purl: "pkg:generic/rules_cc@0.0.9" + purl: "pkg:bazel/rules_cc@0.0.9" declared_licenses: [] declared_licenses_processed: {} description: "" @@ -234,7 +234,7 @@ packages: revision: "" path: "" - id: "Bazel::rules_license:0.0.7" - purl: "pkg:generic/rules_license@0.0.7" + purl: "pkg:bazel/rules_license@0.0.7" declared_licenses: [] declared_licenses_processed: {} description: ""