| 1 | package SBOM::CycloneDX::Version; | ||||||||||||||||||||||||||||
| 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 Types::Standard qw(Str Enum InstanceOf); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | extends 'SBOM::CycloneDX::Base'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 0 | my ($self, $args) = @_; | |||||||||||||||||||||||||||
| 17 | Carp::croak('"version" and "range" cannot be used at the same time') | ||||||||||||||||||||||||||||
| 18 | 0 | ▶ | if exists $args->{version} && exists $args->{range}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $args->{"version"} and exists $args->{"range"}
MC/DC0%0/2
exists $args->{"version"} and exists $args->{"range"}
exists $args->{"version"}
exists $args->{"range"}
Truth table0%0/3
A and B
A= exists $args->{"version"}B= exists $args->{"range"}
| |||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | has version => (is => 'rw', isa => Str); | |||||||||||||||||||||||||||
| 22 | 0 | ▶ | has range => (is => 'rw', isa => InstanceOf ['URI::VersionRange'], coerce => sub { _vers_parse($_[0]) }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 23 | 1 | has status => (is => 'rw', isa => Enum [qw(affected unaffected unknown)]); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub _vers_parse { | ||||||||||||||||||||||||||
|
Subroutine
_vers_parse: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | my $vers = shift; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | return $vers if (ref $vers eq 'URI::VersionRange'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | return URI::VersionRange->from_string($vers); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub TO_JSON { | ||||||||||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | my $json = {}; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $json->{versions} = $self->versions if $self->versions; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | $json->{range} = $self->range->to_string if $self->range; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $json->{status} = $self->status if $self->status; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | return $json; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | 1; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head1 NAME | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | SBOM::CycloneDX::Version - Version | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | SBOM::CycloneDX::Version->new(); | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | L<SBOM::CycloneDX::Version> provide the version object. | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =head2 METHODS | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | L<SBOM::CycloneDX::Version> inherits all methods from L<SBOM::CycloneDX::Base> | ||||||||||||||||||||||||||||
| 68 | and implements the following new ones. | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =over | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =item SBOM::CycloneDX::Version->new( %PARAMS ) | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | Properties: | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =over | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =item * C<range>, A version range specified in Package URL Version Range | ||||||||||||||||||||||||||||
| 79 | syntax (vers) which is defined at | ||||||||||||||||||||||||||||
| 80 | L<https://github.com/package-url/purl-spec/blob/master/VERSION-RANGE-SPEC.rst> | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =item * C<status>, The vulnerability status for the version or range of | ||||||||||||||||||||||||||||
| 83 | versions. | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =item * C<version>, A single version of a component or service. | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =back | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =item $version->range | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =item $version->status | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =item $version->version | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =back | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head2 Bugs / Feature Requests | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | Please report any bugs or feature requests through the issue tracker | ||||||||||||||||||||||||||||
| 103 | at L<https://github.com/giterlizzi/perl-SBOM-CycloneDX/issues>. | ||||||||||||||||||||||||||||
| 104 | You will be notified automatically of any progress on your issue. | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =head2 Source Code | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | This is open source software. The code repository is available for | ||||||||||||||||||||||||||||
| 109 | public review and contribution under the terms of the license. | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | L<https://github.com/giterlizzi/perl-SBOM-CycloneDX> | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =over 4 | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =item * Giuseppe Di Terlizzi <gdt@cpan.org> | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =back | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi. | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 130 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =cut | ||||||||||||||||||||||||||||