Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/reports/sbom/component.rb')
-rw-r--r--lib/gitlab/ci/reports/sbom/component.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/gitlab/ci/reports/sbom/component.rb b/lib/gitlab/ci/reports/sbom/component.rb
index a516f4d02f1..51fd6af7bc4 100644
--- a/lib/gitlab/ci/reports/sbom/component.rb
+++ b/lib/gitlab/ci/reports/sbom/component.rb
@@ -5,12 +5,14 @@ module Gitlab
module Reports
module Sbom
class Component
- attr_reader :component_type, :name, :version
+ include Gitlab::Utils::StrongMemoize
+
+ attr_reader :component_type, :version
def initialize(type:, name:, purl:, version:)
@component_type = type
@name = name
- @purl = purl
+ @raw_purl = purl
@version = version
end
@@ -23,9 +25,16 @@ module Gitlab
end
def purl
- return unless @purl
+ return unless @raw_purl
+
+ ::Sbom::PackageUrl.parse(@raw_purl)
+ end
+ strong_memoize_attr :purl
+
+ def name
+ return @name unless purl
- ::Sbom::PackageUrl.parse(@purl)
+ [purl.namespace, purl.name].compact.join('/')
end
private