line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# database::vfeed Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Database::Vfeed; |
7
|
1
|
|
|
1
|
|
623
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
26
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
508
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable cve) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes => { |
19
|
|
|
|
|
|
|
datadir => [ qw(datadir) ], |
20
|
|
|
|
|
|
|
db => [ qw(vfeed.db) ], |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
attributes_default => { |
23
|
|
|
|
|
|
|
db => 'vfeed.db', |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
commands => { |
26
|
|
|
|
|
|
|
db_version => [ ], |
27
|
|
|
|
|
|
|
update => [ ], |
28
|
|
|
|
|
|
|
cve => [ qw(cve_id) ], |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
require_modules => { |
31
|
|
|
|
|
|
|
'Data::Dumper' => [ ], |
32
|
|
|
|
|
|
|
'vFeed::DB' => [ ], |
33
|
|
|
|
|
|
|
'vFeed::Log' => [ ], |
34
|
|
|
|
|
|
|
'Metabrik::Client::Www' => [ ], |
35
|
|
|
|
|
|
|
'Metabrik::File::Compress' => [ ], |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub db_version { |
41
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $db = $self->db; |
44
|
0
|
|
|
|
|
|
my $datadir = $self->datadir; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $log = vFeed::Log->new; |
47
|
0
|
|
|
|
|
|
my $vfeed = vFeed::DB->new( |
48
|
|
|
|
|
|
|
log => $log, |
49
|
|
|
|
|
|
|
file => $datadir.'/'.$db, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$vfeed->init; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return $vfeed->db_version; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub cve { |
58
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
my ($id) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('cve', $id) or return; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $db = $self->db; |
64
|
0
|
|
|
|
|
|
my $datadir = $self->datadir; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $log = vFeed::Log->new; |
67
|
0
|
|
|
|
|
|
my $vfeed = vFeed::DB->new( |
68
|
|
|
|
|
|
|
log => $log, |
69
|
|
|
|
|
|
|
file => $datadir.'/'.$db, |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$vfeed->init; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $cve = $vfeed->get_cve($id); |
75
|
0
|
|
|
|
|
|
my $cpe = $vfeed->get_cpe($id); |
76
|
0
|
|
|
|
|
|
my $cwe = $vfeed->get_cwe($id); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return { |
79
|
0
|
|
|
|
|
|
cve => $cve, |
80
|
|
|
|
|
|
|
cpe => $cpe, |
81
|
|
|
|
|
|
|
cwe => $cwe, |
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub update { |
86
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my $db = $self->db; |
89
|
0
|
|
|
|
|
|
my $datadir = $self->datadir; |
90
|
0
|
|
|
|
|
|
my $url = 'http://www.toolswatch.org/vfeed/vfeed.db.tgz'; |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
my $cw = Metabrik::Client::Www->new_from_brik_init($self) or return; |
93
|
0
|
|
|
|
|
|
my $files = $cw->mirror($url, 'vfeed.db.tgz', $datadir); |
94
|
0
|
0
|
|
|
|
|
if (@$files) { # An update was found |
95
|
0
|
|
|
|
|
|
$self->log->info("update: a new version was found"); |
96
|
0
|
0
|
|
|
|
|
my $fc = Metabrik::File::Compress->new_from_brik_init($self) or return; |
97
|
0
|
0
|
|
|
|
|
$fc->uncompress($files->[0], $db, $datadir) or return; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return $self->db_version; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |