2022-08-27 11:52:29 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Parsers
|
|
|
|
module Sbom
|
|
|
|
module Source
|
|
|
|
class DependencyScanning
|
|
|
|
REQUIRED_ATTRIBUTES = [
|
|
|
|
%w[input_file path]
|
|
|
|
].freeze
|
|
|
|
|
|
|
|
def self.source(...)
|
|
|
|
new(...).source
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(data)
|
|
|
|
@data = data
|
|
|
|
end
|
|
|
|
|
|
|
|
def source
|
|
|
|
return unless required_attributes_present?
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
::Gitlab::Ci::Reports::Sbom::Source.new(
|
|
|
|
type: :dependency_scanning,
|
2022-11-25 23:54:43 +05:30
|
|
|
data: data
|
2022-10-11 01:57:18 +05:30
|
|
|
)
|
2022-08-27 11:52:29 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :data
|
|
|
|
|
|
|
|
def required_attributes_present?
|
|
|
|
REQUIRED_ATTRIBUTES.all? do |keys|
|
|
|
|
data.dig(*keys).present?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|