-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathcve-oldest.pl
More file actions
57 lines (47 loc) · 1.23 KB
/
cve-oldest.pl
File metadata and controls
57 lines (47 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
# NOTE:
#
# This accesses the web site git repo to find the 'vuln.pm' file with the
# proper meta-data!
#
# Shows the number of days each CVE was present in a curl release before
# fixed.
#
my $webroot = $ARGV[0] || "../curl-www";
require "$webroot/docs/vuln.pm";
$csv = "$webroot/docs/releases.csv";
sub relinfo {
open(C, "<$csv");
while(<C>) {
chomp;
my ($index, $version, $vulns, $date, $since, $ddays, $adays, $dbugs, $abugs,
$dchanges, $achanges) = split(';', $_);
$release{$version}=$date;
push @inorder, $version;
}
close(C);
}
relinfo();
sub deltadays {
my ($prev, $date) = @_;
my $psecs = `date +%s -d "$prev"`;
my $secs = `date +%s -d "$date"`;
return int(($secs-$psecs)/86400);
}
sub conv {
my ($days) = @_;
return $days / 365.25;
}
for(@vuln) {
my ($id, $start, $stop, $desc, $cve, $date, $rdate, $cwe, $award,
$area, $cissue, $where, $severity, $issue)=split('\|');
my $delta = deltadays($release{$start}, $date);
$age{$cve} = $delta;
}
my $index = 1;
for my $cve (sort {$age{$b} <=> $age{$a}} keys %age) {
printf "%u;%s;%.2f\n", $index++, $cve, conv($age{$cve});
if($index == 21) {
last;
}
}