CycloneDX/Composition.pm untested

filter: Statementstmt 0.0% 0 / 63 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 88 CC 6 SCAR 27.8
CC
6
Cov
0%
TO_JSON
42.0
BEGIN
2.0
BEGIN
2.0
CRAP 16.1
1 package SBOM::CycloneDX::Composition;
2  
3 use 5.010001;
4 use strict;
5 use warnings;
6 use utf8;
7  
8 use SBOM::CycloneDX::BomRef;
9 use SBOM::CycloneDX::Enum;
10 use SBOM::CycloneDX::List;
11  
12 use Types::Standard qw(Str Enum InstanceOf HashRef);
13 use Types::TypeTiny qw(ArrayLike);
14  
15 use Moo;
16 use namespace::autoclean;
17  
18 extends 'SBOM::CycloneDX::Base';
19  
20 has bom_ref => (
21 is => 'rw',
22 isa => InstanceOf ['SBOM::CycloneDX::BomRef'],
23 coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::BomRef->new($_[0]) }
24 );
25  
26 has aggregate => (is => 'rw', isa => Enum [SBOM::CycloneDX::Enum->values('AGGREGATE_TYPE')], required => 1);
27  
28 has assemblies => (
29 is => 'rw',
30 isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::BomRef']],
31 default => sub { SBOM::CycloneDX::List->new }
32 );
33  
34 has dependencies => (
35 is => 'rw',
36 isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::BomRef']],
37 default => sub { SBOM::CycloneDX::List->new }
38 );
39  
40 has vulnerabilities => (
41 is => 'rw',
42 isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::BomRef']],
43 default => sub { SBOM::CycloneDX::List->new }
44 );
45  
46 has signature => (is => 'rw', isa => HashRef);
47  
48 sub TO_JSON {
49  
50 my $self = shift;
51  
52 my $json = {aggregate => $self->aggregate};
53  
54 $json->{'bom-ref'} = $self->bom_ref if $self->bom_ref;
55 $json->{assemblies} = $self->assemblies if @{$self->assemblies};
56 $json->{dependencies} = $self->dependencies if @{$self->dependencies};
57 $json->{vulnerabilities} = $self->vulnerabilities if @{$self->vulnerabilities};
58 $json->{signature} = $self->signature if $self->signature;
59  
60 return $json;
61  
62 }
63  
64 1;
65  
66 =encoding utf-8
67  
68 =head1 NAME
69  
70 SBOM::CycloneDX::Composition - Composition
71  
72 =head1 SYNOPSIS
73  
74 SBOM::CycloneDX::Composition->new();
75  
76  
77 =head1 DESCRIPTION
78  
79 L<SBOM::CycloneDX::Composition> describe constituent parts (including components,
80 services, and dependency relationships) and their completeness. The completeness
81 of vulnerabilities expressed in a BOM may also be described.
82  
83 =head2 METHODS
84  
85 =over
86  
87 =item SBOM::CycloneDX::Composition->new( %PARAMS )
88  
89 Properties:
90  
91 =over
92  
93 =item * C<aggregate>, Specifies an aggregate type that describes how complete a
94 relationship is.
95  
96 =item * C<assemblies>, The bom-ref identifiers of the components or services being
97 described. Assemblies refer to nested relationships whereby a constituent part
98 may include other constituent parts. References do not cascade to child parts.
99 References are explicit for the specified constituent part only.
100  
101 =item * C<bom_ref>, An identifier which can be used to reference the composition
102 elsewhere in the BOM. Every C<bom-ref> must be unique within the BOM.
103  
104 Value SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid conflicts with BOM-Links.
105  
106 =item * C<dependencies>, The bom-ref identifiers of the components or services
107 being described. Dependencies refer to a relationship whereby an independent
108 constituent part requires another independent constituent part. References do
109 not cascade to transitive dependencies. References are explicit for the specified
110 dependency only.
111  
112 =item * C<signature>, Enveloped signature in JSON Signature Format
113 (JSF) (L<https://cyberphone.github.io/doc/security/jsf.html>).
114  
115 =item * C<vulnerabilities>, The bom-ref identifiers of the vulnerabilities being
116 described.
117  
118 =back
119  
120 =item $composition->aggregate
121  
122 =item $composition->assemblies
123  
124 =item $composition->bom_ref
125  
126 =item $composition->dependencies
127  
128 =item $composition->signature
129  
130 =item $composition->vulnerabilities
131  
132 =back
133  
134  
135 =head1 SUPPORT
136  
137 =head2 Bugs / Feature Requests
138  
139 Please report any bugs or feature requests through the issue tracker
140 at L<https://github.com/giterlizzi/perl-SBOM-CycloneDX/issues>.
141 You will be notified automatically of any progress on your issue.
142  
143 =head2 Source Code
144  
145 This is open source software. The code repository is available for
146 public review and contribution under the terms of the license.
147  
148 L<https://github.com/giterlizzi/perl-SBOM-CycloneDX>
149  
150 git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
151  
152  
153 =head1 AUTHOR
154  
155 =over 4
156  
157 =item * Giuseppe Di Terlizzi <gdt@cpan.org>
158  
159 =back
160  
161  
162 =head1 LICENSE AND COPYRIGHT
163  
164 This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
165  
166 This is free software; you can redistribute it and/or modify it under
167 the same terms as the Perl 5 programming language system itself.
168  
169 =cut