| Parse-Nessus-XML documentation | Contained in the Parse-Nessus-XML distribution. |
Parse::Nessus::XML - Interface to Nessus XML result files
use Parse::Nessus::XML my $scan = Parse::Nessus::XML->new( $filename ); my @results = $scan->results; my $plugin = $scan->plugin(10964); # Parse::Nessus::XML::Plugin object my $name = $plugin->name;
Provides an interface to the Nessus XML report file. This is primarily for my own use, so if it's missing stuff that you think should be in here, send me a patch.
Please note that this API is just a suggestion, and is subject to change in the first few releases. Because of how deeply nested the data structure is, there's no particularly nice API to the whole thing - at least that I can think of. See the example script in the example/ subdirectory to see how I use this in real life.
my $scan = Parse::Nessus::XML->new( $filename );
Given the path to a file, returns a Parse::Nessus::XML object.
my $results = $scan->results; # listref
my @results = $scan->results; # list
Returns a plugin object, given the ID. Then you can call for attributes off of that object.
my $plugin = $scan->plugin(10964); $name = $plugin->name; $risk = $plugin->risk;
Supplementary package which facilitates figuring out what's in a particular plugin. Also allows location of a plugin by ID number, which speeds things up.
my $plugin = Parse::Nessus::XML::Plugin->new( $scan, ID => 10964 ); my $risk = $plugin->risk;
Available attributes are: id, name, version, family, cve_id, bugtraq_id, category, risk, summary, copyright
Rich Bowen
CPAN ID: RBOW
rbowen@rcbowen.com
http://rich.rcbowen.com/
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
Parse::Nessus::NBE
| Parse-Nessus-XML documentation | Contained in the Parse-Nessus-XML distribution. |
package Parse::Nessus::XML; use strict; use XML::Simple qw(); use vars qw($VERSION); $VERSION = (qw($Revision: 1.14 $))[1]; # Documentation {{{
# }}} # sub new {{{
sub new { my ( $class, $file ) = @_; @XML::Simple::DefKeyAttr = qw(id); my $scan = XML::Simple::XMLin( $file, KeyAttr => { plugin => 'id', ports => 'portid' }, ); my $self = bless( $scan, ref($class) || $class ); return ($self); } # }}} # sub results {{{
sub results { my $self = shift; return wantarray ? @{ $self->{results}->{result} } : $self->{results}->{result}; } # }}} # sub plugin {{{
sub plugin { my $scan = shift; my $ID = shift; return unless $ID; return Parse::Nessus::XML::Plugin->new( $scan, ID => $ID ); } # }}} 1; # Parse::Nessus::XML::Plugin {{{
package Parse::Nessus::XML::Plugin; use vars qw($AUTOLOAD);
sub new { my $class = shift; my $self = {}; my $scan = shift; my %attribs = @_; if ($attribs{ID}) { $self = $scan->{plugins}{plugin}{$attribs{ID}}; $self->{id} = $attribs{ID}; } else { warn "No ID given, so I don't know what plugin you wanted."; } bless $self, $class; return $self; } sub AUTOLOAD { my $self = shift; my $attrib = $AUTOLOAD; $attrib =~ s/.*:://; return $self->{$attrib} || undef; } 1; # End package }}}