diff options
author | eik <eik@FreeBSD.org> | 2004-06-26 08:40:17 +0800 |
---|---|---|
committer | eik <eik@FreeBSD.org> | 2004-06-26 08:40:17 +0800 |
commit | b5633c6082fcce3328c7c42edf42205df493b964 (patch) | |
tree | 6a4c3a9d06765755780144c229783406bad83da8 | |
parent | a0d280780a413f0e7e62a673f34e57ac324e5c6b (diff) | |
download | freebsd-ports-gnome-b5633c6082fcce3328c7c42edf42205df493b964.tar.gz freebsd-ports-gnome-b5633c6082fcce3328c7c42edf42205df493b964.tar.zst freebsd-ports-gnome-b5633c6082fcce3328c7c42edf42205df493b964.zip |
add portaudit2vuxml.pl to easy the migration of entries to VuXML
-rw-r--r-- | ports-mgmt/portaudit-db/database/portaudit2vuxml.pl | 129 | ||||
-rw-r--r-- | security/portaudit-db/database/portaudit2vuxml.pl | 129 |
2 files changed, 258 insertions, 0 deletions
diff --git a/ports-mgmt/portaudit-db/database/portaudit2vuxml.pl b/ports-mgmt/portaudit-db/database/portaudit2vuxml.pl new file mode 100644 index 000000000000..11a04f5e22da --- /dev/null +++ b/ports-mgmt/portaudit-db/database/portaudit2vuxml.pl @@ -0,0 +1,129 @@ +#!/usr/bin/perl -w +# +# Copyright (c) 2004 Oliver Eikemeier. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright notice +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the author nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# $FreeBSD$ +# +# portaudit to VuXML converter, use with +# portaudit2vuxml.pl <uuid> +# and edit the entry to suit your needs. +# + +require 5.005; +use strict; +use Cwd 'abs_path'; + +my $portsdir = $ENV{PORTSDIR} ? $ENV{PORTSDIR} : '/usr/ports'; + +my $portauditdb = "$portsdir/security/portaudit-db/database/portaudit.txt"; + +my $uuid = $ARGV[0]; + +$#ARGV == 0 && $uuid =~ /^[0-9a-f]{8}(?:-[0-9a-f]{4}){4}[0-9a-f]{8}$/ + or die "usage: $0 $uuid <uuid>\n"; + +my $today=`date -u +%Y-%m-%d`; +chomp $today; + +my @pkg; +my $url; +my $topic; + +open PORTAUDITDB, "<$portauditdb" + or die "Can't open $portauditdb: $!\n"; + +while (<PORTAUDITDB>) { + chomp; + next if /^(?:#|$)/; + my @line = split /\|/; + next if $#line < 3 || $line[3] ne $uuid; + push @pkg, $line[0]; + $url = $line[1]; + $topic = $line[2]; +} + +close PORTAUDITDB; + +$url =~ s/</</g; +$url =~ s/>/>/g; +$url =~ s/&/&/g; + +$topic =~ s/</</g; +$topic =~ s/>/>/g; +$topic =~ s/&/&/g; + +my %oper = ( + '<' => 'lt', + '<=' => 'le', + '=' => 'eq', + '>=' => 'ge', + '>' => 'gt' +); + +if (@pkg) { + print " <vuln vid=\"$uuid\">\n"; + print " <topic>$topic</topic>\n"; + print " <affects>\n"; + foreach (@pkg) { + my @vers = split /((?:<|>)=?|=)/; + my $pkgname = shift @vers; + print " <package>\n"; + print " <name>$pkgname</name>\n"; + if (@vers) { + print " <range>"; + while (@vers) { + my $op = $oper{shift @vers}; + my $v = shift @vers; + print "<$op>$v</$op>"; + } + print "</range>\n"; + } + print " </package>\n"; + } + print " </affects>\n"; + + print " <description>\n"; + print " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n"; + print " <p>Please <a href=\"mailto:security\@FreeBSD.org?subject=vid%20$uuid\">contact\n"; + print " the FreeBSD Security Team</a> for more information.</p>\n"; + print " </body>\n"; + print " </description>\n"; + print " <references>\n"; + + foreach (split ' ', $url) { + print " <url>$_</url>\n"; + } + + print " </references>\n"; + print " <dates>\n"; + print " <discovery>2000-00-00</discovery>\n"; + print " <entry>$today</entry>\n"; + print " </dates>\n"; + print " </vuln>\n"; +} diff --git a/security/portaudit-db/database/portaudit2vuxml.pl b/security/portaudit-db/database/portaudit2vuxml.pl new file mode 100644 index 000000000000..11a04f5e22da --- /dev/null +++ b/security/portaudit-db/database/portaudit2vuxml.pl @@ -0,0 +1,129 @@ +#!/usr/bin/perl -w +# +# Copyright (c) 2004 Oliver Eikemeier. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright notice +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the author nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# $FreeBSD$ +# +# portaudit to VuXML converter, use with +# portaudit2vuxml.pl <uuid> +# and edit the entry to suit your needs. +# + +require 5.005; +use strict; +use Cwd 'abs_path'; + +my $portsdir = $ENV{PORTSDIR} ? $ENV{PORTSDIR} : '/usr/ports'; + +my $portauditdb = "$portsdir/security/portaudit-db/database/portaudit.txt"; + +my $uuid = $ARGV[0]; + +$#ARGV == 0 && $uuid =~ /^[0-9a-f]{8}(?:-[0-9a-f]{4}){4}[0-9a-f]{8}$/ + or die "usage: $0 $uuid <uuid>\n"; + +my $today=`date -u +%Y-%m-%d`; +chomp $today; + +my @pkg; +my $url; +my $topic; + +open PORTAUDITDB, "<$portauditdb" + or die "Can't open $portauditdb: $!\n"; + +while (<PORTAUDITDB>) { + chomp; + next if /^(?:#|$)/; + my @line = split /\|/; + next if $#line < 3 || $line[3] ne $uuid; + push @pkg, $line[0]; + $url = $line[1]; + $topic = $line[2]; +} + +close PORTAUDITDB; + +$url =~ s/</</g; +$url =~ s/>/>/g; +$url =~ s/&/&/g; + +$topic =~ s/</</g; +$topic =~ s/>/>/g; +$topic =~ s/&/&/g; + +my %oper = ( + '<' => 'lt', + '<=' => 'le', + '=' => 'eq', + '>=' => 'ge', + '>' => 'gt' +); + +if (@pkg) { + print " <vuln vid=\"$uuid\">\n"; + print " <topic>$topic</topic>\n"; + print " <affects>\n"; + foreach (@pkg) { + my @vers = split /((?:<|>)=?|=)/; + my $pkgname = shift @vers; + print " <package>\n"; + print " <name>$pkgname</name>\n"; + if (@vers) { + print " <range>"; + while (@vers) { + my $op = $oper{shift @vers}; + my $v = shift @vers; + print "<$op>$v</$op>"; + } + print "</range>\n"; + } + print " </package>\n"; + } + print " </affects>\n"; + + print " <description>\n"; + print " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n"; + print " <p>Please <a href=\"mailto:security\@FreeBSD.org?subject=vid%20$uuid\">contact\n"; + print " the FreeBSD Security Team</a> for more information.</p>\n"; + print " </body>\n"; + print " </description>\n"; + print " <references>\n"; + + foreach (split ' ', $url) { + print " <url>$_</url>\n"; + } + + print " </references>\n"; + print " <dates>\n"; + print " <discovery>2000-00-00</discovery>\n"; + print " <entry>$today</entry>\n"; + print " </dates>\n"; + print " </vuln>\n"; +} |