File Coverage

blib/lib/SBOM/CycloneDX/Formulation.pm
Criterion Covered Total %
statement 26 38 68.4
branch 0 10 0.0
condition n/a
subroutine 9 10 90.0
pod 1 1 100.0
total 36 59 61.0


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::Formulation;
2              
3 1     1   16449 use 5.010001;
  1         5  
4 1     1   7 use strict;
  1         4  
  1         31  
5 1     1   6 use warnings;
  1         3  
  1         85  
6 1     1   6 use utf8;
  1         3  
  1         13  
7              
8 1     1   75 use SBOM::CycloneDX::BomRef;
  1         3  
  1         51  
9              
10 1     1   5 use Types::Standard qw(Str InstanceOf);
  1         3  
  1         16  
11 1     1   4146 use Types::TypeTiny qw(ArrayLike);
  1         3  
  1         11  
12              
13 1     1   705 use Moo;
  1         3  
  1         13  
14 1     1   574 use namespace::autoclean;
  1         3  
  1         19  
15              
16             extends 'SBOM::CycloneDX::Base';
17              
18             has bom_ref => (
19             is => 'rw',
20             isa => InstanceOf ['SBOM::CycloneDX::BomRef'],
21             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::BomRef->new($_[0]) }
22             );
23              
24             has components => (
25             is => 'rw',
26             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Component']],
27             default => sub { SBOM::CycloneDX::List->new }
28             );
29              
30             has services => (
31             is => 'rw',
32             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Service']],
33             default => sub { SBOM::CycloneDX::List->new }
34             );
35              
36             has workflows => (
37             is => 'rw',
38             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Workflow']],
39             default => sub { SBOM::CycloneDX::List->new }
40             );
41              
42             has properties => (
43             is => 'rw',
44             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Property']],
45             default => sub { SBOM::CycloneDX::List->new }
46             );
47              
48             sub TO_JSON {
49              
50 0     0 1   my $self = shift;
51              
52 0           my $json = {};
53              
54 0 0         $json->{'bom-ref'} = $self->bom_ref if $self->bom_ref;
55 0 0         $json->{components} = $self->components if @{$self->components};
  0            
56 0 0         $json->{services} = $self->services if @{$self->services};
  0            
57 0 0         $json->{workflows} = $self->workflows if @{$self->workflows};
  0            
58 0 0         $json->{properties} = $self->properties if @{$self->properties};
  0            
59              
60 0           return $json;
61              
62             }
63              
64             1;
65              
66             =encoding utf-8
67              
68             =head1 NAME
69              
70             SBOM::CycloneDX::Formulation - Formula
71              
72             =head1 SYNOPSIS
73              
74             SBOM::CycloneDX::Formulation->new();
75              
76              
77             =head1 DESCRIPTION
78              
79             L describes the formulation of any referencable
80             object within the BOM, including components, services, metadata, declarations,
81             or the BOM itself. This may encompass how the object was created, assembled,
82             deployed, tested, certified, or otherwise brought into its present form. Common
83             examples include software build pipelines, deployment processes, AI/ML model
84             training, cryptographic key generation or certification, and third-party
85             audits. Processes are modeled using declared and observed formulas, composed of
86             workflows, tasks, and individual steps.
87              
88             =head2 METHODS
89              
90             L inherits all methods from L
91             and implements the following new ones.
92              
93             =over
94              
95             =item SBOM::CycloneDX::Formulation->new( %PARAMS )
96              
97             Properties:
98              
99             =over
100              
101             =item * C, An identifier which can be used to reference the
102             formula elsewhere in the BOM. Every bom-ref must be unique within the BOM.
103             Value SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid
104             conflicts with BOM-Links.
105              
106             =item * C, Transient components that are used in tasks that
107             constitute one or more of this formula's workflows
108              
109             =item * C, Provides the ability to document properties in a
110             name-value store. This provides flexibility to include data not officially
111             supported in the standard without having to use additional namespaces or
112             create extensions. Unlike key-value stores, properties support duplicate
113             names, each potentially having different values. Property names of interest
114             to the general public are encouraged to be registered in the CycloneDX
115             Property Taxonomy (L).
116             Formal registration is optional.
117              
118             =item * C, Transient services that are used in tasks that
119             constitute one or more of this formula's workflows
120              
121             =item * C, List of workflows that can be declared to accomplish
122             specific orchestrated goals and independently triggered.
123              
124             =back
125              
126             =item $formulation->bom_ref
127              
128             =item $formulation->components
129              
130             =item $formulation->properties
131              
132             =item $formulation->services
133              
134             =item $formulation->workflows
135              
136             =back
137              
138              
139             =head1 SUPPORT
140              
141             =head2 Bugs / Feature Requests
142              
143             Please report any bugs or feature requests through the issue tracker
144             at L.
145             You will be notified automatically of any progress on your issue.
146              
147             =head2 Source Code
148              
149             This is open source software. The code repository is available for
150             public review and contribution under the terms of the license.
151              
152             L
153              
154             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
155              
156              
157             =head1 AUTHOR
158              
159             =over 4
160              
161             =item * Giuseppe Di Terlizzi
162              
163             =back
164              
165              
166             =head1 LICENSE AND COPYRIGHT
167              
168             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
169              
170             This is free software; you can redistribute it and/or modify it under
171             the same terms as the Perl 5 programming language system itself.
172              
173             =cut