Class: Gitlab::Ci::Reports::Sbom::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/reports/sbom/report.rb

Constant Summary collapse

BOM_FORMAT =
'CycloneDX'
SPEC_VERSION =
'1.4'
VERSION =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReport

Returns a new instance of Report.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/ci/reports/sbom/report.rb', line 17

def initialize
  @sbom_attributes = {
    bom_format: BOM_FORMAT,
    spec_version: SPEC_VERSION,
    serial_number: "urn:uuid:#{SecureRandom.uuid}",
    version: VERSION
  }
  @components = []
  @metadata = ::Gitlab::Ci::Reports::Sbom::Metadata.new
  @errors = []
end

Instance Attribute Details

#componentsObject

Returns the value of attribute components.



15
16
17
# File 'lib/gitlab/ci/reports/sbom/report.rb', line 15

def components
  @components
end

#errorsObject (readonly)

Returns the value of attribute errors.



14
15
16
# File 'lib/gitlab/ci/reports/sbom/report.rb', line 14

def errors
  @errors
end

#metadataObject

Returns the value of attribute metadata.



15
16
17
# File 'lib/gitlab/ci/reports/sbom/report.rb', line 15

def 
  @metadata
end

#sbom_attributesObject

Returns the value of attribute sbom_attributes.



15
16
17
# File 'lib/gitlab/ci/reports/sbom/report.rb', line 15

def sbom_attributes
  @sbom_attributes
end

#sourceObject

Returns the value of attribute source.



14
15
16
# File 'lib/gitlab/ci/reports/sbom/report.rb', line 14

def source
  @source
end

Instance Method Details

#add_component(component) ⇒ Object



41
42
43
# File 'lib/gitlab/ci/reports/sbom/report.rb', line 41

def add_component(component)
  components << component
end

#add_error(error) ⇒ Object



33
34
35
# File 'lib/gitlab/ci/reports/sbom/report.rb', line 33

def add_error(error)
  errors << error
end

#set_source(source) ⇒ Object



37
38
39
# File 'lib/gitlab/ci/reports/sbom/report.rb', line 37

def set_source(source)
  self.source = source
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  errors.empty?
end