CSAF/Type.pm

filter: Statementstmt 100% 29 / 29 Branchbran 75.0% 3 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 97.9% 48 / 49 CC 4 SCAR 6.9
CC
4
Cov
97%
_build
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« CSAF/Validator/Schema.pm ↑ Summary CSAF/Util/List.pm »
1 package CSAF::Type;
2  
3 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use constant TYPE_CLASSES => {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 acknowledgment => 'CSAF::Type::Acknowledgment',
12 acknowledgments => 'CSAF::Type::Acknowledgments',
13 aggregate_severity => 'CSAF::Type::AggregateSeverity',
14 branch => 'CSAF::Type::Branch',
15 branches => 'CSAF::Type::Branches',
16 cvss_v2 => 'CSAF::Type::CVSS2',
17 cvss_v3 => 'CSAF::Type::CVSS3',
18 cwe => 'CSAF::Type::CWE',
19 distribution => 'CSAF::Type::Distribution',
20 document => 'CSAF::Type::Document',
21 engine => 'CSAF::Type::Engine',
22 file_hash => 'CSAF::Type::FileHash',
23 file_hashes => 'CSAF::Type::FileHashes',
24 flag => 'CSAF::Type::Flag',
25 flags => 'CSAF::Type::Flags',
26 full_product_name => 'CSAF::Type::FullProductName',
27 full_product_names => 'CSAF::Type::FullProductNames',
28 generator => 'CSAF::Type::Generator',
29 generic_uri => 'CSAF::Type::GenericURI',
30 generic_uris => 'CSAF::Type::GenericURIs',
31 hash => 'CSAF::Type::Hash',
32 hashes => 'CSAF::Type::Hashes',
33 id => 'CSAF::Type::ID',
34 ids => 'CSAF::Type::IDs',
35 note => 'CSAF::Type::Note',
36 notes => 'CSAF::Type::Notes',
37 product => 'CSAF::Type::Product',
38 product_group => 'CSAF::Type::ProductGroup',
39 product_groups => 'CSAF::Type::ProductGroups',
40 product_identification_helper => 'CSAF::Type::ProductIdentificationHelper',
41 product_status => 'CSAF::Type::ProductStatus',
42 product_tree => 'CSAF::Type::ProductTree',
43 publisher => 'CSAF::Type::Publisher',
44 reference => 'CSAF::Type::Reference',
45 references => 'CSAF::Type::References',
46 relationship => 'CSAF::Type::Relationship',
47 relationships => 'CSAF::Type::Relationships',
48 remediation => 'CSAF::Type::Remediation',
49 remediations => 'CSAF::Type::Remediations',
50 restart_required => 'CSAF::Type::RestartRequired',
51 revision => 'CSAF::Type::Revision',
52 revision_history => 'CSAF::Type::RevisionHistory',
53 score => 'CSAF::Type::Score',
54 scores => 'CSAF::Type::Scores',
55 threat => 'CSAF::Type::Threat',
56 threats => 'CSAF::Type::Threats',
57 tlp => 'CSAF::Type::TLP',
58 tracking => 'CSAF::Type::Tracking',
59 vulnerabilities => 'CSAF::Type::Vulnerabilities',
60 vulnerability => 'CSAF::Type::Vulnerability',
61 2 };
62  
63  
64 50 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
65  
66 50 my ($self, %params) = @_;
67  
68 50 my $name = delete $params{name};
69 50 my $value = delete $params{value};
70  
71 50 return _build(lc $name, $value);
72  
73 }
74  
75 37 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
76 37 my ($self, $name, $value) = @_;
77 37 return _build(lc $name, $value);
78 }
79  
80 87 ▶sub _build {
Subroutine _build: called CC=4 SCAR=13.9
81  
82 87 my ($name, $value) = @_;
83  
84 87 ▶ my $class = TYPE_CLASSES->{$name} or Carp::croak 'Unknown CSAF type';
Branch: 1 branch
BranchTrueFalseTotal
my $class = {"acknowledgment" => "CSAF::Type::Acknowledgment","acknowledgments" => "CSAF::Type::Acknowledgments","aggregate_severity" => "CSAF::Type::AggregateSeverity","branch" => "CSAF::Type::Branch","branches" => "CSAF::Type::Branches","cvss_v2" => "CSAF::Type::CVSS2","cvss_v3" => "CSAF::Type::CVSS3","cwe" => "CSAF::Type::CWE","distribution" => "CSAF::Type::Distribution","document" => "CSAF::Type::Document","engine" => "CSAF::Type::Engine","file_hash" => "CSAF::Type::FileHash","file_hashes" => "CSAF::Type::FileHashes","flag" => "CSAF::Type::Flag","flags" => "CSAF::Type::Flags","full_product_name" => "CSAF::Type::FullProductName","full_product_names" => "CSAF::Type::FullProductNames","generator" => "CSAF::Type::Generator","generic_uri" => "CSAF::Type::GenericURI","generic_uris" => "CSAF::Type::GenericURIs","hash" => "CSAF::Type::Hash","hashes" => "CSAF::Type::Hashes","id" => "CSAF::Type::ID","ids" => "CSAF::Type::IDs","note" => "CSAF::Type::Note","notes" => "CSAF::Type::Notes","product" => "CSAF::Type::Product","product_group" => "CSAF::Type::ProductGroup","product_groups" => "CSAF::Type::ProductGroups","product_identification_helper" => "CSAF::Type::ProductIdentificationHelper","product_status" => "CSAF::Type::ProductStatus","product_tree" => "CSAF::Type::ProductTree","publisher" => "CSAF::Type::Publisher","reference" => "CSAF::Type::Reference","references" => "CSAF::Type::References","relationship" => "CSAF::Type::Relationship","relationships" => "CSAF::Type::Relationships","remediation" => "CSAF::Type::Remediation","remediations" => "CSAF::Type::Remediations","restart_required" => "CSAF::Type::RestartRequired","revision" => "CSAF::Type::Revision","revision_history" => "CSAF::Type::RevisionHistory","score" => "CSAF::Type::Score","scores" => "CSAF::Type::Scores","threat" => "CSAF::Type::Threat","threats" => "CSAF::Type::Threats","tlp" => "CSAF::Type::TLP","tracking" => "CSAF::Type::Tracking","vulnerabilities" => "CSAF::Type::Vulnerabilities","vulnerability" => "CSAF::Type::Vulnerability"}->{$name} or Carp::croak("Unknown CSAF type") 87 0 87
85  
86 87 ▶ if ($class->can('new') or eval "require $class; 1") {
Branch: 1 branch
BranchTrueFalseTotal
if ($class->can("new") or eval "require $class; 1") 78 9 87
Condition100%3/3
$class->can("new") or eval "require $class; 1"
l!l&&r!l&&!r
44349
MC/DC100%2/2
$class->can("new") or eval "require $class; 1"
$class->can("new") eval "require $class; 1"
Truth table100%3/3
A or B
A= $class->can("new")B= eval "require $class; 1"
ABresult
1X1
011
000
87 78 local $Carp::Internal{caller()} = 1;
88 78 return $class->new($value);
89 }
90  
91 }
92  
93 2 1;
94  
95 __END__
« CSAF/Validator/Schema.pm ↑ Summary CSAF/Util/List.pm »