Merge branch 'ent-8470-POST-ocultar-comando-en-respuestas-de-eventos-2' into 'develop'

added token to display or hide command in event response execution

See merge request artica/pandorafms!4671
This commit is contained in:
Daniel Rodriguez 2022-02-01 13:42:14 +00:00
commit 91797c7112
7 changed files with 23 additions and 3 deletions

View File

@ -1,5 +1,6 @@
START TRANSACTION;
ALTER TABLE `tpolicy_queue` MODIFY COLUMN `progress` int(10) NOT NULL default '0';
CREATE INDEX `IDX_tservice_element` ON `tservice_element`(`id_service`,`id_agente_modulo`);
ALTER TABLE tevent_response ADD COLUMN display_command tinyint(1) default 0;
COMMIT;

View File

@ -2002,6 +2002,7 @@ ALTER TABLE `tserver` ADD COLUMN `port` int(5) unsigned NOT NULL default 0;
-- ---------------------------------------------------------------------
ALTER TABLE tevent_response ADD COLUMN server_to_exec int(10) unsigned NOT NULL DEFAULT 0;
ALTER TABLE tevent_response ADD COLUMN command_timeout int(5) unsigned NOT NULL DEFAULT 90;
ALTER TABLE tevent_response ADD COLUMN display_command tinyint(1) DEFAULT 0;
-- ---------------------------------------------------------------------
-- Table `tmodule`

View File

