Net-Nessus-XMLRPC
view release on metacpan or search on metacpan
lib/Net/Nessus/XMLRPC.pm view on Meta::CPAN
save_knowledge_base => no,
port_range => 1-65535
=cut
sub policy_edit {
my ( $self, $policy_id, $params ) = @_;
my $post={
"token" => $self->token,
"policy_id" => $policy_id
};
while (my ($key, $value) = each(%{$params}))
{
$post->{$key} = $value;
}
my $xmls = $self->nessus_request("policy/add",$post);
return $xmls;
}
=head2 policy_new ( $params )
create new policy with $params,
%params must be present:
policy_name
policy_shared
the others parameters are same as policy_edit
=cut
sub policy_new {
my ( $self, $params ) = @_;
my $xmls = $self->policy_edit(0, %{$params});
return $xmls;
}
=head2 policy_get_opts ( $policy_id )
returns hashref with different options for policy identified by $policy_id
=cut
sub policy_get_opts {
my ( $self, $policy_id ) = @_;
my $post=[
"token" => $self->token,
];
my $xmls = $self->nessus_request("policy/list",$post);
if ($xmls->{'contents'}->[0]->{'policies'}->[0]->{'policy'}) {
my %opts;
foreach my $report (@{$xmls->{'contents'}->[0]->{'policies'}->[0]->{'policy'}}) {
if ($report->{'policyID'}->[0] eq $policy_id) {
$opts{'policy_name'}=$report->{'policyName'}->[0];
if ($report->{'visibility'}->[0] eq "shared") {
$opts{'policy_shared'}=1;
} else {
$opts{'policy_shared'}=0;
}
if ($report->{'policyContents'}->[0]->{'policyComments'}->[0]) {
$opts{'policy_comments'}=$report->{'policyContents'}->[0]->{'policyComments'}->[0];
}
foreach my $prefs (@{$report->{'policyContents'}->[0]->{'Preferences'}->[0]->{'ServerPreferences'}->[0]->{'preference'}}) {
$opts{$prefs->{'name'}->[0]} = $prefs->{'value'}->[0] if ($prefs->{'name'}->[0]);
}
foreach my $prefp (@{$report->{'policyContents'}->[0]->{'Preferences'}->[0]->{'PluginsPreferences'}->[0]->{'item'}}) {
$opts{$prefp->{'fullName'}->[0]} = $prefp->{'selectedValue'}->[0] if ($prefp->{'fullName'}->[0]);
}
foreach my $plugf (@{$report->{'policyContents'}->[0]->{'FamilySelection'}->[0]->{'FamilyItem'}}) {
$opts{"plugin_selection.family.".$plugf->{'FamilyName'}->[0]} = $plugf->{'Status'}->[0] if ($plugf->{'FamilyName'}->[0]);
}
foreach my $plugi (@{$report->{'policyContents'}->[0]->{'IndividualPluginSelection'}->[0]->{'PluginItem'}}) {
$opts{"plugin_selection.individual_plugin.".$plugi->{'PluginId'}->[0]} = $plugi->{'Status'}->[0] if ($plugi->{'PluginId'}->[0]);
}
return \%opts;
}
} # foreach
} # if
return '';
}
=head2 policy_set_opts ( $policy_id , $params )
sets policy options via hashref $params identified by $policy_id
=cut
sub policy_set_opts {
my ( $self, $policy_id, $params ) = @_;
my $post = $self->policy_get_opts ($policy_id);
while (my ($key, $value) = each(%{$params}))
{
$post->{$key} = $value;
}
$post->{"token"} = $self->token;
$post->{"policy_id"} = $policy_id;
my $xmls = $self->nessus_request("policy/edit",$post);
return $xmls;
}
=head2 report_list_uids
returns ref to array of IDs of reports available
=cut
sub report_list_uids {
my ( $self ) = @_;
my $post=[
"token" => $self->token
];
my $xmls = $self->nessus_request("report/list",$post);
my @list;
if ($xmls->{'contents'}->[0]->{'reports'}->[0]->{'report'}) {
foreach my $report (@{$xmls->{'contents'}->[0]->{'reports'}->[0]->{'report'}}) {
push @list, $report->{'name'}->[0];
}
}
return \@list;
}
=head2 report_list_hash
( run in 3.122 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )