File Coverage

blib/lib/SBOM/CycloneDX/Citation.pm
Criterion Covered Total %
statement 29 42 69.0
branch 0 16 0.0
condition n/a
subroutine 10 11 90.9
pod 1 1 100.0
total 40 70 57.1


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::Citation;
2              
3 1     1   3026 use 5.010001;
  1         4  
4 1     1   10 use strict;
  1         3  
  1         48  
5 1     1   7 use warnings;
  1         3  
  1         85  
6 1     1   8 use utf8;
  1         2  
  1         9  
7              
8 1     1   39 use SBOM::CycloneDX::BomRef;
  1         2  
  1         48  
9 1     1   7 use SBOM::CycloneDX::List;
  1         2  
  1         43  
10              
11 1     1   8 use Moo;
  1         3  
  1         10  
12 1     1   476 use namespace::autoclean;
  1         2  
  1         11  
13              
14 1     1   125 use Types::Standard qw(Str InstanceOf HashRef);
  1         2  
  1         10  
15 1     1   2161 use Types::TypeTiny qw(ArrayLike);
  1         4115  
  1         14  
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 pointers => (is => 'rw', isa => ArrayLike [Str], default => sub { SBOM::CycloneDX::List->new });
26              
27             has expressions => (is => 'rw', isa => ArrayLike [Str], default => sub { SBOM::CycloneDX::List->new });
28              
29             has timestamp => (
30             is => 'rw',
31             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
32             required => 1,
33             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
34             );
35              
36             has attributed_to => (is => 'rw', isa => Str);
37              
38             has process => (is => 'rw', isa => Str);
39              
40             has note => (is => 'rw', isa => Str);
41              
42             has signature => (is => 'rw', isa => HashRef);
43              
44              
45             sub TO_JSON {
46              
47 0     0 1   my $self = shift;
48              
49 0           my $json = {timestamp => $self->timestamp};
50              
51 0 0         $json->{'bom-ref'} = $self->bom_ref if $self->bom_ref;
52 0 0         $json->{pointers} = $self->pointers if @{$self->pointers};
  0            
53 0 0         $json->{expressions} = $self->expressions if @{$self->expressions};
  0            
54 0 0         $json->{timestamp} = $self->timestamp if $self->timestamp;
55 0 0         $json->{attributedTo} = $self->attributed_to if $self->attributed_to;
56 0 0         $json->{process} = $self->process if $self->process;
57 0 0         $json->{note} = $self->note if $self->note;
58 0 0         $json->{signature} = $self->signature if $self->signature;
59              
60 0           return $json;
61              
62             }
63              
64             1;
65              
66             =encoding utf-8
67              
68             =head1 NAME
69              
70             SBOM::CycloneDX::Citation - Citation
71              
72             =head1 SYNOPSIS
73              
74             SBOM::CycloneDX::Citation->new();
75              
76              
77             =head1 DESCRIPTION
78              
79             L Details a specific attribution of data within
80             the BOM to a contributing entity or process.
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::Citation->new( %PARAMS )
90              
91             Properties:
92              
93             =over
94              
95             =item * C, The C of an object, such as a component,
96             service, tool, organisational entity, or person that supplied the cited
97             information.
98             At least one of the "attributed_to" or "process" elements must be present.
99              
100             =item * C, BOM Reference
101              
102             =item * C, One or more path expressions used to locate values
103             within a BOM.
104             Exactly one of the "pointers" or "expressions" elements must be present.
105              
106             =item * C, A description or comment about the context or quality of the
107             data attribution.
108              
109             =item * C, One or more "JSON
110             Pointers" (L identifying the
111             BOM fields to which the attribution applies.
112             Exactly one of the "pointers" or "expressions" elements must be present.
113              
114             =item * C, The C to a process (such as a formula, workflow,
115             task, or step) defined in the C section that executed or
116             generated the attributed data.
117             At least one of the "attributed_to" or "process" elements must be present.
118              
119             =item * C, A digital signature verifying the authenticity or
120             integrity of the attribution.
121              
122             =item * C, The date and time when the attribution was made or the
123             information was supplied.
124              
125             =back
126              
127             =item $citation->attributed_to
128              
129             =item $citation->bom_ref
130              
131             =item $citation->expressions
132              
133             =item $citation->note
134              
135             =item $citation->pointers
136              
137             =item $citation->process
138              
139             =item $citation->signature
140              
141             =item $citation->timestamp
142              
143             =back
144              
145              
146             =head1 SUPPORT
147              
148             =head2 Bugs / Feature Requests
149              
150             Please report any bugs or feature requests through the issue tracker
151             at L.
152             You will be notified automatically of any progress on your issue.
153              
154             =head2 Source Code
155              
156             This is open source software. The code repository is available for
157             public review and contribution under the terms of the license.
158              
159             L
160              
161             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
162              
163              
164             =head1 AUTHOR
165              
166             =over 4
167              
168             =item * Giuseppe Di Terlizzi
169              
170             =back
171              
172              
173             =head1 LICENSE AND COPYRIGHT
174              
175             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
176              
177             This is free software; you can redistribute it and/or modify it under
178             the same terms as the Perl 5 programming language system itself.
179              
180             =cut