CycloneDX/Metadata.pm

filter: Statementstmt 97.2% 70 / 72 Branchbran 58.3% 14 / 24 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 94.7% 18 / 19 Podpod 50.0% 1 / 2 totaltotal 83.3% 105 / 126 CC 15 SCAR 20.0
CC
15
Cov
84%
TO_JSON
16.2
__ANON__
6.0
BUILD
2.1
CRAP 7.4
« CycloneDX/Version.pm ↑ Summary CycloneDX/Vulnerability/ProofOfConcept.pm »
1 package SBOM::CycloneDX::Metadata;
2  
3 16 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 16 ▶use SBOM::CycloneDX::Timestamp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 16 ▶use SBOM::CycloneDX::List;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 16 ▶use Types::Standard qw(Str InstanceOf);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 16 ▶use Types::TypeTiny qw(ArrayLike);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 16 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 16 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 16 extends 'SBOM::CycloneDX::Base';
20  
21 57 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=7.2
Pod undocumented
22 57 my ($self, $args) = @_;
23 Carp::carp '"manufacture" is deprecated from CycloneDX v1.6. '
24 . 'Use the SBOM::CycloneDX::Component->manufacturer instead'
25 57 ▶ if exists $args->{manufacture};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"manufacture"} 0 57 57
26 }
27  
28  
29 has timestamp => (
30 is => 'rw',
31 isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
32 0 ▶ coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
33 16 );
34  
35 has lifecycles => (
36 is => 'rw',
37 isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Metadata::Lifecycle']],
38 57 ▶ default => sub { SBOM::CycloneDX::List->new }
Subroutine __ANON__: called CC=1 SCAR=0.0
39 16 );
40  
41 # TODO: metadata.tools[] array is DEPRECATED
42  
43 has tools => (
44 is => 'rw',
45 isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Tool']] | InstanceOf ['SBOM::CycloneDX::Tools'],
46 57 ▶ default => sub { SBOM::CycloneDX::List->new }
Subroutine __ANON__: called CC=1 SCAR=0.0
47 16 );
48  
49 16 has manufacturer => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::OrganizationalEntity']);
50  
51 has authors => (
52 is => 'rw',
53 isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::OrganizationalContact']],
54 57 ▶ default => sub { SBOM::CycloneDX::List->new }
Subroutine __ANON__: called CC=1 SCAR=0.0
55 16 );
56  
57 16 has component => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::Component']);
58 16 has manufacture => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::OrganizationalEntity']);
59 16 has supplier => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::OrganizationalEntity']);
60  
61 has licenses => (
62 is => 'rw',
63 isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::License']],
64 57 ▶ default => sub { SBOM::CycloneDX::List->new }
Subroutine __ANON__: called CC=1 SCAR=0.0
65 16 );
66  
67 has properties => (
68 is => 'rw',
69 isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Property']],
70 57 ▶ default => sub { SBOM::CycloneDX::List->new }
Subroutine __ANON__: called CC=1 SCAR=0.0
71 16 );
72  
73 16 has distribution_constraints => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::Metadata::DistributionConstraint']);
74  
75 190 ▶sub TO_JSON {
Subroutine TO_JSON: called CC=13 SCAR=27.9
Pod documented
76  
77 190 my $self = shift;
78  
79 190 my $json = {};
80  
81 190 ▶ if (ref($self->tools) =~ /List/ && @{$self->tools} || ref($self->tools) =~ /Tools/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($self->tools) =~ /List/ and @{$self->tools;} or ref($self->tools) =~ /Tools/) 0 190 190
Condition33%2/6
ref($self->tools) =~ /List/ and @{$self->tools;} or ref($self->tools) =~ /Tools/
l!l&&r!l&&!r
00190
ref($self->tools) =~ /List/ and @{$self->tools;}
!ll&&!rl&&r
01900
MC/DC0%0/3
ref($self->tools) =~ /List/ and @{$self->tools;} or ref($self->tools) =~ /Tools/
ref($self->tools) =~ /List/ @{$self->tools;} ref($self->tools) =~ /Tools/
Truth table20%1/5
A and B or C
A= ref($self->tools) =~ /List/B= @{$self->tools;}C= ref($self->tools) =~ /Tools/
ABCresult
11X1
0X11
1011
0X00
1000
82 0 $json->{tools} = $self->tools;
83 }
84  
85 190 ▶ $json->{timestamp} = $self->timestamp if $self->timestamp;
Branch: 1 branch
BranchTrueFalseTotal
if $self->timestamp 0 190 190
86 190 ▶ $json->{lifecycles} = $self->lifecycles if @{$self->lifecycles};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->lifecycles;} 18 172 190
87 190 ▶ $json->{authors} = $self->authors if @{$self->authors};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->authors;} 36 154 190
88 190 ▶ $json->{component} = $self->component if $self->component;
Branch: 1 branch
BranchTrueFalseTotal
if $self->component 0 190 190
89 190 ▶ $json->{manufacture} = $self->manufacture if $self->manufacture;
Branch: 1 branch
BranchTrueFalseTotal
if $self->manufacture 0 190 190
90 190 ▶ $json->{supplier} = $self->supplier if $self->supplier;
Branch: 1 branch
BranchTrueFalseTotal
if $self->supplier 0 190 190
91 190 ▶ $json->{licenses} = $self->licenses if @{$self->licenses};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->licenses;} 50 140 190
92 190 ▶ $json->{properties} = $self->properties if @{$self->properties};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->properties;} 0 190 190
93 190 ▶ $json->{distributionConstraints} = $self->distribution_constraints if $self->distribution_constraints;
Branch: 1 branch
BranchTrueFalseTotal
if $self->distribution_constraints 0 190 190
94  
95 190 return $json;
96  
97 }
98  
99 16 1;
100  
101 =encoding utf-8
102  
103 =head1 NAME
104  
105 SBOM::CycloneDX::Metadata - BOM Metadata
106  
107 =head1 SYNOPSIS
108  
109 SBOM::CycloneDX::Metadata->new();
110  
111  
112 =head1 DESCRIPTION
113  
114 L<SBOM::CycloneDX::Metadata> provides additional information about a BOM.
115  
116 =head2 METHODS
117  
118 L<SBOM::CycloneDX::Metadata> inherits all methods from L<SBOM::CycloneDX::Base>
119 and implements the following new ones.
120  
121 =over
122  
123 =item SBOM::CycloneDX::Metadata->new( %PARAMS )
124  
125 Properties:
126  
127 =over
128  
129 =item * C<authors>, The person(s) who created the BOM.
130 Authors are common in BOMs created through manual processes. BOMs created
131 through automated means may have "manufacturer" instead.
132  
133 =item * C<component>, The component that the BOM describes.
134  
135 =item * C<licenses>, The license information for the BOM document.
136 This may be different from the license(s) of the component(s) that the BOM
137 describes.
138  
139 =item * C<lifecycles>, Lifecycles communicate the stage(s) in which data in
140 the BOM was captured. Different types of data may be available at various
141 phases of a lifecycle, such as the Software Development Lifecycle (SDLC),
142 IT Asset Management (ITAM), and Software Asset Management (SAM). Thus, a
143 BOM may include data specific to or only obtainable in a given lifecycle.
144  
145 =item * C<manufacture>, [Deprecated in 1.6] This will be removed in a future
146 version. Use the "manufacturer" method in L<SBOM::CycloneDX::Component> instead.
147 The organization that manufactured the component that the BOM describes.
148  
149 =item * C<manufacturer>, The organization that created the BOM.
150 Manufacturer is common in BOMs created through automated processes. BOMs
151 created through manual means may have `@.authors` instead.
152  
153 =item * C<properties>, Provides the ability to document properties in a
154 name-value store. This provides flexibility to include data not officially
155 supported in the standard without having to use additional namespaces or
156 create extensions. Unlike key-value stores, properties support duplicate
157 names, each potentially having different values. Property names of interest
158 to the general public are encouraged to be registered in the CycloneDX
159 Property Taxonomy (L<https://github.com/CycloneDX/cyclonedx-property-taxonomy>).
160 Formal registration is optional.
161  
162 =item * C<supplier>, The organization that supplied the component that the
163 BOM describes. The supplier may often be the manufacturer, but may also be
164 a distributor or repackager.
165  
166 =item * C<timestamp>, The date and time (timestamp) when the BOM was created.
167  
168 =item * C<tools>, The tool(s) used in the creation, enrichment, and
169 validation of the BOM.
170  
171 =back
172  
173 =item $metadata->authors
174  
175 =item $metadata->component
176  
177 =item $metadata->licenses
178  
179 =item $metadata->lifecycles
180  
181 =item $metadata->manufacture
182  
183 =item $metadata->manufacturer
184  
185 =item $metadata->properties
186  
187 =item $metadata->supplier
188  
189 =item $metadata->timestamp
190  
191 =item $metadata->tools
192  
193 =back
194  
195  
196 =head1 SUPPORT
197  
198 =head2 Bugs / Feature Requests
199  
200 Please report any bugs or feature requests through the issue tracker
201 at L<https://github.com/giterlizzi/perl-SBOM-CycloneDX/issues>.
202 You will be notified automatically of any progress on your issue.
203  
204 =head2 Source Code
205  
206 This is open source software. The code repository is available for
207 public review and contribution under the terms of the license.
208  
209 L<https://github.com/giterlizzi/perl-SBOM-CycloneDX>
210  
211 git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
212  
213  
214 =head1 AUTHOR
215  
216 =over 4
217  
218 =item * Giuseppe Di Terlizzi <gdt@cpan.org>
219  
220 =back
221  
222  
223 =head1 LICENSE AND COPYRIGHT
224  
225 This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
226  
227 This is free software; you can redistribute it and/or modify it under
228 the same terms as the Perl 5 programming language system itself.
229  
230 =cut
« CycloneDX/Version.pm ↑ Summary CycloneDX/Vulnerability/ProofOfConcept.pm »