Class: Gitlab::Ci::Reports::Sbom::Component

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/ci/reports/sbom/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, name:, purl:, version:) ⇒ Component

Returns a new instance of Component.



12
13
14
15
16
17
# File 'lib/gitlab/ci/reports/sbom/component.rb', line 12

def initialize(type:, name:, purl:, version:)
  @component_type = type
  @name = name
  @raw_purl = purl
  @version = version
end

Instance Attribute Details

#component_typeObject (readonly)

Returns the value of attribute component_type.



10
11
12
# File 'lib/gitlab/ci/reports/sbom/component.rb', line 10

def component_type
  @component_type
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/gitlab/ci/reports/sbom/component.rb', line 10

def path
  @path
end

#versionObject (readonly)

Returns the value of attribute version.



10
11
12
# File 'lib/gitlab/ci/reports/sbom/component.rb', line 10

def version
  @version
end

Instance Method Details

#<=>(other) ⇒ Object



19
20
21
# File 'lib/gitlab/ci/reports/sbom/component.rb', line 19

def <=>(other)
  sort_by_attributes(self) <=> sort_by_attributes(other)
end

#ingestible?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/gitlab/ci/reports/sbom/component.rb', line 23

def ingestible?
  supported_component_type? && supported_purl_type?
end

#keyObject



48
49
50
# File 'lib/gitlab/ci/reports/sbom/component.rb', line 48

def key
  [name, version, purl&.type]
end

#nameObject



42
43
44
45
46
# File 'lib/gitlab/ci/reports/sbom/component.rb', line 42

def name
  return @name unless purl

  [purl.namespace, purl.name].compact.join('/')
end

#purlObject



27
28
29
30
31
# File 'lib/gitlab/ci/reports/sbom/component.rb', line 27

def purl
  return unless @raw_purl

  ::Sbom::PackageUrl.parse(@raw_purl)
end

#purl_typeObject



34
35
36
# File 'lib/gitlab/ci/reports/sbom/component.rb', line 34

def purl_type
  purl.type
end

#typeObject



38
39
40
# File 'lib/gitlab/ci/reports/sbom/component.rb', line 38

def type
  component_type
end