Merging multiple Nessus reports

I have recently had the need to merge multiple Nessus reports into single reports and here is the code I used to do it. Take care and if it breaks for you you get to keep both pieces Winking smile. Please note that you need to change the report name to the same value, like this:

sed -i -e s/\<Report\ name=\".*\"\>/\<Report\ name=\"Combined\ report\ name\"\>/g reports/*.xml

mergeReports.pl

#!/usr/bin/env perl

use strict;
use warnings;

use XML::Merge;

if ( $#ARGV < 0 ) {
    print "Merging into " . $ARGV[0] . "\n";
    my $merge_obj = XML::Merge->new( 'filename' => $ARGV[0] );
    foreach my $filename (@ARGV) {
        if ( $filename ne $ARGV[0] ) {
            print "Merging " . $filename . "...";
            $merge_obj->merge( 'filename' => $filename );
            print " Done!\n";
        }
    }

    print "Tiding up.... " . $ARGV[0];
    $merge_obj->tidy();
    print "Done!\n";
} else {
    print "Usage: mergeReports.pl Output.xml inputfiles.xml\n";
}

4 comments:

Anonymous said...

Very helpful, thanks!

Chris Clements said...

Actually, I can't get this script to run. I get the following error after creating the script and making it executable:

Global symbol "$merge" requires explicit package name at ./mergeReports.pl line 20.
Execution of ./mergeReports.pl aborted due to compilation errors.

Michael Boman said...

@Chris Clements: change $merge to $merge_obj on line 20.

Michael Boman said...

I have updated the blog post with the changes to the source code.

Post a Comment