File Coverage

blib/lib/SBOM/CycloneDX/ExternalReference.pm
Criterion Covered Total %
statement 29 37 78.3
branch 0 6 0.0
condition n/a
subroutine 10 11 90.9
pod 1 1 100.0
total 40 55 72.7


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::ExternalReference;
2              
3 16     16   368 use 5.010001;
  16         69  
4 16     16   100 use strict;
  16         38  
  16         491  
5 16     16   77 use warnings;
  16         31  
  16         1016  
6 16     16   93 use utf8;
  16         32  
  16         664  
7              
8 16     16   666 use SBOM::CycloneDX::Enum;
  16         35  
  16         1323  
9 16     16   99 use SBOM::CycloneDX::List;
  16         36  
  16         734  
10              
11 16     16   82 use Types::Standard qw(Str Enum InstanceOf);
  16         31  
  16         182  
12 16     16   52317 use Types::TypeTiny qw(ArrayLike);
  16         46  
  16         128  
13              
14 16     16   8726 use Moo;
  16         38  
  16         125  
15 16     16   7164 use namespace::autoclean;
  16         43  
  16         179  
16              
17             extends 'SBOM::CycloneDX::Base';
18              
19             has url => (is => 'rw', isa => Str, required => 1);
20              
21             has comment => (is => 'rw', isa => Str);
22              
23             has type => (is => 'rw', isa => Enum [SBOM::CycloneDX::Enum->values('EXTERNAL_REFERENCE_TYPE')], required => 1);
24              
25             has hashes => (
26             is => 'rw',
27             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Hash']],
28             default => sub { SBOM::CycloneDX::List->new }
29             );
30              
31             has properties => (
32             is => 'rw',
33             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Property']],
34             default => sub { SBOM::CycloneDX::List->new }
35             );
36              
37             sub TO_JSON {
38              
39 0     0 1   my $self = shift;
40              
41 0           my $json = {url => $self->url, type => $self->type};
42              
43 0 0         $json->{comment} = $self->comment if $self->comment;
44 0 0         $json->{hashes} = $self->hashes if @{$self->hashes};
  0            
45 0 0         $json->{properties} = $self->properties if @{$self->properties};
  0            
46              
47 0           return $json;
48              
49             }
50              
51             1;
52              
53             =encoding utf-8
54              
55             =head1 NAME
56              
57             SBOM::CycloneDX::ExternalReference - External Reference
58              
59             =head1 SYNOPSIS
60              
61             SBOM::CycloneDX::ExternalReference->new();
62              
63              
64             =head1 DESCRIPTION
65              
66             L provide a way to
67             document systems, sites, and information that may be relevant but are not
68             included with the BOM. They may also establish specific relationships
69             within or external to the BOM.
70              
71             =head2 METHODS
72              
73             L inherits all methods from L
74             and implements the following new ones.
75              
76             =over
77              
78             =item SBOM::CycloneDX::ExternalReference->new( %PARAMS )
79              
80             Properties:
81              
82             =over
83              
84             =item * C, A comment describing the external reference
85              
86             =item * C, The hashes of the external reference (if applicable).
87              
88             =item * C, Provides the ability to document properties in a name-value
89             store. This provides flexibility to include data not officially supported in the
90             standard without having to use additional namespaces or create extensions.
91             Unlike key-value stores, properties support duplicate names, each potentially
92             having different values. Property names of interest to the general public are
93             encouraged to be registered in the CycloneDX Property Taxonomy. Formal
94             registration is optional. See L
95              
96             =item * C, Specifies the type of external reference.
97              
98             =item * C, The URI (URL or URN) to the external reference. External
99             references are URIs and therefore can accept any URL scheme including https
100             (RFC-7230 - L), mailto
101             (RFC-2368 - L), tel
102             (RFC-3966 - L), and dns
103             (RFC-4501 - L). External references may
104             also include formally registered URNs such as CycloneDX
105             BOM-Link (L) to reference
106             CycloneDX BOMs or any object within a BOM. BOM-Link transforms applicable
107             external references into relationships that can be expressed in a BOM or
108             across BOMs.
109              
110             =back
111              
112             =item $external_reference->comment
113              
114             =item $external_reference->hashes
115              
116             =item $external_reference->properties
117              
118             =item $external_reference->type
119              
120             =item $external_reference->url
121              
122             =back
123              
124              
125             =head1 SUPPORT
126              
127             =head2 Bugs / Feature Requests
128              
129             Please report any bugs or feature requests through the issue tracker
130             at L.
131             You will be notified automatically of any progress on your issue.
132              
133             =head2 Source Code
134              
135             This is open source software. The code repository is available for
136             public review and contribution under the terms of the license.
137              
138             L
139              
140             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
141              
142              
143             =head1 AUTHOR
144              
145             =over 4
146              
147             =item * Giuseppe Di Terlizzi
148              
149             =back
150              
151              
152             =head1 LICENSE AND COPYRIGHT
153              
154             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
155              
156             This is free software; you can redistribute it and/or modify it under
157             the same terms as the Perl 5 programming language system itself.
158              
159             =cut