File Coverage

blib/lib/SBOM/CycloneDX/Service.pm
Criterion Covered Total %
statement 29 59 49.1
branch 0 36 0.0
condition n/a
subroutine 10 11 90.9
pod 1 1 100.0
total 40 107 37.3


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::Service;
2              
3 1     1   2149 use 5.010001;
  1         4  
4 1     1   9 use strict;
  1         2  
  1         25  
5 1     1   3 use warnings;
  1         2  
  1         63  
6 1     1   4 use utf8;
  1         2  
  1         10  
7              
8 1     1   53 use SBOM::CycloneDX::BomRef;
  1         2  
  1         40  
9 1     1   8 use SBOM::CycloneDX::List;
  1         3  
  1         73  
10              
11 1     1   5 use Types::Standard qw(Str Bool InstanceOf HashRef);
  1         2  
  1         10  
12 1     1   3188 use Types::TypeTiny qw(ArrayLike);
  1         5  
  1         11  
13              
14 1     1   476 use Moo;
  1         3  
  1         15  
15 1     1   638 use namespace::autoclean;
  1         5  
  1         17  
16              
17             extends 'SBOM::CycloneDX::Base';
18              
19             has bom_ref => (
20             is => 'rw',
21             isa => InstanceOf ['SBOM::CycloneDX::BomRef'],
22             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::BomRef->new($_[0]) }
23             );
24              
25             has provider => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::OrganizationalEntity']);
26             has group => (is => 'rw', isa => Str);
27             has name => (is => 'rw', isa => Str, required => 1);
28             has version => (is => 'rw', isa => Str);
29             has description => (is => 'rw', isa => Str);
30             has endpoints => (is => 'rw', isa => Str);
31             has authenticated => (is => 'rw', isa => Bool);
32             has x_trust_boundary => (is => 'rw', isa => Bool);
33             has trust_zone => (is => 'rw', isa => Str);
34             has data => (is => 'rw', isa => ArrayLike [Str]);
35              
36             has licenses => (
37             is => 'rw',
38             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::License']],
39             default => sub { SBOM::CycloneDX::List->new }
40             );
41              
42             has patent_assertions => (
43             is => 'rw',
44             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::PatentAssertion']],
45             default => sub { SBOM::CycloneDX::List->new }
46             );
47              
48             has external_references => (
49             is => 'rw',
50             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::ExternalReference']],
51             default => sub { SBOM::CycloneDX::List->new }
52             );
53              
54             has services => (
55             is => 'rw',
56             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Service']],
57             default => sub { SBOM::CycloneDX::List->new }
58             );
59              
60             has release_notes => (is => 'rw', isa => Str);
61              
62             has properties => (
63             is => 'rw',
64             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Property']],
65             default => sub { SBOM::CycloneDX::List->new }
66             );
67              
68             has tags => (is => 'rw', isa => ArrayLike [Str]);
69             has signature => (is => 'rw', isa => ArrayLike [HashRef]);
70              
71              
72             sub TO_JSON {
73              
74 0     0 1   my $self = shift;
75              
76 0           my $json = {name => $self->name};
77              
78 0 0         $json->{'bom-ref'} = $self->bom_ref if $self->bom_ref;
79 0 0         $json->{provider} = $self->provider if $self->provider;
80 0 0         $json->{group} = $self->group if $self->group;
81 0 0         $json->{version} = $self->version if $self->version;
82 0 0         $json->{description} = $self->description if $self->description;
83 0 0         $json->{endpoints} = $self->endpoints if @{$self->endpoints};
  0            
84 0 0         $json->{authenticated} = $self->authenticated if $self->authenticated;
85 0 0         $json->{'x-trust-boundary'} = $self->x_trust_boundary if $self->x_trust_boundary;
86 0 0         $json->{trustZone} = $self->trust_zone if $self->trust_zone;
87 0 0         $json->{data} = $self->data if @{$self->data};
  0            
88 0 0         $json->{patentAssertions} = $self->patent_assertions if @{$self->patent_assertions};
  0            
89 0 0         $json->{licenses} = $self->licenses if @{$self->licenses};
  0            
90 0 0         $json->{externalReferences} = $self->external_references if @{$self->external_references};
  0            
91 0 0         $json->{services} = $self->services if @{$self->services};
  0            
92 0 0         $json->{releaseNotes} = $self->release_notes if $self->release_notes;
93 0 0         $json->{properties} = $self->properties if @{$self->properties};
  0            
94 0 0         $json->{tags} = $self->tags if @{$self->tags};
  0            
95 0 0         $json->{signature} = $self->signature if @{$self->signature};
  0            
96              
97 0           return $json;
98              
99             }
100              
101             1;
102              
103             =encoding utf-8
104              
105             =head1 NAME
106              
107             SBOM::CycloneDX::Service - Service
108              
109             =head1 SYNOPSIS
110              
111             SBOM::CycloneDX::Service->new();
112              
113              
114             =head1 DESCRIPTION
115              
116             L provides a list of services included or deployed
117             behind the parent service. This is not a dependency tree. It provides a way to
118             specify a hierarchical representation of service assemblies.
119              
120             =head2 METHODS
121              
122             L inherits all methods from L
123             and implements the following new ones.
124              
125             =over
126              
127             =item SBOM::CycloneDX::Service->new( %PARAMS )
128              
129             Properties:
130              
131             =over
132              
133             =item * C, A boolean value indicating if the service requires
134             authentication. A value of true indicates the service requires
135             authentication prior to use. A value of false indicates the service does
136             not require authentication.
137              
138             =item * C, An identifier which can be used to reference the
139             service elsewhere in the BOM. Every bom-ref must be unique within the BOM.
140             Value SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid
141             conflicts with BOM-Links.
142              
143             =item * C, Specifies information about the data including the
144             directional flow of data and the data classification.
145              
146             =item * C, Specifies a description for the service
147              
148             =item * C, The endpoint URIs of the service. Multiple endpoints
149             are allowed.
150              
151             =item * C, External references provide a way to document
152             systems, sites, and information that may be relevant but are not included
153             with the BOM. They may also establish specific relationships within or
154             external to the BOM.
155              
156             =item * C, The grouping name, namespace, or identifier. This will
157             often be a shortened, single name of the company or project that produced
158             the service or domain name. Whitespace and special characters should be
159             avoided.
160              
161             =item * C, Service License(s).
162              
163             =item * C, The name of the service. This will often be a shortened,
164             single name of the service.
165              
166             =item * C, Service Patent(s).
167              
168             Patent Assertions. A list of assertions made regarding patents associated
169             with this component or service. Assertions distinguish between ownership,
170             licensing, and other relevant interactions with patents.
171              
172             =item * C, Provides the ability to document properties in a
173             name-value store. This provides flexibility to include data not officially
174             supported in the standard without having to use additional namespaces or
175             create extensions. Unlike key-value stores, properties support duplicate
176             names, each potentially having different values. Property names of interest
177             to the general public are encouraged to be registered in the CycloneDX
178             Property Taxonomy (L).
179             Formal registration is optional.
180              
181             =item * C, The organization that provides the service.
182              
183             =item * C, Specifies release notes.
184              
185             =item * C, A list of services included or deployed behind the
186             parent service. This is not a dependency tree. It provides a way to specify
187             a hierarchical representation of service assemblies.
188              
189             =item * C, Enveloped signature in JSON Signature Format
190             (JSF) (L).
191              
192             =item * C,
193              
194             =item * C, The name of the trust zone the service resides in.
195              
196             =item * C, The service version.
197              
198             =item * C, A boolean value indicating if use of the service
199             crosses a trust zone or boundary. A value of true indicates that by using
200             the service, a trust boundary is crossed. A value of false indicates that by
201             using the service, a trust boundary is not crossed.
202              
203             =back
204              
205             =item $service->authenticated
206              
207             =item $service->bom_ref
208              
209             =item $service->data
210              
211             =item $service->description
212              
213             =item $service->endpoints
214              
215             =item $service->external_references
216              
217             =item $service->group
218              
219             =item $service->licenses
220              
221             =item $service->name
222              
223             =item $service->patent_assertions
224              
225             =item $service->properties
226              
227             =item $service->provider
228              
229             =item $service->release_notes
230              
231             =item $service->services
232              
233             =item $service->signature
234              
235             =item $service->tags
236              
237             =item $service->trust_zone
238              
239             =item $service->version
240              
241             =item $service->x_trust_boundary
242              
243             =back
244              
245              
246             =head1 SUPPORT
247              
248             =head2 Bugs / Feature Requests
249              
250             Please report any bugs or feature requests through the issue tracker
251             at L.
252             You will be notified automatically of any progress on your issue.
253              
254             =head2 Source Code
255              
256             This is open source software. The code repository is available for
257             public review and contribution under the terms of the license.
258              
259             L
260              
261             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
262              
263              
264             =head1 AUTHOR
265              
266             =over 4
267              
268             =item * Giuseppe Di Terlizzi
269              
270             =back
271              
272              
273             =head1 LICENSE AND COPYRIGHT
274              
275             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
276              
277             This is free software; you can redistribute it and/or modify it under
278             the same terms as the Perl 5 programming language system itself.
279              
280             =cut