Class: SupplyChain::Slsa::ProvenanceStatement
- Inherits:
-
Object
- Object
- SupplyChain::Slsa::ProvenanceStatement
- Includes:
- ActiveModel::Serializers::JSON, CamelCaseJson
- Defined in:
- app/models/supply_chain/slsa/provenance_statement.rb
Defined Under Namespace
Classes: BuildDefinition, BuildMetadata, Builder, ExternalParameters, Predicate, RunDetails
Constant Summary collapse
- PREDICATE_TYPE_V1 =
"https://slsa.dev/provenance/v1"
Instance Attribute Summary collapse
-
#_type ⇒ Object
Returns the value of attribute _type.
-
#predicate ⇒ Object
Returns the value of attribute predicate.
-
#predicate_type ⇒ Object
Returns the value of attribute predicate_type.
-
#subject ⇒ Object
Returns the value of attribute subject.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(options = nil) ⇒ Object
- #attributes ⇒ Object
-
#initialize ⇒ ProvenanceStatement
constructor
A new instance of ProvenanceStatement.
Methods included from CamelCaseJson
Constructor Details
#initialize ⇒ ProvenanceStatement
Returns a new instance of ProvenanceStatement.
43 44 45 46 |
# File 'app/models/supply_chain/slsa/provenance_statement.rb', line 43 def initialize @_type = "https://in-toto.io/Statement/v1" @predicate_type = PREDICATE_TYPE_V1 end |
Instance Attribute Details
#_type ⇒ Object
Returns the value of attribute _type.
25 26 27 |
# File 'app/models/supply_chain/slsa/provenance_statement.rb', line 25 def _type @_type end |
#predicate ⇒ Object
Returns the value of attribute predicate.
25 26 27 |
# File 'app/models/supply_chain/slsa/provenance_statement.rb', line 25 def predicate @predicate end |
#predicate_type ⇒ Object
Returns the value of attribute predicate_type.
25 26 27 |
# File 'app/models/supply_chain/slsa/provenance_statement.rb', line 25 def predicate_type @predicate_type end |
#subject ⇒ Object
Returns the value of attribute subject.
25 26 27 |
# File 'app/models/supply_chain/slsa/provenance_statement.rb', line 25 def subject @subject end |
Class Method Details
.from_build(build) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/supply_chain/slsa/provenance_statement.rb', line 29 def self.from_build(build) archives = build.job_artifacts.filter { |artifact| artifact.file_type == "archive" } raise ArgumentError, 'artifacts associated with build do not contain a single archive' if archives.length != 1 archive = archives[0] archive_resource = ResourceDescriptor.new(name: archive.file.filename, digest: { sha256: archive.file_sha256 }) provenance_statement = ProvenanceStatement.new provenance_statement.subject = [archive_resource] provenance_statement.predicate = Predicate.from_build(build) provenance_statement end |
Instance Method Details
#as_json(options = nil) ⇒ Object
48 49 50 |
# File 'app/models/supply_chain/slsa/provenance_statement.rb', line 48 def as_json( = nil) deep_change_case(super) end |
#attributes ⇒ Object
52 53 54 |
# File 'app/models/supply_chain/slsa/provenance_statement.rb', line 52 def attributes { '_type' => nil, 'subject' => nil, 'predicate_type' => nil, 'predicate' => nil } end |