Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
calculate number of days from a curl security report until release
#!/usr/bin/perl
# un-preprocessed _changes-file as input
require "./vuln.pm";
sub vernum {
my ($ver)=@_;
my @v = split('\.', $ver);
return ($v[0] << 16) | ($v[1] << 8) | $v[2];
}
sub days {
my ($d)=@_;
my $datesecs=`date -d "$d" +%s`;
return int($datesecs/(3600*24));
}
my $f = $ARGV[0];
if(!$f) {
print "report2release.pl <_changes.html>\n";
exit;
}
open(F, "<$f") || die;
while(<F>) {
# each release starts with this
if($_ =~ /^SUBTITLE\(Fixed in ([0-9.]*) - (.*)\)/) {
$str=$1;
my $date=$2;
push @releases, $1;
$reldate{$1}=$2;
$bugfixes{$str}=0;
$changes{$str}=0;
}
}
close(F);
print "page;report;date;report2release;release2report\n";
for(@vuln) {
my ($page, $start, $stop, $name, $cve, $date, $report)=split('\|');
if($report eq "-") {
next;
}
my $days = days($date) - days($report);
my $rel2rep = days($report) - days($reldate{$start});
my $projage = int($rel2rep * 100 / (days($report) - days("19980320")));
print "$cve;$report;$date;$days;$start;$reldate{$start};$rel2rep;$projage\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment