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/parsers/sbom')
-rw-r--r--lib/gitlab/ci/parsers/sbom/cyclonedx.rb14
-rw-r--r--lib/gitlab/ci/parsers/sbom/source/dependency_scanning.rb10
2 files changed, 15 insertions, 9 deletions
diff --git a/lib/gitlab/ci/parsers/sbom/cyclonedx.rb b/lib/gitlab/ci/parsers/sbom/cyclonedx.rb
index deb20a2138c..aa594ca4049 100644
--- a/lib/gitlab/ci/parsers/sbom/cyclonedx.rb
+++ b/lib/gitlab/ci/parsers/sbom/cyclonedx.rb
@@ -6,7 +6,6 @@ module Gitlab
module Sbom
class Cyclonedx
SUPPORTED_SPEC_VERSIONS = %w[1.4].freeze
- COMPONENT_ATTRIBUTES = %w[type name version].freeze
def parse!(blob, sbom_report)
@report = sbom_report
@@ -62,10 +61,17 @@ module Gitlab
end
def parse_components
- data['components']&.each do |component|
- next unless supported_component_type?(component['type'])
+ data['components']&.each do |component_data|
+ type = component_data['type']
+ next unless supported_component_type?(type)
- report.add_component(component.slice(*COMPONENT_ATTRIBUTES))
+ component = ::Gitlab::Ci::Reports::Sbom::Component.new(
+ type: type,
+ name: component_data['name'],
+ version: component_data['version']
+ )
+
+ report.add_component(component)
end
end
diff --git a/lib/gitlab/ci/parsers/sbom/source/dependency_scanning.rb b/lib/gitlab/ci/parsers/sbom/source/dependency_scanning.rb
index ad04b3257f9..00ca723b258 100644
--- a/lib/gitlab/ci/parsers/sbom/source/dependency_scanning.rb
+++ b/lib/gitlab/ci/parsers/sbom/source/dependency_scanning.rb
@@ -21,11 +21,11 @@ module Gitlab
def source
return unless required_attributes_present?
- {
- 'type' => :dependency_scanning,
- 'data' => data,
- 'fingerprint' => fingerprint
- }
+ ::Gitlab::Ci::Reports::Sbom::Source.new(
+ type: :dependency_scanning,
+ data: data,
+ fingerprint: fingerprint
+ )
end
private