| 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
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 87 | ▶ | if ($class->can('new') or eval "require $class; 1") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$class->can("new") or eval "require $class; 1"
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"
| |||||||||||||||||||||||||||||
| 87 | 78 | local $Carp::Internal{caller()} = 1; | |||||||||||||||||||||||||||
| 88 | 78 | return $class->new($value); | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 2 | 1; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | __END__ | ||||||||||||||||||||||||||||