blib/lib/NIST/NVD/Store/SQLite3.pm

filter: Statementstmt 32.5% 114 / 350 Branchbran 16.1% 20 / 124 Conditioncond 28.5% 4 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 51.5% 17 / 33 Podpod 100% 16 / 16 totaltotal 31.3% 171 / 546 CC 89 SCAR 36.7
CC
89
Cov
28%
update_websec_idx_cpe
156.0
put_cve_idx_cpe
56.0
put_cpe
56.0
CRAP 39.4
↑ Summary
1 package NIST::NVD::Store::SQLite3;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 ▶use NIST::NVD::Store::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 ▶use base qw{NIST::NVD::Store::Base};
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 7 our @ISA;
11 7 push @ISA, qw{NIST::NVD::Store::Base};
12  
13 7 ▶use Carp(qw(carp confess cluck));
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 7 ▶use Storable qw(nfreeze thaw);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 7 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 7 ▶use Time::HiRes qw( gettimeofday );
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 =head1 NAME
20  
21 NIST::NVD::Store::SQLite3 - SQLite3 store for NIST::NVD
22  
23 =head1 VERSION
24  
25 Version 1.02.00
26  
27 =cut
28  
29 7 our $VERSION = '1.02.00';
30  
31 7 my %query = (
32 cpe_create => qq{
33 CREATE TABLE IF NOT EXISTS cpe (
34 id INTEGER PRIMARY KEY AUTOINCREMENT,
35 urn VARCHAR(64) CONSTRAINT uniq_urn UNIQUE ON CONFLICT FAIL,
36  
37 part CHAR,
38 vendor VARCHAR(16),
39 product VARCHAR(16),
40 version VARCHAR(16),
41 updt VARCHAR(16),
42 edition VARCHAR(16),
43 language VARCHAR(4)
44 )},
45 cve_create => qq{
46 CREATE TABLE IF NOT EXISTS cve (
47 id INTEGER PRIMARY KEY AUTOINCREMENT,
48 score REAL,
49 cve_id VARCHAR(16) CONSTRAINT uniq_cve_id UNIQUE ON CONFLICT FAIL,
50 cve_dump BLOB
51 )},
52 cwe_create => qq{
53 CREATE TABLE IF NOT EXISTS cwe (
54 id INTEGER PRIMARY KEY AUTOINCREMENT,
55 cwe_id VARCHAR(16) CONSTRAINT uniq_cwe_id UNIQUE ON CONFLICT FAIL,
56 cwe_dump BLOB
57 )},
58 cpe_cve_map_create => qq{
59 CREATE TABLE IF NOT EXISTS cpe_cve_map (
60 id INTEGER PRIMARY KEY AUTOINCREMENT,
61  
62 cpe_id INTEGER,
63 cve_id INTEGER,
64 CONSTRAINT uniq_cpe_cve UNIQUE ( cpe_id, cve_id ) ON CONFLICT FAIL
65 )},
66 cpe_cwe_map_create => qq{
67 CREATE TABLE IF NOT EXISTS cpe_cwe_map (
68 id INTEGER PRIMARY KEY AUTOINCREMENT,
69  
70 cpe_id INTEGER,
71 cwe_id INTEGER,
72 CONSTRAINT uniq_cpe_cwe UNIQUE ( cpe_id, cwe_id ) ON CONFLICT IGNORE
73 )},
74 cve_cwe_map_create => qq{
75 CREATE TABLE IF NOT EXISTS cve_cwe_map (
76 id INTEGER PRIMARY KEY AUTOINCREMENT,
77  
78 cve_id INTEGER,
79 cwe_id VARCHAR(64),
80 CONSTRAINT uniq_cve_cwe UNIQUE ( cve_id, cwe_id ) ON CONFLICT IGNORE
81 )},
82 websec_create => qq{
83 CREATE TABLE IF NOT EXISTS cpe_websec_score (
84 id INTEGER PRIMARY KEY AUTOINCREMENT,
85  
86 cpe_urn VARCHAR(64) UNIQUE,
87 cat_a0 REAL,
88 cat_a1 REAL,
89 cat_a2 REAL,
90 cat_a3 REAL,
91 cat_a4 REAL,
92 cat_a5 REAL,
93 cat_a6 REAL,
94 cat_a7 REAL,
95 cat_a8 REAL,
96 cat_a9 REAL,
97 cat_a10 REAL
98  
99 )},
100 verify_cwe_pkid => qq{
101 SELECT cwe_id,id FROM cwe WHERE id=?
102 },
103 cve_for_cpe_select => qq{
104 SELECT cve.cve_id
105 FROM cpe_cve_map,cve
106 WHERE cpe_cve_map.cpe_id=?
107 AND cpe_cve_map.cve_id=cve.id
108 ORDER BY cve.cve_id
109 },
110 cwe_for_cpe_select => qq{
111 SELECT cwe.cwe_id
112 FROM cpe_cwe_map,cwe
113 WHERE cpe_cwe_map.cpe_id=?
114 AND cpe_cwe_map.cwe_id=cwe.id
115 ORDER BY cwe.cwe_id
116 },
117 get_cpe_id_select => qq{
118 SELECT id FROM cpe WHERE cpe.urn=?
119 },
120 get_cve_id_select => qq{
121 SELECT id FROM cve WHERE cve.cve_id=?
122 },
123 get_cwe_id_select => qq{
124 SELECT id FROM cwe WHERE cwe.cwe_id=?
125 },
126 get_cve_select => qq{
127 SELECT cve_dump FROM cve WHERE cve.cve_id=?
128 },
129 get_websec_score_select_by_cpe => qq{
130 SELECT cat_a0, cat_a1, cat_a2, cat_a3, cat_a4, cat_a5, cat_a6, cat_a7,
131 cat_a8, cat_a9, cat_a10 FROM cpe_websec_score WHERE cpe_urn=?
132 },
133 get_cve_id_select_by_pkey => qq{
134 SELECT id,cve_id FROM cve WHERE id=?
135 },
136 get_cve_id_select_by_friendly => qq{
137 SELECT id,cve_id FROM cve WHERE cve_id=?
138 },
139 get_cwe_select => qq{
140 SELECT id,cwe_dump FROM cwe WHERE cwe.cwe_id=?
141 },
142 put_cve_idx_cpe_insert => qq{
143 INSERT INTO cpe_cve_map (cpe_id,cve_id)
144 VALUES ( ?, ? )
145 },
146 put_cwe_idx_cpe_insert => qq{
147 INSERT INTO cpe_cwe_map (cpe_id,cwe_id)
148 VALUES ( ?, ? )
149 },
150 put_cwe_idx_cve_insert => qq{
151 INSERT INTO cve_cwe_map (cve_id,cwe_id)
152 VALUES ( ?, ? )
153 },
154 put_cve_insert => qq{
155 INSERT INTO cve ( cve_dump, score, cve_id ) VALUES (?, ?, ?)
156 },
157 put_cve_update => qq{
158 UPDATE cve SET cve_dump=?, score=? WHERE cve.id=?
159 },
160 put_cwe_insert => qq{
161 INSERT INTO cwe ( cwe_dump, cwe_id ) VALUES (?, ?)
162 },
163 put_cwe_update => qq{
164 UPDATE cwe SET cwe_dump=? WHERE cwe.id=?
165 },
166 put_cpe_insert => qq{
167 INSERT INTO cpe ( urn,part,vendor,product,version,updt,edition,language )
168 VALUES( ?,?,?,?,?,?,?,? )
169 }
170  
171 );
172  
173 7 my %sth = ();
174  
175 =head1 SYNOPSIS
176  
177 $q =
178 eval { NIST::NVD::Query->new( store => 'SQLite3', database => $db_file, ); };
179  
180  
181 =head1 SUBROUTINES/METHODS
182  
183 =head2 new
184  
185 my $NVD_Storage_SQLite3 = NIST::NVD::Store::SQLite3->new(
186 store => 'SQLite3',
187 database => '/path/to/database.sqlite',
188 );
189  
190 =cut
191  
192 5 ▶sub new {
Subroutine new: called CC=7 SCAR=21.8
Pod documented
193 5 my ( $class, %args ) = @_;
194 5 ▶ $class = ref $class || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
050
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
195  
196 # my $self = $class->SUPER::new(%args);
197  
198 5 my $self = bless { store => $args{store} }, $class;
199  
200 5 my $store = $args{store};
201  
202 5 ▶ unless ( exists $args{database} && $args{database} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"database"} and $args{"database"}) 0 5 5
Condition33%1/3
exists $args{"database"} and $args{"database"}
!ll&&!rl&&r
005
MC/DC0%0/2
exists $args{"database"} and $args{"database"}
exists $args{"database"} $args{"database"}
Truth table33%1/3
A and B
A= exists $args{"database"}B= $args{"database"}
ABresult
0X0
100
111
203 0 confess('database argument is required, but was not passed');
204 0 return;
205 }
206  
207 5 $self->{$store} = $self->_connect_db( database => $args{database} );
208  
209 5 $self->{sqlite} = $self->{SQLite3};
210  
211 5 $self->{vuln_software} = {};
212  
213 5 foreach my $statement (
214 qw( put_cpe_insert
215 cve_for_cpe_select cwe_for_cpe_select
216 put_cve_idx_cpe_insert
217 put_cwe_idx_cpe_insert
218 put_cwe_idx_cve_insert
219 put_cve_insert put_cve_update
220 put_cwe_insert put_cwe_update
221 get_cpe_id_select
222 get_cve_id_select get_cve_select
223 get_cwe_id_select get_cwe_select
224 get_cve_id_select_by_pkey
225 get_cve_id_select_by_friendly
226 get_websec_score_select_by_cpe
227 )
228 )
229 {
230 90 ▶ $sth{$statement} = $self->{sqlite}->prepare( $query{$statement} )
Branch: 1 branch
BranchTrueFalseTotal
$sth{$statement} = $self->{"sqlite"}->prepare($query{$statement}) or die "couldn't prepare statement '${statement}'" 90 0 90
231 or die "couldn't prepare statement '$statement'";
232 }
233 5 my $fail = 0;
234  
235 5 ▶ return if $fail;
Branch: 1 branch
BranchTrueFalseTotal
if $fail 0 5 5
236  
237 5 return $self;
238 }
239  
240 5 ▶sub _connect_db {
Subroutine _connect_db: called CC=3 SCAR=11.2
241 5 my ( $self, %args ) = @_;
242  
243 5 my $dbh = DBI->connect( "dbi:SQLite:dbname=$args{database}", "", "" );
244  
245 5 foreach my $statement (
246 qw(
247 cpe_create websec_create
248 cve_cwe_map_create
249 cve_create cpe_cve_map_create
250 cwe_create cpe_cwe_map_create
251 verify_cwe_pkid
252 )
253 )
254 {
255  
256 40 my $query = $query{$statement};
257  
258 40 ▶ $sth{$statement} //= $dbh->prepare($query);
Condition33%1/3
$sth{$statement} //= $dbh->prepare($query)
l!l&&r!l&&!r
0400
MC/DC0%0/2
$sth{$statement} //= $dbh->prepare($query)
$sth{$statement} $dbh->prepare($query)
Truth table33%1/3
A //= B
A= $sth{$statement}B= $dbh->prepare($query)
ABresult
1X1
011
000
259 40 $sth{$statement}->execute();
260 }
261  
262 5 return $dbh;
263 }
264  
265 =head2 get_cve_for_cpe
266  
267 =cut
268  
269 7 my $cpe_urn_re = qr{^(cpe:/(.)(:[^:]+){2,6})$};
270  
271 6 ▶sub get_cve_for_cpe {
Subroutine get_cve_for_cpe: called CC=4 SCAR=14.2
Pod documented
272 6 my ( $self, %args ) = @_;
273  
274 6 my $cpe = $args{cpe};
275  
276 6 ▶ return unless $cpe;
Branch: 1 branch
BranchTrueFalseTotal
unless $cpe 1 5 6
277  
278 5 my $cpe_pkey_id;
279 5 ▶ if ( $cpe =~ /^\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cpe =~ /^\d+$/) { } 0 5 5
280 0 $cpe_pkey_id = $cpe;
281 }
282 else {
283 5 ( my ( $cpe, @parts ) ) = ( $args{cpe} =~ $cpe_urn_re );
284 5 $cpe_pkey_id = $self->_get_cpe_id($cpe);
285 }
286  
287 5 $sth{cve_for_cpe_select}->execute($cpe_pkey_id);
288  
289 5 my $cve_id = [];
290  
291 5 ▶ while ( my $row = $sth{cve_for_cpe_select}->fetchrow_hashref() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth{"cve_for_cpe_select"}->fetchrow_hashref) 0 5 5
292 0 push( @$cve_id, $row->{'cve_id'} );
293 }
294  
295 5 return $cve_id;
296 }
297  
298 =head2 get_cwe_for_cpe
299  
300 =cut
301  
302 1 ▶sub get_cwe_for_cpe {
Subroutine get_cwe_for_cpe: called CC=4 SCAR=14.6
Pod documented
303 1 my ( $self, %args ) = @_;
304  
305 1 my $cpe = $args{cpe};
306  
307 1 ▶ return unless $cpe;
Branch: 1 branch
BranchTrueFalseTotal
unless $cpe 0 1 1
308  
309 1 my $cpe_pkey_id;
310 1 ▶ if ( $cpe =~ /^\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cpe =~ /^\d+$/) { } 0 1 1
311 0 $cpe_pkey_id = $cpe;
312 }
313 else {
314 1 ( my ( $cpe, @parts ) ) = ( $args{cpe} =~ $cpe_urn_re );
315 1 $cpe_pkey_id = $self->_get_cpe_id($cpe);
316 }
317  
318 1 $sth{cwe_for_cpe_select}->execute($cpe_pkey_id);
319  
320 1 my $cwe_id = [];
321  
322 1 ▶ while ( my $row = $sth{cwe_for_cpe_select}->fetchrow_hashref() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth{"cwe_for_cpe_select"}->fetchrow_hashref) 0 1 1
323 0 push( @$cwe_id, $row->{'cwe_id'} );
324 }
325  
326 1 return $cwe_id;
327 }
328  
329 7 my %cve_id_cache;
330  
331 0 ▶sub _get_cve_id {
Subroutine _get_cve_id: not called CC=5 SCAR=34.0
332 0 my ( $self, $cve_id ) = @_;
333  
334 0 ▶ return @{ $cve_id_cache{$cve_id} } if exists $cve_id_cache{$cve_id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $cve_id_cache{$cve_id} 0 0 0
335  
336 0 my $sth;
337 my $query;
338  
339 0 ▶ if ( $cve_id =~ /^\d+$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cve_id =~ /^\d+$/) { } 0 0 0
elsif ($cve_id =~ /^CVE-\d+-\d+/) { } 0 0 0
340 0 $sth = $sth{get_cve_id_select_by_pkey};
341 }
342 elsif ( $cve_id =~ /^CVE-\d+-\d+/ ) {
343 0 $sth = $sth{get_cve_id_select_by_friendly};
344 }
345 else {
346 0 confess "cve id malformed\n";
347 0 die;
348 }
349  
350 0 $sth->execute($cve_id);
351 0 my $row = $sth->fetchrow_hashref();
352 0 ▶ return unless $row;
Branch: 1 branch
BranchTrueFalseTotal
unless $row 0 0 0
353  
354 0 $cve_id_cache{$cve_id} = [ $row->{id}, $row->{cve_id} ];
355  
356 0 return ( $row->{id}, $row->{cve_id} );
357 }
358  
359 my %cwe_id_cache;
360  
361 0 ▶sub _get_cwe_id {
Subroutine _get_cwe_id: not called CC=5 SCAR=34.0
362 0 my ( $self, $cwe_id ) = @_;
363  
364 0 ▶ return @{ $cwe_id_cache{$cwe_id} } if exists $cwe_id_cache{$cwe_id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $cwe_id_cache{$cwe_id} 0 0 0
365  
366 0 my $sth;
367  
368 0 ▶ if ( $cwe_id =~ /^\d+$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cwe_id =~ /^\d+$/) { } 0 0 0
elsif ($cwe_id =~ /^CWE-\d+/) { } 0 0 0
369 0 $sth = $self->{sqlite}->prepare('SELECT id,cwe_id FROM cwe WHERE id=?');
370  
371 }
372 elsif ( $cwe_id =~ /^CWE-\d+/ ) {
373  
374 $sth =
375 0 $self->{sqlite}->prepare('SELECT id,cwe_id FROM cwe WHERE cwe_id=?');
376 }
377 else {
378 0 cluck "cwe id malformed\n";
379 0 return;
380 }
381  
382 0 $sth->execute($cwe_id);
383 0 my $row = $sth->fetchrow_hashref();
384  
385 0 ▶ unless ($row) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($row) 0 0 0
386 0 return;
387 }
388  
389 0 $cwe_id_cache{$cwe_id} = [ $row->{qw{id cwe_id}} ];
390 \
391  
392 0 return ( $row->{qw{id cwe_id}} );
393 }
394  
395 8 ▶sub _get_cpe_id {
Subroutine _get_cpe_id: called CC=4 SCAR=16.6
396 8 my ( $self, $cpe_urn ) = @_;
397  
398 return $self->{cpe_map}->{$cpe_urn}
399 8 ▶ if ( exists $self->{cpe_map}->{$cpe_urn} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"cpe_map"}{$cpe_urn} 0 8 8
400  
401 8 $sth{get_cpe_id_select}->execute($cpe_urn);
402  
403 # TODO: Assert that this query only returns one result
404 8 my $rows = 0;
405 8 ▶ while ( my $row = $sth{get_cpe_id_select}->fetchrow_hashref() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth{"get_cpe_id_select"}->fetchrow_hashref) 0 8 8
406 0 ▶ carp
Branch: 1 branch
BranchTrueFalseTotal
if $rows != 0 0 0 0
407 "multiple ($rows) results for value intended to be unique. cpe_urn: [$cpe_urn]\n"
408 if ( $rows != 0 );
409 0 $self->{cpe_map}->{$cpe_urn} = $row->{id};
410 }
411  
412 8 return $self->{cpe_map}->{$cpe_urn};
413 }
414  
415 1 ▶sub _get_query {
Subroutine _get_query: called CC=3 SCAR=11.4
416 1 my ( $self, $query_name ) = @_;
417  
418 1 ▶ return $query{$query_name}
Branch: 1 branch
BranchTrueFalseTotal
if $query_name 0 1 1
419 if ($query_name);
420  
421 1 ▶ return %query if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
422  
423 1 return \%query;
424 }
425  
426 3 ▶sub _get_sth {
Subroutine _get_sth: called CC=5 SCAR=20.9
427 3 my ( $self, $query_name ) = @_;
428  
429 3 ▶ return unless exists $query{$query_name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $query{$query_name} 0 3 3
430  
431 3 ▶ if ($query_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($query_name) 3 0 3
432 3 ▶ $sth{$query_name} //= $self->{sqlite}->prepare( $query{$query_name} );
Condition33%1/3
$sth{$query_name} //= $self->{"sqlite"}->prepare($query{$query_name})
l!l&&r!l&&!r
300
MC/DC0%0/2
$sth{$query_name} //= $self->{"sqlite"}->prepare($query{$query_name})
$sth{$query_name} $self->{"sqlite"}->prepare($query{$query_name})
Truth table33%1/3
A //= B
A= $sth{$query_name}B= $self->{"sqlite"}->prepare($query{$query_name})
ABresult
1X1
011
000
433 3 return $sth{$query_name};
434 }
435  
436 0 ▶ return %sth if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
437  
438 0 return \%sth;
439 }
440  
441 0 ▶sub _prepare {
Subroutine _prepare: not called CC=1 SCAR=0.0
442  
443 }
444  
445 =head2 get_cve
446  
447  
448 =cut
449  
450 3 ▶sub get_cve {
Subroutine get_cve: called CC=2 SCAR=7.2
Pod documented
451 3 my ( $self, %args ) = @_;
452  
453 3 $sth{get_cve_select}->execute( $args{cve_id} );
454  
455 3 my $row = $sth{get_cve_select}->fetchrow_hashref();
456  
457 3 my $frozen = $row->{cve_dump};
458  
459 3 my $entry = eval { thaw $frozen };
460 3 ▶ if (@$) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$) 0 3 3
461 0 carp "Storable::thaw had a major malfunction.";
462 0 return;
463 }
464  
465 3 return $entry;
466 }
467  
468 7 my %injection = ( OWASP => 'A1', );
469 7 my %xss = ( OWASP => 'A2', );
470 7 my %authn_session = ( OWASP => 'A3', );
471  
472 7 my %latest_OWASP_ten = (
473 'A1' => {
474 id => 'CWE-810',
475 members => [ 'CWE-78', 'CWE-88', 'CWE-89', 'CWE-90', 'CWE-91', ],
476 },
477 'A2' => {
478 id => 'CWE-811',
479 members => [ 'CWE-79', ],
480 },
481  
482 'A3' => {
483 id => 'CWE-812',
484 members => [ 'CWE-287', 'CWE-306', 'CWE-307', 'CWE-798', 'CWE-798', ],
485 },
486 'A4' => {
487 id => 'CWE-813',
488 members =>
489 [ 'CWE-22', 'CWE-434', 'CWE-639', 'CWE-829', 'CWE-862', 'CWE-863' ]
490 },
491 'A5' => { id => 'CWE-814', members => ['CWE-352'] },
492 'A6' => {
493 id => 'CWE-815',
494 members =>
495 [ 'CWE-209', 'CWE-219', 'CWE-250', 'CWE-538', 'CWE-552', 'CWE-732', ]
496 },
497 'A7' => {
498 id => 'CWE-816',
499 members => [ 'CWE-311', 'CWE-312', 'CWE-326', 'CWE-327', 'CWE-759', ]
500 },
501 'A8' => {
502 id => 'CWE-817',
503 members => [ 'CWE-284', 'CWE-862', 'CWE-863', ]
504 },
505 'A9' => {
506 id => 'CWE-818',
507 members => [ 'CWE-311', 'CWE-319', ]
508 },
509 'A10' => {
510 id => 'CWE-819',
511 members => [ 'CWE-601', ]
512 },
513 );
514  
515 7 my %owasp_idx;
516  
517 7 foreach my $cat (qw( A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 )) {
518 70 foreach my $cwe_id ( @{ $latest_OWASP_ten{$cat}->{members} } ) {
519 245 $owasp_idx{$cwe_id} = $cat;
520 }
521 }
522  
523 =head2 get_cwe
524  
525 my $cwe_dump = $self->get_cwe( id => $cwe_row->{id} );
526 or
527 my $cwe_dump = $self->get_cwe( cwe_id => $cwe_row->{cwe_id} );
528  
529 =cut
530  
531 1 ▶sub get_cwe {
Subroutine get_cwe: called CC=6 SCAR=30.3
Pod documented
532 1 my ( $self, %args ) = @_;
533  
534 1 my $sth;
535  
536 my $arg;
537  
538 1 ▶ if ( exists $args{id} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $args{'id'}) { } 0 1 1
elsif (exists $args{'cwe_id'}) { } 1 0 1
539 0 ▶ die "id [$args{id}] is malformed" unless $args{id} =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"id"} =~ /^\d+$/ 0 0 0
540 0 $sth = $self->{sqlite}->prepare('SELECT cwe_dump FROM cwe WHERE id=?');
541 0 $arg = $args{id};
542 }
543 elsif ( exists $args{cwe_id} ) {
544 die "cwe_id [$args{cwe_id}] is malformed"
545 1 ▶ unless $args{cwe_id} =~ /^CWE-\d+/;
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"cwe_id"} =~ /^CWE-\d+/ 1 0 1
546 $sth =
547 0 $self->{sqlite}->prepare('SELECT cwe_dump FROM cwe WHERE cwe_id=?');
548 0 $arg = $args{cwe_id};
549 }
550  
551 0 $sth->execute($arg);
552  
553 0 my $frozen = $sth->fetchrow_hashref()->{cwe_dump};
554  
555 0 my $data = eval { thaw $frozen };
556 0 ▶ if (@$) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$) 0 0 0
557 0 carp "Storable::thaw had a major malfunction.";
558 0 return;
559 }
560  
561 0 return $data;
562 }
563  
564 =head2 put_cve_idx_cpe
565  
566 my %vuln_software = ( $cpe_urn0 => [ $cve_id0,$cve_id42,... ],
567 $cpe_urn1 => [ $cve_id1,$cve_id24,... ],
568 # ...,
569 $cpe_urnN => [ $cve_id2,$cve_id3,... ],
570 );
571 $Updater->put_cve_idx_cpe( \%vuln_software );
572  
573 =cut
574  
575 7 my %uniq_cve_idx_cpe;
576  
577 0 ▶sub put_cve_idx_cpe {
Subroutine put_cve_idx_cpe: not called CC=7 SCAR=40.3
Pod documented
578 0 my ( $self, $vuln_software ) = @_;
579  
580 0 my @params;
581 0 ▶ while ( my ( $cpe_urn, $cve_id ) = ( each %$vuln_software ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$vuln_software) 0 0 0
582 0 my $cpe_pkey_id = $self->_get_cpe_id($cpe_urn);
583  
584 0 foreach my $id (@$cve_id) {
585 0 my ( $cve_pkey, $cve_friendly ) = $self->_get_cve_id($id);
586 0 ▶ next unless $cve_pkey;
Branch: 1 branch
BranchTrueFalseTotal
unless $cve_pkey 0 0 0
587 0 ▶ next if $uniq_cve_idx_cpe{$cpe_pkey_id}->{$cve_pkey}++;
Branch: 1 branch
BranchTrueFalseTotal
if $uniq_cve_idx_cpe{$cpe_pkey_id}{$cve_pkey}++ 0 0 0
588 0 push( @params, [ $cpe_pkey_id, $cve_pkey ] );
589 }
590 }
591  
592 0 $self->{sqlite}->do("BEGIN IMMEDIATE TRANSACTION");
593 0 $sth{put_cve_idx_cpe_insert}->execute(@$_) foreach (@params);
594 0 ▶ $self->{sqlite}->commit() or die $$self->{sqlite}->errstr;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"sqlite"}->commit or die $$self->{"sqlite"}->errstr 0 0 0
595 0 return;
596 }
597  
598 =head2 put_cwe_idx_cpe
599  
600 my %vuln_software = ( $cpe_urn0 => [ $cwe_id0,$cwe_id42,... ],
601 $cpe_urn1 => [ $cwe_id1,$cwe_id24,... ],
602 # ...,
603 $cpe_urnN => [ $cwe_id2,$cwe_id3,... ],
604 );
605 $Updater->put_cwe_idx_cpe( \%weaknesses );
606  
607 =cut
608  
609 my %uniq_cwe_idx_cpe;
610  
611 0 ▶sub put_cwe_idx_cpe {
Subroutine put_cwe_idx_cpe: not called CC=6 SCAR=37.4
Pod documented
612 0 my ( $self, $weaknesses ) = @_;
613  
614 0 my $initial_cwe_ids = $self->get_cwe_ids();
615  
616 0 my (%cpe_pkey_id) = map { $_ => $self->_get_cpe_id($_) } keys %$weaknesses;
617  
618 0 my @params;
619 0 ▶ while ( my ( $cpe_urn, $cwe_id ) = ( each %$weaknesses ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$weaknesses) 0 0 0
620 0 my $cpe_pkey_id = $cpe_pkey_id{$cpe_urn};
621  
622 0 foreach my $id (@$cwe_id) {
623 0 my $cwe_pkey_id = $initial_cwe_ids->{$id};
624  
625 0 ▶ unless ($cwe_pkey_id) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cwe_pkey_id) 0 0 0
626  
627 # print STDERR "no data for [$id]\n";
628 0 print 'x';
629 0 next;
630 }
631  
632 0 ▶ next if $uniq_cwe_idx_cpe{$cpe_pkey_id}->{$cwe_pkey_id}++;
Branch: 1 branch
BranchTrueFalseTotal
if $uniq_cwe_idx_cpe{$cpe_pkey_id}{$cwe_pkey_id}++ 0 0 0
633 0 push( @params, [ $cpe_pkey_id, $cwe_pkey_id ] );
634 }
635 }
636  
637 0 $self->{sqlite}->do("BEGIN IMMEDIATE TRANSACTION");
638 0 $sth{put_cwe_idx_cpe_insert}->execute(@$_) foreach (@params);
639 0 $self->{sqlite}->commit();
640 0 return;
641 }
642  
643 =head2 update_websec_idx_cpe
644  
645 $Updater->update_websec_idx_cpe({ cpe_urn[$i] => [ $cwe_id[20], $cwe_id[7], $cwe_id[235], ... $cwe_id[$n], ],
646 cpe_urn[$j] => [ $cwe_id[42], $cwe_id[$k], $cwe_id[72], ... $cwe_id[$j], ],
647 ... => });
648  
649 =cut
650  
651 0 ▶sub update_websec_idx_cpe {
Subroutine update_websec_idx_cpe: not called CC=12 SCAR=50.5
Pod documented
652 0 my ($self) = @_;
653  
654 # walk through each cpe urn
655  
656 0 my $dbh = $self->{sqlite};
657  
658 0 my $q = "SELECT id, urn FROM cpe";
659 0 my $cpe_sth = $dbh->prepare($q);
660  
661 0 $q = "SELECT cve_id FROM cpe_cve_map WHERE cpe_id=?";
662 0 my $cve_sth = $dbh->prepare($q);
663  
664 0 $q = "SELECT score FROM cve WHERE id=?";
665 0 my $cve_score_sth = $dbh->prepare($q);
666  
667 0 $q = "SELECT cwe_id FROM cve_cwe_map WHERE cve_id=?";
668 0 my $cwe_sth = $dbh->prepare($q);
669  
670 0 my $cwe_idx_cpe_sth = $self->_get_sth('put_cwe_idx_cpe_insert');
671  
672 0 $q =
673 ( "INSERT INTO cpe_websec_score ("
674 . "cpe_urn,cat_a0,cat_a1,cat_a2,cat_a3,cat_a4,cat_a5,cat_a6,cat_a7,cat_a8,cat_a9,cat_a10"
675 . ") VALUES ("
676 . "?,?,?,?,?,?,?,?,?,?,?,?"
677 . ")" );
678 0 my $score_sth = $dbh->prepare($q);
679  
680 0 $cpe_sth->execute();
681  
682 0 my @idx_args = ();
683  
684 0 my $websec_score = {};
685  
686 0 ▶ while ( my $cpe_row = $cpe_sth->fetchrow_hashref() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cpe_row = $cpe_sth->fetchrow_hashref) 0 0 0
687  
688 # for each cpe, find all CVEs
689 0 $cve_sth->execute( $cpe_row->{id} );
690 0 ▶ while ( my $cve_row = $cve_sth->fetchrow_hashref() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cve_row = $cve_sth->fetchrow_hashref) 0 0 0
691  
692 0 $cve_score_sth->execute( $cve_row->{cve_id} );
693 0 my $cve_score_row = $cve_score_sth->fetchrow_hashref();
694  
695 0 my $score = $cve_score_row->{score};
696  
697 my ( $cve_pkey, $cve_friendly ) =
698 0 $self->_get_cve_id( $cve_row->{cve_id} );
699  
700 # for each CVE, find all CWEs
701 0 $cwe_sth->execute($cve_friendly);
702  
703 0 ▶ while ( my $cwe_row = $cwe_sth->fetchrow_hashref() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cwe_row = $cwe_sth->fetchrow_hashref) 0 0 0
704 0 my $cwe_id = $cwe_row->{cwe_id};
705 0 push( @idx_args, [ $cpe_row->{id}, $cwe_id ] );
706  
707 0 ▶ my $owasp_cat = $owasp_idx{$cwe_id} // 'other';
Condition0%0/2
$owasp_idx{$cwe_id} // "other"
l!l
00
MC/DC0%0/1
$owasp_idx{$cwe_id} // "other"
$owasp_idx{$cwe_id}
Truth table0%0/2
A
A= $owasp_idx{$cwe_id}
Aresult
11
00
708  
709 push(
710 0 @{ $websec_score->{ $cpe_row->{urn} }->{$owasp_cat} },
711 {
712 cwe_id => $cwe_id,
713 cve_id => $cve_friendly,
714 score => $score,
715 },
716 );
717 }
718  
719 }
720 }
721  
722 0 my @websec_score;
723 0 foreach my $cpe_urn ( keys %$websec_score ) {
724 0 my $score = $websec_score->{$cpe_urn};
725 0 my @score;
726 0 foreach my $cat (qw( other A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 )) {
727 0 ▶ if ( exists $score->{$cat} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $score->{$cat}) { } 0 0 0
728 0 my $final = 0;
729 0 foreach my $s ( @{ $score->{$cat} } ) {
730 0 ▶ $final = $s->{score} if $s->{score} > $final;
Branch: 1 branch
BranchTrueFalseTotal
if $s->{"score"} > $final 0 0 0
731 }
732 0 push( @score, $final );
733 }
734 else {
735 0 push( @score, 0 );
736 }
737 }
738 0 push( @websec_score, [ $cpe_urn, @score ] );
739 }
740  
741 0 $self->{sqlite}->do("BEGIN IMMEDIATE TRANSACTION");
742 0 $score_sth->execute(@$_) foreach @websec_score;
743 0 $cwe_idx_cpe_sth->execute(@$_) foreach @idx_args;
744 0 $self->{sqlite}->commit();
745  
746 }
747  
748 =head2 put_cpe
749  
750  
751 =cut
752  
753 7 my %inserted_cpe;
754  
755 0 ▶sub put_cpe {
Subroutine put_cpe: not called CC=7 SCAR=40.3
Pod documented
756 0 my ( $self, $cpe_urn ) = @_;
757  
758 0 ▶ $cpe_urn = [$cpe_urn] unless ( ref $cpe_urn eq 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cpe_urn eq "ARRAY" 0 0 0
759  
760 0 my %cpe_urn = map { $_ => 1 } @$cpe_urn;
761 0 my $query = 'SELECT id,urn FROM cpe';
762 0 my $sth = $self->{sqlite}->prepare($query);
763  
764 0 ▶ while ( my $row = $sth->fetchrow_hashref() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
765 delete $cpe_urn{ $row->{cpe_urn} }
766 0 ▶ if exists $cpe_urn{ $row->{cpe_urn} };
Branch: 1 branch
BranchTrueFalseTotal
if exists $cpe_urn{$row->{"cpe_urn"}} 0 0 0
767 }
768  
769 0 my @params;
770 0 foreach my $urn ( keys %cpe_urn ) {
771 0 ▶ next if $inserted_cpe{$urn}++;
Branch: 1 branch
BranchTrueFalseTotal
if $inserted_cpe{$urn}++ 0 0 0
772  
773 my (
774 0 $prefix, $nada, $part, $vendor, $product,
775 $version, $update, $edition, $language
776 ) = split( m{[/:]}, $urn );
777  
778 0 push(
779 @params,
780 [
781 $urn, $part, $vendor, $product,
782 $version, $update, $edition, $language
783 ]
784 );
785 }
786  
787 0 $self->{sqlite}->do('BEGIN IMMEDIATE TRANSACTION');
788 0 $sth{put_cpe_insert}->execute(@$_) foreach @params;
789 0 $self->{sqlite}->commit();
790 }
791  
792 =head2 put_cve
793  
794  
795 =cut
796  
797 0 ▶sub put_cve {
Subroutine put_cve: not called CC=1 SCAR=0.0
Pod documented
798  
799 }
800  
801 =head2 put_nvd_entries
802  
803  
804 =cut
805  
806 0 ▶sub put_nvd_entries {
Subroutine put_nvd_entries: not called CC=7 SCAR=40.3
Pod documented
807 0 my ( $self, $entries ) = @_;
808  
809 0 my @insert_args;
810 my @update_args;
811  
812 0 ▶ while ( my ( $cve_id, $orig_entry ) = ( each %$entries ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$entries) 0 0 0
813 0 my $entry = {};
814  
815 0 foreach my $preserve ( $self->_important_fields() ) {
816 $entry->{$preserve} = $orig_entry->{$preserve}
817 0 ▶ if exists $orig_entry->{$preserve};
Branch: 1 branch
BranchTrueFalseTotal
if exists $orig_entry->{$preserve} 0 0 0
818 }
819  
820 0 my $frozen = nfreeze($entry);
821  
822 my $score =
823 0 $entry->{'vuln:cvss'}->{'cvss:base_metrics'}->{'cvss:score'};
824 0 my ( $pkey, $friendly ) = $self->_get_cve_id($cve_id);
825 0 my $sth;
826 0 my $cve_indexed = 0;
827  
828 # If the CVE is already in the database, update the record
829 0 ▶ if ($pkey) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkey) { } 0 0 0
830 0 push( @update_args, [ $frozen, $score, $cve_id ] );
831 }
832 else {
833 0 push( @insert_args, [ $frozen, $score, $cve_id ] );
834 }
835  
836 }
837  
838 0 $self->{sqlite}->do("BEGIN IMMEDIATE TRANSACTION");
839 0 $sth{put_cve_update}->execute(@$_) foreach @update_args;
840 0 $sth{put_cve_insert}->execute(@$_) foreach @insert_args;
841 0 $self->{sqlite}->commit();
842  
843 }
844  
845 =head2 put_cwe
846  
847 $result = $self->put_cwe( cwe_id => 'CWE-42',
848 cwe_dump => $cwe_dump );
849  
850 =cut
851  
852 7 my $commit_buffer = {};
853  
854 0 ▶sub put_cwe {
Subroutine put_cwe: not called CC=2 SCAR=17.9
Pod documented
855 0 my ( $self, %args ) = @_;
856  
857 0 my $cwe_id = $args{cwe_id};
858 0 my $cwe_dump = $args{cwe_dump};
859  
860 0 ▶ if ( exists $args{transactional} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{'transactional'}) { } 0 0 0
861 0 push( @{ $commit_buffer->{put_cwe_insert} }, [ $cwe_dump, $cwe_id ] );
862 }
863 else {
864 0 $sth{put_cwe_insert}->execute( $cwe_dump, $cwe_id );
865 }
866  
867 0 return;
868 }
869  
870 =head2 put_cwe_idx_cve
871  
872 $result = $store->put_cwe_idx_cve({ $cve_id[0] => $entry[0],
873 $cve_id[1] => $entry[1],
874 # ...
875 $cve_id[$n] => $entry[$n],
876 });
877  
878 =cut
879  
880 0 ▶sub put_cwe_idx_cve {
Subroutine put_cwe_idx_cve: not called CC=7 SCAR=40.3
Pod documented
881 0 my ( $self, $entries ) = @_;
882  
883 0 my @cwe_idx_args;
884 0 my $num_cwes = 0;
885 0 ▶ while ( my ( $cve_id, $entry ) = ( each %$entries ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$entries) 0 0 0
886 0 my ( $pkey, $friendly ) = $self->_get_cve_id($cve_id);
887  
888 0 $num_cwes += scalar @{ $entry->{'vuln:cwe'} }
889 0 ▶ if exists $entry->{'vuln:cwe'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $entry->{"vuln:cwe"} 0 0 0
890  
891 # index the cve->cwe relation
892 0 foreach my $cwe_id ( @{ $entry->{'vuln:cwe'} } ) {
893  
894 0 my ( $cwe_friendly, $cwe_pkey );
895  
896 0 ▶ if ( $cwe_id =~ /^CWE-\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cwe_id =~ /^CWE-\d+$/) { } 0 0 0
897 0 $cwe_friendly = $cwe_id;
898 }
899 else {
900 0 ( $cwe_pkey, $cwe_friendly ) = $self->_get_cwe_id($cwe_id);
901 }
902  
903 0 ▶ next unless $cwe_friendly;
Branch: 1 branch
BranchTrueFalseTotal
unless $cwe_friendly 0 0 0
904  
905 0 push( @cwe_idx_args, [ $cve_id, $cwe_friendly ] );
906 }
907 }
908  
909 0 $self->{sqlite}->do("BEGIN IMMEDIATE TRANSACTION");
910 0 $sth{put_cwe_idx_cve_insert}->execute(@$_) foreach @cwe_idx_args;
911 0 $self->{sqlite}->commit();
912  
913 }
914  
915 0 ▶sub _commit {
Subroutine _commit: not called CC=2 SCAR=17.9
916 0 my ( $self, $buffer_name ) = @_;
917  
918 0 $self->{sqlite}->do('BEGIN IMMEDIATE TRANSACTION');
919 0 foreach my $row ( @{ $commit_buffer->{$buffer_name} } ) {
920 0 my (@bound) = @$row;
921 0 $sth{$buffer_name}->execute(@bound);
922 }
923 0 $self->{sqlite}->commit();
924 0 delete $commit_buffer->{$buffer_name};
925 }
926  
927 =head2 get_websec_by_cpe
928  
929 my $result = $store->get_websec_by_cpe( 'cpe:/a:apache:tomcat:6.0.28' );
930 while( my $websec = shift( @{$result->{websec_results}} ) ){
931 print( "$websec->{key} - $websec->{category}: ".
932 "$websec->{score}\n" );
933 }
934  
935 =cut
936  
937 7 my %cat_name = (
938 cat_a0 => 'Other',
939 cat_a1 => 'Injection',
940 cat_a2 => 'Cross-Site Scripting (XSS)',
941 cat_a3 => 'Broken Authentication and Session Management',
942 cat_a4 => 'Insecure Direct Object References',
943 cat_a5 => 'Cross-Site Request Forgery (CSRF)',
944 cat_a6 => 'Security Misconfiguration',
945 cat_a7 => 'Insecure Cryptographic Storage',
946 cat_a8 => 'Failure to Restrict URL Access',
947 cat_a9 => 'Insufficient Transport Layer Protection',
948 cat_a10 => 'Unvalidated Redirects and Forwards',
949 );
950  
951 0 ▶sub get_websec_by_cpe {
Subroutine get_websec_by_cpe: not called CC=3 SCAR=24.8
Pod documented
952 0 my ( $s, $self, $cpe ) = @_;
953  
954 0 my @websec_results;
955 0 my %results = ( websec_results => \@websec_results );
956  
957 0 my $sth = $sth{get_websec_score_select_by_cpe};
958  
959 0 $sth->execute($cpe);
960  
961 0 my $row = $sth->fetchrow_hashref();
962  
963 0 foreach my $key (
964 qw(cat_a0 cat_a1 cat_a2 cat_a3 cat_a4
965 cat_a5 cat_a6 cat_a7 cat_a8 cat_a9 cat_a10)
966 )
967 {
968 push(
969 @websec_results,
970 {
971 category => $cat_name{$key},
972 0 score => $row->{$key},
973 key => $key
974 }
975 );
976 }
977  
978 0 ▶ return %results if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
979  
980 0 return \%results;
981 }
982  
983 =head2 get_cwe_ids
984  
985 $result = $self->get_cwe_ids();
986 while( my( $cwe_id, $cwe_pkey_id ) = each %$result ){
987 ...
988 }
989  
990 =cut
991  
992 0 ▶sub get_cwe_ids {
Subroutine get_cwe_ids: not called CC=2 SCAR=17.9
Pod documented
993 0 my ($self) = @_;
994  
995 0 my $result = {};
996  
997 0 my $sth = $self->{sqlite}->prepare("SELECT cwe_id,id FROM cwe");
998  
999 0 $sth->execute();
1000  
1001 0 ▶ while ( my $row = $sth->fetchrow_hashref() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
1002 0 $result->{ $row->{cwe_id} } = $row->{id};
1003 }
1004  
1005 0 return $result;
1006 }
1007  
1008 =head2 put_cwe_data
1009  
1010 $cwe_data = { View => $view_data,
1011 Category => $category_data,
1012 Weakness => $weakness_data,
1013 Compound_Element => $compound_data,
1014 };
1015  
1016 $NVD_Updater->put_cwe_data($cwe_data);
1017  
1018 =cut
1019  
1020 0 ▶sub put_cwe_data {
Subroutine put_cwe_data: not called CC=7 SCAR=40.3
Pod documented
1021 0 my ( $self, $weakness_data ) = @_;
1022  
1023 0 my @insert_entries;
1024 my @update_entries;
1025  
1026 0 my $insert_sth = $sth{put_cwe_insert};
1027 0 my $update_sth = $sth{put_cwe_update};
1028  
1029 0 my $initial_cwe_ids = $self->get_cwe_ids();
1030  
1031 0 my $count = 0;
1032 0 foreach my $element (qw(View Category Weakness Compound_Element)) {
1033 0 my $data = $weakness_data->{$element};
1034 0 my %cwe_pkey_id;
1035  
1036 0 ▶ while ( my ( $k, $entry ) = ( each %$data ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$data) 0 0 0
1037  
1038 0 my ( $cwe_pkey_id, $cwe_id ) = $self->_get_cwe_id($k);
1039  
1040 0 ▶ $self->{cwe_pkey_id}->{$cwe_id} = $cwe_pkey_id if $cwe_id;
Branch: 1 branch
BranchTrueFalseTotal
if $cwe_id 0 0 0
1041  
1042 0 my $frozen = nfreeze($entry);
1043  
1044 0 ▶ if ($cwe_pkey_id) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cwe_pkey_id) { } 0 0 0
elsif ($k =~ /^CWE-\d+$/) { } 0 0 0
1045 0 push( @update_entries, [ $frozen, $cwe_pkey_id ] );
1046 }
1047 elsif ( $k =~ /^CWE-\d+$/ ) {
1048 0 push( @insert_entries, [ $frozen, $cwe_id ] );
1049 }
1050 else {
1051 0 carp "cwe id [$k] is unrecognized.\n";
1052 }
1053 0 ▶ print STDERR '.' if ( ++$count % 100 == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if ++$count % 100 == 0 0 0 0
1054 }
1055 }
1056  
1057 # $self->{sqlite}->do("BEGIN IMMEDIATE TRANSACTION");
1058 # $insert_sth->execute(@$_) foreach @insert_entries;
1059 # $update_sth->execute(@$_) foreach @update_entries;
1060 # $self->{sqlite}->commit();
1061  
1062 }
1063  
1064 0 ▶sub _important_fields {
Subroutine _important_fields: not called CC=1 SCAR=6.9
1065 0 return qw(
1066 vuln:cve-id
1067 vuln:cvss
1068 vuln:cwe
1069 vuln:discovered-datetime
1070 vuln:published-datetime
1071 vuln:discovered-datetime
1072 vuln:last-modified-datetime
1073 vuln:security-protection
1074 vuln:vulnerable-software-list
1075 );
1076  
1077 }
1078  
1079 =head1 AUTHOR
1080  
1081 C.J. Adams-Collier, C<< <cjac at f5.com> >>
1082  
1083 =head1 BUGS
1084  
1085 Please report any bugs or feature requests to C<bug-nist-nvd-store-sqlite3 at rt.cpan.org>, or through
1086 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=NIST-NVD-Store-SQLite3>. I will be notified, and then you'll
1087 automatically be notified of progress on your bug as I make changes.
1088  
1089  
1090  
1091  
1092 =head1 SUPPORT
1093  
1094 You can find documentation for this module with the perldoc command.
1095  
1096 perldoc NIST::NVD::Store::SQLite3
1097  
1098  
1099 You can also look for information at:
1100  
1101 =over 4
1102  
1103 =item * RT: CPAN's request tracker
1104  
1105 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=NIST-NVD-Store-SQLite3>
1106  
1107 =item * AnnoCPAN: Annotated CPAN documentation
1108  
1109 L<http://annocpan.org/dist/NIST-NVD-Store-SQLite3>
1110  
1111 =item * CPAN Ratings
1112  
1113 L<http://cpanratings.perl.org/d/NIST-NVD-Store-SQLite3>
1114  
1115 =item * Search CPAN
1116  
1117 L<http://search.cpan.org/dist/NIST-NVD-Store-SQLite3/>
1118  
1119 =back
1120  
1121  
1122 =head1 ACKNOWLEDGEMENTS
1123  
1124  
1125 =head1 LICENSE AND COPYRIGHT
1126  
1127 Copyright (C) 2012 C.J. Adams-Collier
1128 Copyright (C) 2012 F5 Networks, Inc
1129 Copyright (C) 2013 Washington State Guard Association
1130 Copyright (C) 2022 Google, LLC
1131  
1132 CVE(r) and CWE(tm) are marks of The MITRE Corporation and used here with
1133 permission. The information in CVE and CWE are copyright of The MITRE
1134 Corporation and also used here with permission.
1135  
1136 Please include links for CVE(r) <http://cve.mitre.org/> and CWE(tm)
1137 <http://cwe.mitre.org/> in all reproductions of these materials.
1138  
1139 This program is free software; you can redistribute it and/or modify it
1140 under the terms of either: the GNU General Public License as published
1141 by the Free Software Foundation; or the Artistic License.
1142  
1143 See http://dev.perl.org/licenses/ for more information.
1144  
1145  
1146 =cut
1147  
1148 7 1; # End of NIST::NVD::Store::SQLite3
↑ Summary