File Coverage

blib/lib/SBOM/CycloneDX/Vulnerability/Rating.pm
Criterion Covered Total %
statement 20 29 68.9
branch 0 12 0.0
condition n/a
subroutine 7 8 87.5
pod 1 1 100.0
total 28 50 56.0


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::Vulnerability::Rating;
2              
3 1     1   1550 use 5.010001;
  1         4  
4 1     1   5 use strict;
  1         4  
  1         24  
5 1     1   5 use warnings;
  1         2  
  1         51  
6 1     1   6 use utf8;
  1         3  
  1         8  
7              
8 1     1   46 use Types::Standard qw(Str Num InstanceOf Enum);
  1         3  
  1         7  
9              
10 1     1   3875 use Moo;
  1         2  
  1         8  
11 1     1   443 use namespace::autoclean;
  1         3  
  1         12  
12              
13             extends 'SBOM::CycloneDX::Base';
14              
15             has source => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::Source']);
16             has score => (is => 'rw', isa => Num);
17             has severity => (is => 'rw', isa => Enum [qw(critical high medium low info none unknown)]);
18             has method => (is => 'rw', isa => Enum [qw(CVSSv2 CVSSv3 CVSSv31 CVSSv4 OWASP SSVC other)]);
19             has vector => (is => 'rw', isa => Str);
20             has justification => (is => 'rw', isa => Str);
21              
22             sub TO_JSON {
23              
24 0     0 1   my $self = shift;
25              
26 0           my $json = {};
27              
28 0 0         $json->{source} = $self->source if $self->source;
29 0 0         $json->{score} = $self->score if $self->score;
30 0 0         $json->{severity} = $self->severity if $self->severity;
31 0 0         $json->{method} = $self->method if $self->method;
32 0 0         $json->{vector} = $self->vector if $self->vector;
33 0 0         $json->{justification} = $self->justification if $self->justification;
34              
35 0           return $json;
36              
37             }
38              
39             1;
40              
41             =encoding utf-8
42              
43             =head1 NAME
44              
45             SBOM::CycloneDX::Vulnerability::Rating - Rating
46              
47             =head1 SYNOPSIS
48              
49             SBOM::CycloneDX::Vulnerability::Rating->new();
50              
51              
52             =head1 DESCRIPTION
53              
54             L Defines the severity or risk ratings of a
55             vulnerability.
56              
57             =head2 METHODS
58              
59             L inherits all methods from L
60             and implements the following new ones.
61              
62             =over
63              
64             =item SBOM::CycloneDX::Vulnerability::Rating->new( %PARAMS )
65              
66             Properties:
67              
68             =over
69              
70             =item * C, A reason for rating the vulnerability as
71             it was
72              
73             =item * C, Specifies the severity or risk scoring methodology or standard
74             used.
75              
76             =item * C, The numerical score of the rating.
77              
78             =item * C, Textual representation of the severity that corresponds
79             to the numerical score of the rating.
80              
81             =item * C, The source that calculated the severity or risk rating of
82             the vulnerability.
83              
84             =item * C, Textual representation of the metric values used to score
85             the vulnerability
86              
87             =back
88              
89             =item $rating->justification
90              
91             =item $rating->method
92              
93             =item $rating->score
94              
95             =item $rating->severity
96              
97             =item $rating->source
98              
99             =item $rating->vector
100              
101             =back
102              
103              
104             =head1 SUPPORT
105              
106             =head2 Bugs / Feature Requests
107              
108             Please report any bugs or feature requests through the issue tracker
109             at L.
110             You will be notified automatically of any progress on your issue.
111              
112             =head2 Source Code
113              
114             This is open source software. The code repository is available for
115             public review and contribution under the terms of the license.
116              
117             L
118              
119             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
120              
121              
122             =head1 AUTHOR
123              
124             =over 4
125              
126             =item * Giuseppe Di Terlizzi
127              
128             =back
129              
130              
131             =head1 LICENSE AND COPYRIGHT
132              
133             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
134              
135             This is free software; you can redistribute it and/or modify it under
136             the same terms as the Perl 5 programming language system itself.
137              
138             =cut