| 1 | package SBOM::CycloneDX::Vulnerability; | ||||||||||
| 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 | 1 | ▶ | use SBOM::CycloneDX::Timestamp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use Types::Standard qw(Str Int InstanceOf); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use Types::TypeTiny qw(ArrayLike); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 1 | extends 'SBOM::CycloneDX::Base'; | |||||||||
| 19 | |||||||||||
| 20 | has bom_ref => ( | ||||||||||
| 21 | is => 'rw', | ||||||||||
| 22 | isa => InstanceOf ['SBOM::CycloneDX::BomRef'], | ||||||||||
| 23 | 0 | ▶ | coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::BomRef->new($_[0]) } | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 24 | 1 | ); | |||||||||
| 25 | |||||||||||
| 26 | 1 | has id => (is => 'rw', isa => Str); | |||||||||
| 27 | 1 | has source => ( | |||||||||
| 28 | is => 'rw', | ||||||||||
| 29 | isa => InstanceOf ['SBOM::CycloneDX::Source'] | InstanceOf ['SBOM::CycloneDX::Vulnerability::Source'] | ||||||||||
| 30 | ); | ||||||||||
| 31 | |||||||||||
| 32 | has references => ( | ||||||||||
| 33 | is => 'rw', | ||||||||||
| 34 | isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Vulnerability::Reference']], | ||||||||||
| 35 | 0 | ▶ | default => sub { SBOM::CycloneDX::List->new } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 36 | 1 | ); | |||||||||
| 37 | |||||||||||
| 38 | has ratings => ( | ||||||||||
| 39 | is => 'rw', | ||||||||||
| 40 | isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Vulnerability::Rating']], | ||||||||||
| 41 | 0 | ▶ | default => sub { SBOM::CycloneDX::List->new } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 42 | 1 | ); | |||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | has cwes => (is => 'rw', isa => ArrayLike [Int], default => sub { SBOM::CycloneDX::List->new }); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 45 | 1 | has description => (is => 'rw', isa => Str); | |||||||||
| 46 | 1 | has detail => (is => 'rw', isa => Str); | |||||||||
| 47 | 1 | has recommendation => (is => 'rw', isa => Str); | |||||||||
| 48 | 1 | has workaround => (is => 'rw', isa => Str); | |||||||||
| 49 | 1 | has proof_of_concept => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::Vulnerability::ProofOfConcept']); | |||||||||
| 50 | |||||||||||
| 51 | has advisories => ( | ||||||||||
| 52 | is => 'rw', | ||||||||||
| 53 | isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Advisory']], | ||||||||||
| 54 | 0 | ▶ | default => sub { SBOM::CycloneDX::List->new } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 55 | 1 | ); | |||||||||
| 56 | |||||||||||
| 57 | has created => ( | ||||||||||
| 58 | is => 'rw', | ||||||||||
| 59 | isa => InstanceOf ['SBOM::CycloneDX::Timestamp'], | ||||||||||
| 60 | 0 | ▶ | coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) } | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 61 | 1 | ); | |||||||||
| 62 | |||||||||||
| 63 | has published => ( | ||||||||||
| 64 | is => 'rw', | ||||||||||
| 65 | isa => InstanceOf ['SBOM::CycloneDX::Timestamp'], | ||||||||||
| 66 | 0 | ▶ | coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) } | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 67 | 1 | ); | |||||||||
| 68 | |||||||||||
| 69 | has updated => ( | ||||||||||
| 70 | is => 'rw', | ||||||||||
| 71 | isa => InstanceOf ['SBOM::CycloneDX::Timestamp'], | ||||||||||
| 72 | 0 | ▶ | coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) } | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 73 | 1 | ); | |||||||||
| 74 | |||||||||||
| 75 | has rejected => ( | ||||||||||
| 76 | is => 'rw', | ||||||||||
| 77 | isa => InstanceOf ['SBOM::CycloneDX::Timestamp'], | ||||||||||
| 78 | 0 | ▶ | coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) } | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 79 | 1 | ); | |||||||||
| 80 | |||||||||||
| 81 | 1 | has credits => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::Vulnerability::Credits']); | |||||||||
| 82 | |||||||||||
| 83 | 1 | has tools => | |||||||||
| 84 | (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::Tools'] | ArrayLike [InstanceOf ['SBOM::CycloneDX::Tool']]); | ||||||||||
| 85 | |||||||||||
| 86 | 1 | has analysis => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::Vulnerability::Analysis']); | |||||||||
| 87 | |||||||||||
| 88 | has affects => ( | ||||||||||
| 89 | is => 'rw', | ||||||||||
| 90 | isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Vulnerability::Affect']], | ||||||||||
| 91 | 0 | ▶ | default => sub { SBOM::CycloneDX::List->new } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 92 | 1 | ); | |||||||||
| 93 | |||||||||||
| 94 | has properties => ( | ||||||||||
| 95 | is => 'rw', | ||||||||||
| 96 | isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::Property']], | ||||||||||
| 97 | 0 | ▶ | default => sub { SBOM::CycloneDX::List->new } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 98 | 1 | ); | |||||||||
| 99 | |||||||||||
| 100 | 0 | ▶ | sub TO_JSON { | ||||||||
|
Subroutine
TO_JSON: not called CC=22 SCAR=62.3
Pod
documented
| |||||||||||
| 101 | |||||||||||
| 102 | 0 | my $self = shift; | |||||||||
| 103 | |||||||||||
| 104 | 0 | my $json = {}; | |||||||||
| 105 | |||||||||||
| 106 | 0 | ▶ | $json->{'bom-ref'} = $self->bom_ref if $self->bom_ref; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 107 | 0 | ▶ | $json->{id} = $self->id if $self->id; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 108 | 0 | ▶ | $json->{source} = $self->source if $self->source; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 109 | 0 | ▶ | $json->{references} = $self->references if @{$self->references}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 110 | 0 | ▶ | $json->{ratings} = $self->ratings if @{$self->ratings}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 111 | 0 | ▶ | $json->{cwes} = $self->cwes if @{$self->cwes}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 112 | 0 | ▶ | $json->{description} = $self->description if $self->description; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 113 | 0 | ▶ | $json->{detail} = $self->detail if $self->detail; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 114 | 0 | ▶ | $json->{recommendation} = $self->recommendation if $self->recommendation; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 115 | 0 | ▶ | $json->{workaround} = $self->workaround if $self->workaround; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 116 | 0 | ▶ | $json->{proofOfConcept} = $self->proof_of_concept if $self->proof_of_concept; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 117 | 0 | ▶ | $json->{advisories} = $self->advisories if @{$self->advisories}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 118 | 0 | ▶ | $json->{created} = $self->created if $self->created; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 119 | 0 | ▶ | $json->{published} = $self->published if $self->published; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 120 | 0 | ▶ | $json->{updated} = $self->updated if $self->updated; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 121 | 0 | ▶ | $json->{rejected} = $self->rejected if $self->rejected; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 122 | 0 | ▶ | $json->{credits} = $self->credits if $self->credits; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 123 | 0 | ▶ | $json->{tools} = $self->tools if $self->tools; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 124 | 0 | ▶ | $json->{analysis} = $self->analysis if $self->analysis; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 125 | 0 | ▶ | $json->{affects} = $self->affects if @{$self->affects}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 126 | 0 | ▶ | $json->{properties} = $self->properties if @{$self->properties}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 127 | |||||||||||
| 128 | 0 | return $json; | |||||||||
| 129 | |||||||||||
| 130 | } | ||||||||||
| 131 | |||||||||||
| 132 | 1 | 1; | |||||||||
| 133 | |||||||||||
| 134 | =encoding utf-8 | ||||||||||
| 135 | |||||||||||
| 136 | =head1 NAME | ||||||||||
| 137 | |||||||||||
| 138 | SBOM::CycloneDX::Vulnerability - Vulnerability | ||||||||||
| 139 | |||||||||||
| 140 | =head1 SYNOPSIS | ||||||||||
| 141 | |||||||||||
| 142 | SBOM::CycloneDX::Vulnerability->new(); | ||||||||||
| 143 | |||||||||||
| 144 | |||||||||||
| 145 | =head1 DESCRIPTION | ||||||||||
| 146 | |||||||||||
| 147 | L<SBOM::CycloneDX::Vulnerability> Defines a weakness in a component or | ||||||||||
| 148 | service that could be exploited or triggered by a threat source. | ||||||||||
| 149 | |||||||||||
| 150 | =head2 METHODS | ||||||||||
| 151 | |||||||||||
| 152 | L<SBOM::CycloneDX::Vulnerability> inherits all methods from L<SBOM::CycloneDX::Base> | ||||||||||
| 153 | and implements the following new ones. | ||||||||||
| 154 | |||||||||||
| 155 | =over | ||||||||||
| 156 | |||||||||||
| 157 | =item SBOM::CycloneDX::Vulnerability->new( %PARAMS ) | ||||||||||
| 158 | |||||||||||
| 159 | Properties: | ||||||||||
| 160 | |||||||||||
| 161 | =over | ||||||||||
| 162 | |||||||||||
| 163 | =item * C<advisories>, Published advisories of the vulnerability if provided. | ||||||||||
| 164 | |||||||||||
| 165 | =item * C<affects>, The components or services that are affected by the | ||||||||||
| 166 | vulnerability. | ||||||||||
| 167 | |||||||||||
| 168 | =item * C<analysis>, An assessment of the impact and exploitability of the | ||||||||||
| 169 | vulnerability. | ||||||||||
| 170 | |||||||||||
| 171 | =item * C<bom_ref>, An identifier which can be used to reference the | ||||||||||
| 172 | vulnerability elsewhere in the BOM. Every bom-ref must be unique within the | ||||||||||
| 173 | BOM. | ||||||||||
| 174 | Value SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid | ||||||||||
| 175 | conflicts with BOM-Links. | ||||||||||
| 176 | |||||||||||
| 177 | =item * C<created>, The date and time (timestamp) when the vulnerability | ||||||||||
| 178 | record was created in the vulnerability database. | ||||||||||
| 179 | |||||||||||
| 180 | =item * C<credits>, Individuals or organizations credited with the discovery | ||||||||||
| 181 | of the vulnerability. | ||||||||||
| 182 | |||||||||||
| 183 | =item * C<cwes>, List of Common Weaknesses Enumerations (CWEs) codes that | ||||||||||
| 184 | describes this vulnerability. | ||||||||||
| 185 | |||||||||||
| 186 | =item * C<description>, A description of the vulnerability as provided by the | ||||||||||
| 187 | source. | ||||||||||
| 188 | |||||||||||
| 189 | =item * C<detail>, If available, an in-depth description of the vulnerability | ||||||||||
| 190 | as provided by the source organization. Details often include information | ||||||||||
| 191 | useful in understanding root cause. | ||||||||||
| 192 | |||||||||||
| 193 | =item * C<id>, The identifier that uniquely identifies the vulnerability. | ||||||||||
| 194 | |||||||||||
| 195 | =item * C<proof_of_concept>, Evidence used to reproduce the vulnerability. | ||||||||||
| 196 | |||||||||||
| 197 | =item * C<properties>, Provides the ability to document properties in a | ||||||||||
| 198 | name-value store. This provides flexibility to include data not officially | ||||||||||
| 199 | supported in the standard without having to use additional namespaces or | ||||||||||
| 200 | create extensions. Unlike key-value stores, properties support duplicate | ||||||||||
| 201 | names, each potentially having different values. Property names of interest | ||||||||||
| 202 | to the general public are encouraged to be registered in the CycloneDX | ||||||||||
| 203 | Property | ||||||||||
| 204 | Taxonomy (L<https://github.com/CycloneDX/cyclonedx-property-taxonomy>). Formal | ||||||||||
| 205 | registration is optional. | ||||||||||
| 206 | |||||||||||
| 207 | =item * C<published>, The date and time (timestamp) when the vulnerability | ||||||||||
| 208 | record was first published. | ||||||||||
| 209 | |||||||||||
| 210 | =item * C<ratings>, List of vulnerability ratings | ||||||||||
| 211 | |||||||||||
| 212 | =item * C<recommendation>, Recommendations of how the vulnerability can be | ||||||||||
| 213 | remediated or mitigated. | ||||||||||
| 214 | |||||||||||
| 215 | =item * C<references>, Zero or more pointers to vulnerabilities that are the | ||||||||||
| 216 | equivalent of the vulnerability specified. Often times, the same | ||||||||||
| 217 | vulnerability may exist in multiple sources of vulnerability intelligence, | ||||||||||
| 218 | but have different identifiers. References provide a way to correlate | ||||||||||
| 219 | vulnerabilities across multiple sources of vulnerability intelligence. | ||||||||||
| 220 | |||||||||||
| 221 | =item * C<rejected>, The date and time (timestamp) when the vulnerability | ||||||||||
| 222 | record was rejected (if applicable). | ||||||||||
| 223 | |||||||||||
| 224 | =item * C<source>, The source that published the vulnerability. | ||||||||||
| 225 | |||||||||||
| 226 | =item * C<tools>, The tool(s) used to identify, confirm, or score the | ||||||||||
| 227 | vulnerability. | ||||||||||
| 228 | |||||||||||
| 229 | =item * C<updated>, The date and time (timestamp) when the vulnerability | ||||||||||
| 230 | record was last updated. | ||||||||||
| 231 | |||||||||||
| 232 | =item * C<workaround>, A bypass, usually temporary, of the vulnerability that | ||||||||||
| 233 | reduces its likelihood and/or impact. Workarounds often involve changes to | ||||||||||
| 234 | configuration or deployments. | ||||||||||
| 235 | |||||||||||
| 236 | =back | ||||||||||
| 237 | |||||||||||
| 238 | =item $vulnerability->advisories | ||||||||||
| 239 | |||||||||||
| 240 | =item $vulnerability->affects | ||||||||||
| 241 | |||||||||||
| 242 | =item $vulnerability->analysis | ||||||||||
| 243 | |||||||||||
| 244 | =item $vulnerability->bom_ref | ||||||||||
| 245 | |||||||||||
| 246 | =item $vulnerability->created | ||||||||||
| 247 | |||||||||||
| 248 | =item $vulnerability->credits | ||||||||||
| 249 | |||||||||||
| 250 | =item $vulnerability->cwes | ||||||||||
| 251 | |||||||||||
| 252 | =item $vulnerability->description | ||||||||||
| 253 | |||||||||||
| 254 | =item $vulnerability->detail | ||||||||||
| 255 | |||||||||||
| 256 | =item $vulnerability->id | ||||||||||
| 257 | |||||||||||
| 258 | =item $vulnerability->proof_of_concept | ||||||||||
| 259 | |||||||||||
| 260 | =item $vulnerability->properties | ||||||||||
| 261 | |||||||||||
| 262 | =item $vulnerability->published | ||||||||||
| 263 | |||||||||||
| 264 | =item $vulnerability->ratings | ||||||||||
| 265 | |||||||||||
| 266 | =item $vulnerability->recommendation | ||||||||||
| 267 | |||||||||||
| 268 | =item $vulnerability->references | ||||||||||
| 269 | |||||||||||
| 270 | =item $vulnerability->rejected | ||||||||||
| 271 | |||||||||||
| 272 | =item $vulnerability->source | ||||||||||
| 273 | |||||||||||
| 274 | =item $vulnerability->tools | ||||||||||
| 275 | |||||||||||
| 276 | =item $vulnerability->updated | ||||||||||
| 277 | |||||||||||
| 278 | =item $vulnerability->workaround | ||||||||||
| 279 | |||||||||||
| 280 | =back | ||||||||||
| 281 | |||||||||||
| 282 | |||||||||||
| 283 | =head1 SUPPORT | ||||||||||
| 284 | |||||||||||
| 285 | =head2 Bugs / Feature Requests | ||||||||||
| 286 | |||||||||||
| 287 | Please report any bugs or feature requests through the issue tracker | ||||||||||
| 288 | at L<https://github.com/giterlizzi/perl-SBOM-CycloneDX/issues>. | ||||||||||
| 289 | You will be notified automatically of any progress on your issue. | ||||||||||
| 290 | |||||||||||
| 291 | =head2 Source Code | ||||||||||
| 292 | |||||||||||
| 293 | This is open source software. The code repository is available for | ||||||||||
| 294 | public review and contribution under the terms of the license. | ||||||||||
| 295 | |||||||||||
| 296 | L<https://github.com/giterlizzi/perl-SBOM-CycloneDX> | ||||||||||
| 297 | |||||||||||
| 298 | git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git | ||||||||||
| 299 | |||||||||||
| 300 | |||||||||||
| 301 | =head1 AUTHOR | ||||||||||
| 302 | |||||||||||
| 303 | =over 4 | ||||||||||
| 304 | |||||||||||
| 305 | =item * Giuseppe Di Terlizzi <gdt@cpan.org> | ||||||||||
| 306 | |||||||||||
| 307 | =back | ||||||||||
| 308 | |||||||||||
| 309 | |||||||||||
| 310 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 311 | |||||||||||
| 312 | This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi. | ||||||||||
| 313 | |||||||||||
| 314 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 315 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 316 | |||||||||||
| 317 | =cut | ||||||||||