File Coverage

blib/lib/SBOM/CycloneDX/Annotation.pm
Criterion Covered Total %
statement 32 37 86.4
branch 0 4 0.0
condition n/a
subroutine 11 12 91.6
pod 1 1 100.0
total 44 54 81.4


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::Annotation;
2              
3 1     1   1702 use 5.010001;
  1         7  
4 1     1   7 use strict;
  1         2  
  1         41  
5 1     1   8 use warnings;
  1         2  
  1         61  
6 1     1   33 use utf8;
  1         11  
  1         10  
7              
8 1     1   40 use SBOM::CycloneDX::BomRef;
  1         3  
  1         40  
9 1     1   7 use SBOM::CycloneDX::List;
  1         2  
  1         33  
10 1     1   6 use SBOM::CycloneDX::Timestamp;
  1         3  
  1         48  
11              
12 1     1   7 use Types::Standard qw(Str HashRef InstanceOf);
  1         3  
  1         9  
13 1     1   2402 use Types::TypeTiny qw(ArrayLike);
  1         4  
  1         10  
14              
15 1     1   640 use Moo;
  1         3  
  1         9  
16 1     1   543 use namespace::autoclean;
  1         3  
  1         11  
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 subjects => (is => 'rw', isa => ArrayLike [Str], required => 1, default => sub { SBOM::CycloneDX::List->new });
27              
28             has annotator => (
29             is => 'rw',
30             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Annotation::Annotator']],
31             required => 1,
32             default => sub { SBOM::CycloneDX::List->new }
33             );
34              
35             has timestamp => (
36             is => 'rw',
37             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
38             required => 1,
39             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
40             );
41              
42             has text => (is => 'rw', isa => Str, required => 1);
43             has signature => (is => 'rw', isa => ArrayLike [HashRef], default => sub { SBOM::CycloneDX::List->new });
44              
45             sub TO_JSON {
46              
47 0     0 1   my $self = shift;
48              
49 0           my $json = {
50             subjects => $self->subjects,
51             annotator => $self->annotator,
52             timestamp => $self->timestamp,
53             text => $self->text
54             };
55              
56 0 0         $json->{'bom-ref'} = $self->bom_ref if $self->bom_ref;
57 0 0         $json->{signature} = $self->signature if $self->signature;
58              
59              
60 0           return $json;
61              
62             }
63              
64             1;
65              
66             =encoding utf-8
67              
68             =head1 NAME
69              
70             SBOM::CycloneDX::Annotation - Annotations
71              
72             =head1 SYNOPSIS
73              
74             SBOM::CycloneDX::Annotation->new();
75              
76              
77             =head1 DESCRIPTION
78              
79             A comment, note, explanation, or similar textual content which provides
80             additional context to the object(s) being annotated.
81              
82             =head2 METHODS
83              
84             L inherits all methods from L
85             and implements the following new ones.
86              
87             =over
88              
89             =item SBOM::CycloneDX::Annotation->new( %PARAMS )
90              
91             Properties:
92              
93             =over
94              
95             =item * C, The organization, person, component, or service which
96             created the textual content of the annotation.
97              
98             =item * C, An identifier which can be used to reference the
99             annotation elsewhere in the BOM. Every bom-ref must be unique within the
100             BOM.
101             Value SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid
102             conflicts with BOM-Links.
103              
104             =item * C, Enveloped signature in JSON Signature Format (JSF)
105             (L).
106              
107             =item * C, The object in the BOM identified by its bom-ref. This is
108             often a component or service, but may be any object type supporting
109             bom-refs.
110              
111             =item * C, The textual content of the annotation.
112              
113             =item * C, The date and time (timestamp) when the annotation was
114             created.
115              
116             =back
117              
118             =item $annotation->annotator
119              
120             =item $annotation->bom_ref
121              
122             =item $annotation->signature
123              
124             =item $annotation->subjects
125              
126             =item $annotation->text
127              
128             =item $annotation->timestamp
129              
130             =back
131              
132              
133             =head1 SUPPORT
134              
135             =head2 Bugs / Feature Requests
136              
137             Please report any bugs or feature requests through the issue tracker
138             at L.
139             You will be notified automatically of any progress on your issue.
140              
141             =head2 Source Code
142              
143             This is open source software. The code repository is available for
144             public review and contribution under the terms of the license.
145              
146             L
147              
148             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
149              
150              
151             =head1 AUTHOR
152              
153             =over 4
154              
155             =item * Giuseppe Di Terlizzi
156              
157             =back
158              
159              
160             =head1 LICENSE AND COPYRIGHT
161              
162             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
163              
164             This is free software; you can redistribute it and/or modify it under
165             the same terms as the Perl 5 programming language system itself.
166              
167             =cut