From bc9e419ee3c2f999e57ef86451efdfd2e81176e1 Mon Sep 17 00:00:00 2001 From: Todd Bruner Date: Fri, 24 Apr 2015 15:02:32 -0600 Subject: [PATCH 1/3] handle the different return type from nessus --- lib/Net/Nessus/REST.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Net/Nessus/REST.pm b/lib/Net/Nessus/REST.pm index 5648d6e..0b60645 100644 --- a/lib/Net/Nessus/REST.pm +++ b/lib/Net/Nessus/REST.pm @@ -296,7 +296,13 @@ sub list_scanners { my ($self) = @_; my $result = $self->_get("/scanners"); - return $result->{scanner} ? @{$result->{scanner}} : (); + # I think that this may have changed in the Nessus API + # now you get an array ref back with a list of hashes + # return $result->{scanner} ? @{$result->{scanner}} : (); + unless ( $result ) { + $result = []; + } + return wantarray ? @{$result} : $result; } sub list_folders { From 52b674894b0e649fc92198be6e658322d9bfb2a9 Mon Sep 17 00:00:00 2001 From: Todd Bruner Date: Fri, 24 Apr 2015 15:11:28 -0600 Subject: [PATCH 2/3] /scanners returns an arrayref not a hashref The Nessus API returns an array of scanner resources, e.g. [ { ... }, {.... } ] --- lib/Net/Nessus/REST.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Net/Nessus/REST.pm b/lib/Net/Nessus/REST.pm index 5648d6e..a61868e 100644 --- a/lib/Net/Nessus/REST.pm +++ b/lib/Net/Nessus/REST.pm @@ -296,7 +296,11 @@ sub list_scanners { my ($self) = @_; my $result = $self->_get("/scanners"); - return $result->{scanner} ? @{$result->{scanner}} : (); + # I think that this may have changed in the Nessus API, because an array ref is returned + # the elements of that array being hash refs + # return $result->{scanner} ? @{$result->{scanner}} : (); + $result = [] unless ($result); + return wantarray ? @{$result} : $result; } sub list_folders { From 82d2220a36aef5dd498cbdd6b8854c975f10c8a9 Mon Sep 17 00:00:00 2001 From: Todd Bruner Date: Mon, 27 Apr 2015 11:53:37 -0600 Subject: [PATCH 3/3] added the stop scan --- lib/Net/Nessus/REST.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/Net/Nessus/REST.pm b/lib/Net/Nessus/REST.pm index 0b60645..439a4ce 100644 --- a/lib/Net/Nessus/REST.pm +++ b/lib/Net/Nessus/REST.pm @@ -136,6 +136,16 @@ sub get_scan_details { return $result; } +sub stop_scan { + my ($self, %params) = @_; + + croak "missing scan_id parameter" unless $params{scan_id}; + + my $scan_id = delete $params{scan_id}; + my $result = $self->_get("/scans/$scan_id/stop", %params); + return $result; +} + sub set_scan_read_status { my ($self, %params) = @_; @@ -660,6 +670,12 @@ returns the details about a plugin family See L for details. +=head2 $nessus->stop_scan(scan_id => $scan_id ) + +Returns details for the given scan. + +See L for details. + =head1 LICENSE This program is free software: you can redistribute it and/or modify