#!/usr/bin/perl # Copyright Andrew Gavin 2009, 2010 # # This file is part of OpenDLP. # # OpenDLP is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # OpenDLP is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with OpenDLP. If not, see . use CGI qw/:standard/; use DBI; my $user = remote_user(); my $is_valid = 1; my $MAX_LENGTH_SCAN = 64; my $db_admin_file = "../etc/db_admin"; my( $scanname, $tracker ) = ""; my( $db_username, $db_password ) = ""; my @FPs = (); open( DB, $db_admin_file ); my $db_line = ; close( DB ); chomp $db_line; ($db_username, $db_password) = split( ":", $db_line ); header(); if( request_method() ne "POST" ) { $is_valid = 0; print "Only POST requests are allowed.
\n"; } foreach $p (param()) { $form{$p} = param($p); if( $p eq "scanname" ) { $scanname = $form{$p}; if( length( $scanname ) > $MAX_LENGTH_SCAN ) { $is_valid = 0; print "Scan name is too long. Limit it to $MAX_LENGTH_SCAN characters.

\n"; } if( $scanname !~ /^[a-z0-9\ \,\.\-\_]+$/i ) { $is_valid = 0; print "Scan name can only contain the following characters, including whitespace: A-Z0-9,.-_

\n"; } } if( $p eq "tracker" ) { $tracker = $form{$p}; if( $tracker !~ /^[A-F0-9]{32}$/i ) { $is_valid = 0; print "Tracker can only be a hexadecimal number with a length of 32.

\n"; } } if( $p =~ /^f[0-9]+$/ && $p ne $scanname && $p ne $tracker ) { push @FPs, $p; } } if( @FPs == 0 ) { $is_valid = 0; print "No false positives were selected. No action is being taken.

\n"; } if( $is_valid ) { print "Clearing False Positives

\n"; my $dbh = DBI->connect("DBI:mysql:database=OpenDLP;host=localhost",$db_username,$db_password); my $sth = ""; foreach( @FPs ) { my $number = $_; $number =~ s/^f//g; my $string = "UPDATE results SET is_false=\"0\" WHERE number=? AND scan=? AND tracker=?"; $sth = $dbh->prepare( $string ); $sth->execute( $number, $scanname, $tracker ); } print "Done clearing false positives. Go back and refresh to see the changes.
\n"; $sth->finish(); $dbh->disconnect(); } #footer(); sub header { print "Content-type: text/html\n\n"; print "\n\n"; print "OpenDLP 0.1\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print '
' . "\n"; } sub footer { print "
\n"; }