Update
This commit is contained in:
parent
a7c783242d
commit
86dfcd162b
|
@ -916,23 +916,21 @@ sub PandoraFMS::Recon::Base::get_credentials {
|
||||||
################################################################################
|
################################################################################
|
||||||
# Create agents and modules reported by Recon::Base.
|
# Create agents and modules reported by Recon::Base.
|
||||||
################################################################################
|
################################################################################
|
||||||
sub PandoraFMS::Recon::Base::report_scanned_agents($) {
|
sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
|
||||||
my ($self) = @_;
|
my ($self,$force) = @_;
|
||||||
|
|
||||||
my $force_creation = 0;
|
my $force_creation = $force;
|
||||||
|
$force_creation = 0 unless (is_enabled($force));
|
||||||
if (defined($self->{'task_data'}{'review_mode'})
|
|
||||||
&& $self->{'task_data'}{'review_mode'} == DISCOVERY_STANDARD
|
|
||||||
) {
|
|
||||||
$force_creation = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Creation
|
# Creation
|
||||||
#
|
#
|
||||||
if(defined($self->{'task_data'}{'review_mode'})
|
|
||||||
&& $self->{'task_data'}{'review_mode'} == DISCOVERY_RESULTS
|
if($force_creation == 1
|
||||||
|
|| (defined($self->{'task_data'}{'review_mode'})
|
||||||
|
&& $self->{'task_data'}{'review_mode'} == DISCOVERY_RESULTS)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
# Load cache.
|
# Load cache.
|
||||||
my @rows = get_db_rows(
|
my @rows = get_db_rows(
|
||||||
$self->{'dbh'},
|
$self->{'dbh'},
|
||||||
|
@ -1008,7 +1006,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
|
||||||
$agent_id = get_db_value(
|
$agent_id = get_db_value(
|
||||||
$self->{'dbh'},
|
$self->{'dbh'},
|
||||||
'SELECT id_agente FROM tagente WHERE nombre = ?',
|
'SELECT id_agente FROM tagente WHERE nombre = ?',
|
||||||
safe_input($data->{'agent'}->{'name'})
|
safe_input($data->{'agent'}{'nombre'})
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!defined($agent_id) || $agent_id <= 0) {
|
if (!defined($agent_id) || $agent_id <= 0) {
|
||||||
|
@ -1046,13 +1044,14 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
|
||||||
if (defined($self->{'main_event_id'})) {
|
if (defined($self->{'main_event_id'})) {
|
||||||
my $addresses_str = join(
|
my $addresses_str = join(
|
||||||
',',
|
',',
|
||||||
safe_output($self->get_addresses($data->{'agent'}{'nombre'}))
|
$self->get_addresses(safe_output($data->{'agent'}{'nombre'}))
|
||||||
);
|
);
|
||||||
|
|
||||||
pandora_extended_event(
|
pandora_extended_event(
|
||||||
$self->{'pa_config'}, $self->{'dbh'},
|
$self->{'pa_config'}, $self->{'dbh'},
|
||||||
$self->{'main_event_id'},"[Discovery] New "
|
$self->{'main_event_id'},"[Discovery] New "
|
||||||
. safe_output($self->get_device_type($data->{'agent'}{'nombre'}))
|
. $self->get_device_type(safe_output($data->{'agent'}{'nombre'}))
|
||||||
. " found " . $$data->{'agent'}{'nombre'} . " (" . $addresses_str
|
. " found " . $data->{'agent'}{'nombre'} . " (" . $addresses_str
|
||||||
. ") Agent $agent_id."
|
. ") Agent $agent_id."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1090,17 +1089,13 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
|
||||||
|
|
||||||
$self->call('message', "[$agent_id] Module: ".$module->{'name'}, 5);
|
$self->call('message', "[$agent_id] Module: ".$module->{'name'}, 5);
|
||||||
|
|
||||||
my $agentmodule_id = $module->{'agentmodule_id'};
|
my $agentmodule_id = get_db_value(
|
||||||
|
|
||||||
if (defined($agentmodule_id) && $agentmodule_id > 0) {
|
|
||||||
$agentmodule_id = get_db_value(
|
|
||||||
$self->{'dbh'},
|
$self->{'dbh'},
|
||||||
'SELECT id_agente_modulo FROM tagente_modulo
|
'SELECT id_agente_modulo FROM tagente_modulo
|
||||||
WHERE id_agente_modulo = ? AND nombre = ?',
|
WHERE id_agente = ? AND nombre = ?',
|
||||||
$agentmodule_id,
|
$agent_id,
|
||||||
safe_input($module->{'name'})
|
safe_input($module->{'name'})
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_enabled($agentmodule_id)) {
|
if (!is_enabled($agentmodule_id)) {
|
||||||
# Create.
|
# Create.
|
||||||
|
@ -1307,6 +1302,10 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(defined($self->{'task_data'}{'review_mode'})
|
||||||
|
&& $self->{'task_data'}{'review_mode'} == DISCOVERY_REVIEW
|
||||||
|
) {
|
||||||
# Notify.
|
# Notify.
|
||||||
my $notification = {};
|
my $notification = {};
|
||||||
$notification->{'subject'} = safe_input('Review pending');
|
$notification->{'subject'} = safe_input('Review pending');
|
||||||
|
@ -1337,6 +1336,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
|
||||||
$notification_id, \@users, \@groups
|
$notification_id, \@users, \@groups
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$self->call('message', "Completed", 5);
|
$self->call('message', "Completed", 5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -683,7 +683,11 @@ sub get_device_type($$) {
|
||||||
my ($self, $device) = @_;
|
my ($self, $device) = @_;
|
||||||
|
|
||||||
if (defined($self->{'visited_devices'}->{$device})) {
|
if (defined($self->{'visited_devices'}->{$device})) {
|
||||||
|
if (defined($self->{'visited_devices'}->{$device}->{'type'})) {
|
||||||
return $self->{'visited_devices'}->{$device}->{'type'};
|
return $self->{'visited_devices'}->{$device}->{'type'};
|
||||||
|
} else {
|
||||||
|
$self->{'visited_devices'}->{$device}->{'type'} = 'host';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Assume 'host' by default.
|
# Assume 'host' by default.
|
||||||
|
@ -1931,7 +1935,14 @@ sub scan($) {
|
||||||
$self->call('message', "[6/6] Processing results.", 3);
|
$self->call('message', "[6/6] Processing results.", 3);
|
||||||
$self->{'step'} = STEP_PROCESSING;
|
$self->{'step'} = STEP_PROCESSING;
|
||||||
# Send agent information to Database (Discovery) or XML (satellite.).
|
# Send agent information to Database (Discovery) or XML (satellite.).
|
||||||
$self->call('report_scanned_agents', $self->{'agents_found'});
|
$self->call('report_scanned_agents');
|
||||||
|
|
||||||
|
if(defined($self->{'task_data'}{'review_mode'})
|
||||||
|
&& $self->{'task_data'}{'review_mode'} == DISCOVERY_STANDARD
|
||||||
|
) {
|
||||||
|
# Send agent information to Database (Discovery) or XML (satellite.).
|
||||||
|
$self->call('report_scanned_agents', 1);
|
||||||
|
}
|
||||||
|
|
||||||
# Done!
|
# Done!
|
||||||
$self->{'step'} = '';
|
$self->{'step'} = '';
|
||||||
|
|
Loading…
Reference in New Issue