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.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/gitlab/ci/reports/sbom/component.rb b/lib/gitlab/ci/reports/sbom/component.rb
index 198b34451b4..5188304f4ed 100644
--- a/lib/gitlab/ci/reports/sbom/component.rb
+++ b/lib/gitlab/ci/reports/sbom/component.rb
@@ -7,11 +7,34 @@ module Gitlab
class Component
attr_reader :component_type, :name, :version
- def initialize(type:, name:, version:)
+ def initialize(type:, name:, purl:, version:)
@component_type = type
@name = name
+ @purl = purl
@version = version
end
+
+ def ingestible?
+ supported_component_type? && supported_purl_type?
+ end
+
+ def purl
+ return unless @purl
+
+ ::Sbom::PackageUrl.parse(@purl)
+ end
+
+ private
+
+ def supported_component_type?
+ ::Enums::Sbom.component_types.include?(component_type.to_sym)
+ end
+
+ def supported_purl_type?
+ return true unless purl
+
+ ::Enums::Sbom.purl_types.include?(purl.type.to_sym)
+ end
end
end
end