CSAF/Schema.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 43 CC 1 SCAR 6.9
CC
1
Cov
0%
validator
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package CSAF::Schema;
2  
3 use 5.010001;
4 use strict;
5 use warnings;
6 use utf8;
7  
8 use CSAF::Util qw(schema_cache_path);
9 use JSON::Validator;
10  
11  
12 our %SCHEMAS = (
13 'csaf-2.0' => 'https://docs.oasis-open.org/csaf/csaf/v2.0/os/schemas/csaf_json_schema.json',
14 'strict-csaf-2.0' => 'https://docs.oasis-open.org/csaf/csaf/v2.0/os/schemas/csaf_json_schema.json?strict',
15 'csaf-2.0-provider' => 'https://docs.oasis-open.org/csaf/csaf/v2.0/os/schemas/provider_json_schema.json',
16 'csaf-2.0-aggregator' => 'https://docs.oasis-open.org/csaf/csaf/v2.0/os/schemas/aggregator_json_schema.json',
17  
18 'cvss-v3.1' => 'https://www.first.org/cvss/cvss-v3.1.json',
19 'cvss-v3.0' => 'https://www.first.org/cvss/cvss-v3.0.json',
20 'cvss-v2.0' => 'https://www.first.org/cvss/cvss-v2.0.json',
21  
22 'cvss-v3.x' => {
23 oneOf => [
24 {'$ref' => 'https://www.first.org/cvss/cvss-v3.0.json'},
25 {'$ref' => 'https://www.first.org/cvss/cvss-v3.1.json'}
26 ]
27 }
28 );
29  
30 sub validator {
31  
32 my ($class, $schema) = @_;
33  
34 my $jv = JSON::Validator->new;
35  
36 $jv->cache_paths([schema_cache_path]);
37 $jv->schema($SCHEMAS{$schema} || $schema);
38  
39 return $jv;
40  
41 }
42  
43 1;
44  
45 __END__