From b6e89f1c7406af737933b4aff09167a724d8fc03 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Wed, 31 Jul 2024 15:23:59 +0200 Subject: [PATCH 1/7] Add `bazel` type for Bazel modules --- PURL-TYPES.rst | 23 ++++++++++++ test-suite-data.json | 84 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) diff --git a/PURL-TYPES.rst b/PURL-TYPES.rst index 64a1342..f281261 100644 --- a/PURL-TYPES.rst +++ b/PURL-TYPES.rst @@ -59,6 +59,29 @@ apk pkg:apk/alpine/curl@7.83.0-r0?arch=x86 pkg:apk/alpine/apk@2.12.9-r3?arch=x86 +bazel +----- +``bazel`` for Bazel modules: + +- The default repository ("registry") is ``https://bcr.bazel.build``, the + Bazel Central Registry (BCR). +- The ``name`` is the module name. It must be lowercased. +- The ``version`` is the module version in `Bazel's relaxed semver format + `_. +- The optional ``repository_url`` can be used to specify the URL of an + alternative registry, with any trailing forward slashes removed. +- The optional ``subpath`` can name a particular Bazel target in the module via + a label with the leading double slash (``//``) removed and canonicalized by + omitting the target name if it is equal to the name of the containing package. +- Examples:: + + pkg:bazel/rules_java@7.8.0 + pkg:bazel/curl@8.8.0.bcr.1 + pkg:bazel/curl@8.8.0?repository_url=https://example.org/bazel-registry + pkg:bazel/rules_java@7.8.0 + pkg:bazel/rules_java@7.8.0#toolchains:singlejar + pkg:bazel/rules_go@0.48.0#go + bitbucket --------- ``bitbucket`` for Bitbucket-based packages: diff --git a/test-suite-data.json b/test-suite-data.json index 689741a..dffa8d3 100644 --- a/test-suite-data.json +++ b/test-suite-data.json @@ -622,5 +622,89 @@ "qualifiers": null, "subpath": null, "is_invalid": false + }, + { + "description": "bazel module with default registry", + "purl": "pkg:bazel/rules_java@7.8.0?registry_url=https://bcr.bazel.build/", + "canonical_purl": "pkg:bazel/rules_java@7.8.0", + "type": "bazel", + "namespace": null, + "name": "rules_java", + "version": "7.8.0", + "qualifiers": null, + "subpath": null, + "is_invalid": false + }, + { + "description": "bazel module with custom registry", + "purl": "pkg:bazel/rules_java@7.8.0?registry_url=https://example.org/bazel-registry/", + "canonical_purl": "pkg:bazel/rules_java@7.8.0?registry_url=https://example.org/bazel-registry", + "type": "bazel", + "namespace": null, + "name": "rules_java", + "version": "7.8.0", + "qualifiers": null, + "subpath": null, + "is_invalid": false + }, + { + "description": "bazel module with relaxed semver version", + "purl": "pkg:bazel/curl@8.8.0.bcr.1", + "canonical_purl": "pkg:bazel/curl@8.8.0.bcr.1", + "type": "bazel", + "namespace": null, + "name": "curl", + "version": "8.8.0.bcr.1", + "qualifiers": null, + "subpath": null, + "is_invalid": false + }, + { + "description": "bazel module names are lowercased", + "purl": "pkg:bazel/Curl@8.8.0.bcr.1", + "canonical_purl": "pkg:bazel/Curl@8.8.0.bcr.1", + "type": "bazel", + "namespace": null, + "name": "curl", + "version": "8.8.0.bcr.1", + "qualifiers": null, + "subpath": null, + "is_invalid": true + }, + { + "description": "bazel module with target", + "purl": "pkg:bazel/rules_java@7.8.0#//toolchains:singlejar", + "canonical_purl": "pkg:bazel/rules_java@7.8.0#toolchains:singlejar", + "type": "bazel", + "namespace": null, + "name": "rules_java", + "version": "7.8.0", + "qualifiers": null, + "subpath": "toolchains:singlejar", + "is_invalid": false + }, + { + "description": "bazel module with target in short-hand form", + "purl": "pkg:bazel/rules_go@0.48.0#//go:go", + "canonical_purl": "pkg:bazel/rules_go@0.48.0#go", + "type": "bazel", + "namespace": null, + "name": "rules_go", + "version": "0.48.0", + "qualifiers": null, + "subpath": "go", + "is_invalid": false + }, + { + "description": "bazel module with top-level target", + "purl": "pkg:bazel/rules_go@0.48.0#//:stdlib", + "canonical_purl": "pkg:bazel/rules_go@0.48.0#:stdlib", + "type": "bazel", + "namespace": null, + "name": "rules_go", + "version": "0.48.0", + "qualifiers": null, + "subpath": ":stdlib", + "is_invalid": false } ] From 77e5c49a14299bb37ea9defaa1553092578c8787 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Fri, 22 Nov 2024 12:57:27 +0100 Subject: [PATCH 2/7] Drop `registry_url` normalization --- PURL-TYPES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PURL-TYPES.rst b/PURL-TYPES.rst index f281261..e207ae0 100644 --- a/PURL-TYPES.rst +++ b/PURL-TYPES.rst @@ -69,7 +69,7 @@ bazel - The ``version`` is the module version in `Bazel's relaxed semver format `_. - The optional ``repository_url`` can be used to specify the URL of an - alternative registry, with any trailing forward slashes removed. + alternative registry. - The optional ``subpath`` can name a particular Bazel target in the module via a label with the leading double slash (``//``) removed and canonicalized by omitting the target name if it is equal to the name of the containing package. From 8bebbba379684e582a4d19c964a4a05b0c3d826a Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Fri, 22 Nov 2024 13:09:37 +0100 Subject: [PATCH 3/7] Simplify subpath spec --- PURL-TYPES.rst | 7 +++---- test-suite-data.json | 26 +++++++------------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/PURL-TYPES.rst b/PURL-TYPES.rst index e207ae0..e0776da 100644 --- a/PURL-TYPES.rst +++ b/PURL-TYPES.rst @@ -70,16 +70,15 @@ bazel `_. - The optional ``repository_url`` can be used to specify the URL of an alternative registry. -- The optional ``subpath`` can name a particular Bazel target in the module via - a label with the leading double slash (``//``) removed and canonicalized by - omitting the target name if it is equal to the name of the containing package. +- The optional ``subpath`` can refer to a particular Bazel package in the + module. - Examples:: pkg:bazel/rules_java@7.8.0 pkg:bazel/curl@8.8.0.bcr.1 pkg:bazel/curl@8.8.0?repository_url=https://example.org/bazel-registry pkg:bazel/rules_java@7.8.0 - pkg:bazel/rules_java@7.8.0#toolchains:singlejar + pkg:bazel/rules_java@8.5.0#java/runfiles pkg:bazel/rules_go@0.48.0#go bitbucket diff --git a/test-suite-data.json b/test-suite-data.json index dffa8d3..d11d4f0 100644 --- a/test-suite-data.json +++ b/test-suite-data.json @@ -672,20 +672,20 @@ "is_invalid": true }, { - "description": "bazel module with target", - "purl": "pkg:bazel/rules_java@7.8.0#//toolchains:singlejar", - "canonical_purl": "pkg:bazel/rules_java@7.8.0#toolchains:singlejar", + "description": "bazel module with multi-segment package", + "purl": "pkg:bazel/rules_java@8.5.0#java/runfiles", + "canonical_purl": "pkg:bazel/rules_java@8.5.0#java/runfiles", "type": "bazel", "namespace": null, "name": "rules_java", - "version": "7.8.0", + "version": "8.5.0", "qualifiers": null, - "subpath": "toolchains:singlejar", + "subpath": "java/runfiles", "is_invalid": false }, { - "description": "bazel module with target in short-hand form", - "purl": "pkg:bazel/rules_go@0.48.0#//go:go", + "description": "bazel module with single-segment package", + "purl": "pkg:bazel/rules_go@0.48.0#go", "canonical_purl": "pkg:bazel/rules_go@0.48.0#go", "type": "bazel", "namespace": null, @@ -694,17 +694,5 @@ "qualifiers": null, "subpath": "go", "is_invalid": false - }, - { - "description": "bazel module with top-level target", - "purl": "pkg:bazel/rules_go@0.48.0#//:stdlib", - "canonical_purl": "pkg:bazel/rules_go@0.48.0#:stdlib", - "type": "bazel", - "namespace": null, - "name": "rules_go", - "version": "0.48.0", - "qualifiers": null, - "subpath": ":stdlib", - "is_invalid": false } ] From 37ec02ae98c08a947f9e867952e3907c8d74741d Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Mon, 27 Jan 2025 15:01:39 +0100 Subject: [PATCH 4/7] Apply suggestions from code review Co-authored-by: Philippe Ombredanne --- PURL-TYPES.rst | 5 ++--- test-suite-data.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/PURL-TYPES.rst b/PURL-TYPES.rst index e0776da..bb9b391 100644 --- a/PURL-TYPES.rst +++ b/PURL-TYPES.rst @@ -61,10 +61,9 @@ apk bazel ----- -``bazel`` for Bazel modules: +``bazel`` for Bazel modules as specified at ``https://bazel.build/external/module``: -- The default repository ("registry") is ``https://bcr.bazel.build``, the - Bazel Central Registry (BCR). +- The default repository is the Bazel Central Registry (BCR) ``https://bcr.bazel.build``. - The ``name`` is the module name. It must be lowercased. - The ``version`` is the module version in `Bazel's relaxed semver format `_. diff --git a/test-suite-data.json b/test-suite-data.json index d11d4f0..fb614c6 100644 --- a/test-suite-data.json +++ b/test-suite-data.json @@ -662,7 +662,7 @@ { "description": "bazel module names are lowercased", "purl": "pkg:bazel/Curl@8.8.0.bcr.1", - "canonical_purl": "pkg:bazel/Curl@8.8.0.bcr.1", + "canonical_purl": "pkg:bazel/curl@8.8.0.bcr.1", "type": "bazel", "namespace": null, "name": "curl", From 2e2269c9cdc18c6beb5e20d8cde60626b16bb033 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Tue, 28 Jan 2025 11:47:28 +0100 Subject: [PATCH 5/7] Drop validation --- PURL-TYPES.rst | 2 +- test-suite-data.json | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/PURL-TYPES.rst b/PURL-TYPES.rst index bb9b391..6fbc681 100644 --- a/PURL-TYPES.rst +++ b/PURL-TYPES.rst @@ -64,7 +64,7 @@ bazel ``bazel`` for Bazel modules as specified at ``https://bazel.build/external/module``: - The default repository is the Bazel Central Registry (BCR) ``https://bcr.bazel.build``. -- The ``name`` is the module name. It must be lowercased. +- The ``name`` is the module name. - The ``version`` is the module version in `Bazel's relaxed semver format `_. - The optional ``repository_url`` can be used to specify the URL of an diff --git a/test-suite-data.json b/test-suite-data.json index fb614c6..55a9689 100644 --- a/test-suite-data.json +++ b/test-suite-data.json @@ -659,18 +659,6 @@ "subpath": null, "is_invalid": false }, - { - "description": "bazel module names are lowercased", - "purl": "pkg:bazel/Curl@8.8.0.bcr.1", - "canonical_purl": "pkg:bazel/curl@8.8.0.bcr.1", - "type": "bazel", - "namespace": null, - "name": "curl", - "version": "8.8.0.bcr.1", - "qualifiers": null, - "subpath": null, - "is_invalid": true - }, { "description": "bazel module with multi-segment package", "purl": "pkg:bazel/rules_java@8.5.0#java/runfiles", From 44c1d6abfd052e45e7c75cb2ae304b7c44fa1645 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Tue, 28 Jan 2025 14:12:53 +0100 Subject: [PATCH 6/7] Add test --- test-suite-data.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test-suite-data.json b/test-suite-data.json index 55a9689..ee2b23c 100644 --- a/test-suite-data.json +++ b/test-suite-data.json @@ -659,6 +659,18 @@ "subpath": null, "is_invalid": false }, + { + "description": "bazel module names are currently all lowercased, but this is not enforced by the PURL type spec", + "purl": "pkg:bazel/Curl@8.8.0.bcr.1", + "canonical_purl": "pkg:bazel/Curl@8.8.0.bcr.1", + "type": "bazel", + "namespace": null, + "name": "Curl", + "version": "8.8.0.bcr.1", + "qualifiers": null, + "subpath": null, + "is_invalid": false + }, { "description": "bazel module with multi-segment package", "purl": "pkg:bazel/rules_java@8.5.0#java/runfiles", From 9741aebc5865596720ad9f69757f043532841c04 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Tue, 28 Jan 2025 15:46:01 +0100 Subject: [PATCH 7/7] Update test-suite-data.json Co-authored-by: Jan Kowalleck --- test-suite-data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-suite-data.json b/test-suite-data.json index ee2b23c..72c7def 100644 --- a/test-suite-data.json +++ b/test-suite-data.json @@ -660,7 +660,7 @@ "is_invalid": false }, { - "description": "bazel module names are currently all lowercased, but this is not enforced by the PURL type spec", + "description": "bazel module names are actually all lowercased, but this is not enforced by the PURL type spec for reasons", "purl": "pkg:bazel/Curl@8.8.0.bcr.1", "canonical_purl": "pkg:bazel/Curl@8.8.0.bcr.1", "type": "bazel",