| 1 | package SBOM::CycloneDX::Standard::Requirement; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use SBOM::CycloneDX::BomRef; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use SBOM::CycloneDX::List; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use Types::Standard qw(InstanceOf Str StrMatch); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use Types::TypeTiny qw(ArrayLike); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 1 | extends 'SBOM::CycloneDX::Base'; | |||||||||
| 18 | |||||||||||
| 19 | has bom_ref => ( | ||||||||||
| 20 | is => 'rw', | ||||||||||
| 21 | isa => InstanceOf ['SBOM::CycloneDX::BomRef'], | ||||||||||
| 22 | 0 | ▶ | coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::BomRef->new($_[0]) } | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 23 | 1 | ); | |||||||||
| 24 | |||||||||||
| 25 | 1 | has identifier => (is => 'rw', isa => Str); | |||||||||
| 26 | 1 | has title => (is => 'rw', isa => Str); | |||||||||
| 27 | 1 | has text => (is => 'rw', isa => Str); | |||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | has descriptions => (is => 'rw', isa => ArrayLike [Str], default => sub { SBOM::CycloneDX::List->new }); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 30 | |||||||||||
| 31 | has open_cre => ( | ||||||||||
| 32 | is => 'rw', | ||||||||||
| 33 | isa => ArrayLike [StrMatch [qr{^CRE:[0-9]+-[0-9]+$}]], | ||||||||||
| 34 | 0 | ▶ | default => sub { SBOM::CycloneDX::List->new } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 35 | 1 | ); | |||||||||
| 36 | |||||||||||
| 37 | 1 | has parent => (is => 'rw', isa => Str); # Like bom-ref | |||||||||
| 38 | |||||||||||
| 39 | has properties => ( | ||||||||||
| 40 | is => 'rw', | ||||||||||
| 41 | isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Property']], | ||||||||||
| 42 | 0 | ▶ | default => sub { SBOM::CycloneDX::List->new } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 43 | 1 | ); | |||||||||
| 44 | |||||||||||
| 45 | has external_references => ( | ||||||||||
| 46 | is => 'rw', | ||||||||||
| 47 | isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::ExternalReference']], | ||||||||||
| 48 | 0 | ▶ | default => sub { SBOM::CycloneDX::List->new } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 49 | 1 | ); | |||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | sub TO_JSON { | ||||||||
|
Subroutine
TO_JSON: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||
| 52 | |||||||||||
| 53 | 0 | my $self = shift; | |||||||||
| 54 | |||||||||||
| 55 | 0 | my $json = {}; | |||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | $json->{'bom-ref'} = $self->bom_ref if $self->bom_ref; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | 0 | ▶ | $json->{identifier} = $self->identifier if $self->identifier; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | ▶ | $json->{title} = $self->title if $self->title; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 0 | ▶ | $json->{text} = $self->text if $self->text; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 0 | ▶ | $json->{descriptions} = $self->descriptions if $self->descriptions; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 0 | ▶ | $json->{openCre} = $self->open_cre if $self->open_cre; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | ▶ | $json->{parent} = $self->parent if $self->parent; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | ▶ | $json->{properties} = $self->properties if $self->properties; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 0 | ▶ | $json->{externalReferences} = $self->external_references if @{$self->external_references}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | |||||||||||
| 67 | 0 | return $json; | |||||||||
| 68 | |||||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 1 | 1; | |||||||||
| 72 | |||||||||||
| 73 | =encoding utf-8 | ||||||||||
| 74 | |||||||||||
| 75 | =head1 NAME | ||||||||||
| 76 | |||||||||||
| 77 | SBOM::CycloneDX::Standard::Requirement - Requirement | ||||||||||
| 78 | |||||||||||
| 79 | =head1 SYNOPSIS | ||||||||||
| 80 | |||||||||||
| 81 | SBOM::CycloneDX::Standard::Requirement->new(); | ||||||||||
| 82 | |||||||||||
| 83 | |||||||||||
| 84 | =head1 DESCRIPTION | ||||||||||
| 85 | |||||||||||
| 86 | L<SBOM::CycloneDX::Standard::Requirement> provides the requirement comprising the standard. | ||||||||||
| 87 | |||||||||||
| 88 | =head2 METHODS | ||||||||||
| 89 | |||||||||||
| 90 | L<SBOM::CycloneDX::Standard::Requirement> inherits all methods from L<SBOM::CycloneDX::Base> | ||||||||||
| 91 | and implements the following new ones. | ||||||||||
| 92 | |||||||||||
| 93 | =over | ||||||||||
| 94 | |||||||||||
| 95 | =item SBOM::CycloneDX::Standard::Requirement->new( %PARAMS ) | ||||||||||
| 96 | |||||||||||
| 97 | Properties: | ||||||||||
| 98 | |||||||||||
| 99 | =over | ||||||||||
| 100 | |||||||||||
| 101 | =item * C<bom_ref>, An identifier which can be used to reference the | ||||||||||
| 102 | object elsewhere in the BOM. Every bom-ref must be unique within the BOM. | ||||||||||
| 103 | |||||||||||
| 104 | =item * C<descriptions>, The supplemental text that provides additional | ||||||||||
| 105 | guidance or context to the requirement, but is not directly part of the | ||||||||||
| 106 | requirement. | ||||||||||
| 107 | |||||||||||
| 108 | =item * C<external_references>, External references provide a way to document | ||||||||||
| 109 | systems, sites, and information that may be relevant, but are not included | ||||||||||
| 110 | with the BOM. They may also establish specific relationships within or | ||||||||||
| 111 | external to the BOM. | ||||||||||
| 112 | |||||||||||
| 113 | =item * C<identifier>, The unique identifier used in the standard to identify | ||||||||||
| 114 | a specific requirement. This should match what is in the standard and | ||||||||||
| 115 | should not be the requirements bom-ref. | ||||||||||
| 116 | |||||||||||
| 117 | =item * C<open_cre>, The Common Requirements Enumeration (CRE) identifier(s). | ||||||||||
| 118 | CRE is a structured and standardized framework for uniting security | ||||||||||
| 119 | standards and guidelines. CRE links each section of a resource to a shared | ||||||||||
| 120 | topic identifier (a Common Requirement). Through this shared topic link, | ||||||||||
| 121 | all resources map to each other. Use of CRE promotes clear and unambiguous | ||||||||||
| 122 | communication among stakeholders. | ||||||||||
| 123 | |||||||||||
| 124 | =item * C<parent>, The optional `bom-ref` to a parent requirement. This | ||||||||||
| 125 | establishes a hierarchy of requirements. Top-level requirements must not | ||||||||||
| 126 | define a parent. Only child requirements should define parents. | ||||||||||
| 127 | |||||||||||
| 128 | =item * C<properties>, Provides the ability to document properties in a | ||||||||||
| 129 | name-value store. This provides flexibility to include data not officially | ||||||||||
| 130 | supported in the standard without having to use additional namespaces or | ||||||||||
| 131 | create extensions. Unlike key-value stores, properties support duplicate | ||||||||||
| 132 | names, each potentially having different values. Property names of interest | ||||||||||
| 133 | to the general public are encouraged to be registered in the [CycloneDX | ||||||||||
| 134 | Property | ||||||||||
| 135 | Taxonomy](https://github.com/CycloneDX/cyclonedx-property-taxonomy). Formal | ||||||||||
| 136 | registration is optional. | ||||||||||
| 137 | |||||||||||
| 138 | =item * C<text>, The textual content of the requirement. | ||||||||||
| 139 | |||||||||||
| 140 | =item * C<title>, The title of the requirement. | ||||||||||
| 141 | |||||||||||
| 142 | =back | ||||||||||
| 143 | |||||||||||
| 144 | =item $requirement->bom_ref | ||||||||||
| 145 | |||||||||||
| 146 | =item $requirement->descriptions | ||||||||||
| 147 | |||||||||||
| 148 | =item $requirement->external_references | ||||||||||
| 149 | |||||||||||
| 150 | =item $requirement->identifier | ||||||||||
| 151 | |||||||||||
| 152 | =item $requirement->open_cre | ||||||||||
| 153 | |||||||||||
| 154 | =item $requirement->parent | ||||||||||
| 155 | |||||||||||
| 156 | =item $requirement->properties | ||||||||||
| 157 | |||||||||||
| 158 | =item $requirement->text | ||||||||||
| 159 | |||||||||||
| 160 | =item $requirement->title | ||||||||||
| 161 | |||||||||||
| 162 | =back | ||||||||||
| 163 | |||||||||||
| 164 | |||||||||||
| 165 | =head1 SUPPORT | ||||||||||
| 166 | |||||||||||
| 167 | =head2 Bugs / Feature Requests | ||||||||||
| 168 | |||||||||||
| 169 | Please report any bugs or feature requests through the issue tracker | ||||||||||
| 170 | at L<https://github.com/giterlizzi/perl-SBOM-CycloneDX/issues>. | ||||||||||
| 171 | You will be notified automatically of any progress on your issue. | ||||||||||
| 172 | |||||||||||
| 173 | =head2 Source Code | ||||||||||
| 174 | |||||||||||
| 175 | This is open source software. The code repository is available for | ||||||||||
| 176 | public review and contribution under the terms of the license. | ||||||||||
| 177 | |||||||||||
| 178 | L<https://github.com/giterlizzi/perl-SBOM-CycloneDX> | ||||||||||
| 179 | |||||||||||
| 180 | git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git | ||||||||||
| 181 | |||||||||||
| 182 | |||||||||||
| 183 | =head1 AUTHOR | ||||||||||
| 184 | |||||||||||
| 185 | =over 4 | ||||||||||
| 186 | |||||||||||
| 187 | =item * Giuseppe Di Terlizzi <gdt@cpan.org> | ||||||||||
| 188 | |||||||||||
| 189 | =back | ||||||||||
| 190 | |||||||||||
| 191 | |||||||||||
| 192 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 193 | |||||||||||
| 194 | This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi. | ||||||||||
| 195 | |||||||||||
| 196 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 197 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 198 | |||||||||||
| 199 | =cut | ||||||||||