@ -197,6 +197,18 @@ $data[0] = '<div id="command_timeout_label" class="labels invisible">'.__('Comma
$data[1] = '<div id="command_timeout_value" class="invisible">'.html_print_input_text('command_timeout', $event_response['command_timeout'], '', 4, 5, true);
$table->data[5] = $data;
$data = [];
$data[0] = __('Display command').ui_print_help_tip(__('If enabled the command will be displayed to any user that can execute this event response'), true);
$data[1] = html_print_checkbox_switch(
'display_command',
1,
$event_response['display_command'],
true
);
$table->data[6] = $data;
if ($event_response_id == 0) {
echo '<form method="post" action="index.php?sec=geventos&sec2=godmode/events/events&section=responses&mode=list&action=create_response&amp;pure='.$config['pure'].'">';
html_print_table($table);

View File

@ -41,6 +41,7 @@ switch ($action) {
$values['modal_height'] = get_parameter('modal_height');
$values['new_window'] = get_parameter('new_window');
$values['params'] = get_parameter('params');
$values['display_command'] = get_parameter('display_command');
$values['server_to_exec'] = get_parameter('server_to_exec');
$values['command_timeout'] = get_parameter('command_timeout', 90);
@ -64,6 +65,7 @@ switch ($action) {
$values['modal_height'] = get_parameter('modal_height');
$values['new_window'] = get_parameter('new_window');
$values['params'] = get_parameter('params');
$values['display_command'] = get_parameter('display_command');
$values['server_to_exec'] = get_parameter('server_to_exec');
$response_id = get_parameter('id_response', 0);
$values['command_timeout'] = get_parameter('command_timeout', '90');

View File

@ -1176,12 +1176,15 @@ if ($dialogue_event_response) {
$prompt = '<br>> ';
switch ($event_response['type']) {
case 'command':
$display_command = (bool) $event_response['display_command'];
$command_str = ($display_command === true) ? $command : '';
if ($massive) {
echo "<div class='left'>";
echo $prompt.sprintf(
'(Event #'.$event_id.') '.__(
'Executing command: %s',
$command
$command_str
)
);
echo '</div><br>';
@ -1214,7 +1217,7 @@ if ($dialogue_event_response) {
} else {
echo "<div class='left'>";
echo $prompt."Executing command: $command";
echo $prompt."Executing command: $command_str";
echo '</div><br>';
echo "<div id='response_loading_command' style='display:none'>".html_print_image('images/spinner.gif', true).'</div>';

View File

@ -2226,6 +2226,7 @@ CREATE TABLE IF NOT EXISTS `tevent_response` (
`params` TEXT NOT NULL,
`server_to_exec` int(10) unsigned NOT NULL DEFAULT 0,
`command_timeout` int(5) unsigned NOT NULL DEFAULT 90,
`display_command` tinyint(1) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1186,7 +1186,7 @@ INSERT INTO `tagent_custom_fields` VALUES (1,'Serial&#x20;Number',0,0,''),(2,'De
INSERT INTO `ttag` VALUES (1,'network','Network&#x20;equipment','http://artica.es','','',''),(2,'critical','Critical&#x20;modules','','','',''),(3,'dmz','DMZ&#x20;Network&#x20;Zone','','','',''),(4,'performance','Performance&#x20;anda&#x20;capacity&#x20;modules','','','',''),(5,'configuration','','','','','');
INSERT INTO `tevent_response` VALUES (1,'Ping&#x20;to&#x20;host','Ping&#x20;to&#x20;the&#x20;agent&#x20;host','ping&#x20;-c&#x20;5&#x20;_agent_address_','command',0,620,500,0,'',0,90),(3,'Create&#x20;incident&#x20;from&#x20;event','Create&#x20;a&#x20;incident&#x20;from&#x20;the&#x20;event&#x20;with&#x20;the&#x20;standard&#x20;incidents&#x20;system&#x20;of&#x20;Pandora&#x20;FMS','index.php?sec=workspace&amp;sec2=operation/incidents/incident_detail&amp;insert_form&amp;from_event=_event_id_','url',0,0,0,1,'',0,90),(5,'Restart&#x20;agent','Restart&#x20;the&#x20;agent&#x20;with&#x20;using&#x20;UDP&#x20;protocol.&#x0d;&#x0a;&#x0d;&#x0a;To&#x20;use&#x20;this&#x20;response&#x20;is&#x20;necessary&#x20;to&#x20;have&#x20;installed&#x20;Pandora&#x20;FMS&#x20;server&#x20;and&#x20;console&#x20;in&#x20;the&#x20;same&#x20;machine.','/usr/share/pandora_server/util/udp_client.pl&#x20;_agent_address_&#x20;41122&#x20;&quot;REFRESH&#x20;AGENT&quot;','command',0,620,500,0,'',0,90),(6,'Ping&#x20;to&#x20;module&#x20;agent&#x20;host','Ping&#x20;to&#x20;the&#x20;module&#x20;agent&#x20;host','ping&#x20;-c&#x20;5&#x20;_module_address_','command',0,620,500,0,'',0,90);
INSERT INTO `tevent_response` VALUES (1,'Ping&#x20;to&#x20;host','Ping&#x20;to&#x20;the&#x20;agent&#x20;host','ping&#x20;-c&#x20;5&#x20;_agent_address_','command',0,620,500,0,'',0,90,0),(3,'Create&#x20;incident&#x20;from&#x20;event','Create&#x20;a&#x20;incident&#x20;from&#x20;the&#x20;event&#x20;with&#x20;the&#x20;standard&#x20;incidents&#x20;system&#x20;of&#x20;Pandora&#x20;FMS','index.php?sec=workspace&amp;sec2=operation/incidents/incident_detail&amp;insert_form&amp;from_event=_event_id_','url',0,0,0,1,'',0,90,0),(5,'Restart&#x20;agent','Restart&#x20;the&#x20;agent&#x20;with&#x20;using&#x20;UDP&#x20;protocol.&#x0d;&#x0a;&#x0d;&#x0a;To&#x20;use&#x20;this&#x20;response&#x20;is&#x20;necessary&#x20;to&#x20;have&#x20;installed&#x20;Pandora&#x20;FMS&#x20;server&#x20;and&#x20;console&#x20;in&#x20;the&#x20;same&#x20;machine.','/usr/share/pandora_server/util/udp_client.pl&#x20;_agent_address_&#x20;41122&#x20;&quot;REFRESH&#x20;AGENT&quot;','command',0,620,500,0,'',0,90,0),(6,'Ping&#x20;to&#x20;module&#x20;agent&#x20;host','Ping&#x20;to&#x20;the&#x20;module&#x20;agent&#x20;host','ping&#x20;-c&#x20;5&#x20;_module_address_','command',0,620,500,0,'',0,90,0);
INSERT INTO `tupdate_settings` VALUES ('current_update', '412'), ('customer_key', 'PANDORA-FREE'), ('updating_binary_path', 'Path where the updated binary files will be stored'), ('updating_code_path', 'Path where the updated code is stored'), ('dbname', ''), ('dbhost', ''), ('dbpass', ''), ('dbuser', ''), ('dbport', ''), ('proxy', ''), ('proxy_port', ''), ('proxy_user', ''), ('proxy_pass', '');