Fix minor issues related with pandorawmic

This commit is contained in:
José González 2022-06-20 16:20:49 +02:00
parent 4589a7c298
commit 275fd2ed19
2 changed files with 44 additions and 33 deletions

View File

@ -667,7 +667,7 @@ $table_other->data[$i++][1] = html_print_input_text(
$config['wmiBinary'], $config['wmiBinary'],
'', '',
50, 50,
10, 50,
true true
); );

View File

@ -2814,7 +2814,7 @@ class AgentWizard extends HTML
// Unpack the query filters. // Unpack the query filters.
$queryFilters = json_decode($module['query_filters'], true); $queryFilters = json_decode($module['query_filters'], true);
// Name of query filter field. // Name of query filter field.
$fieldValueName = $fieldSet[$queryFilters['field']]; $fieldValueName = (empty($fieldSet[$queryFilters['field']]) === false) ? $fieldSet[$queryFilters['field']] : '1';
// Evaluate type of scan and execution. // Evaluate type of scan and execution.
if ($module['scan_type'] == SCAN_TYPE_FIXED) { if ($module['scan_type'] == SCAN_TYPE_FIXED) {
@ -2900,6 +2900,7 @@ class AgentWizard extends HTML
$dataCombined = array_combine($columnsList, $rowList); $dataCombined = array_combine($columnsList, $rowList);
// Change the macros for values. // Change the macros for values.
foreach ($dataCombined as $macroKey => $macroValue) { foreach ($dataCombined as $macroKey => $macroValue) {
$macroKey = trim($macroKey);
if (preg_match('/_'.$macroKey.'_/', $valueOperation) !== 0) { if (preg_match('/_'.$macroKey.'_/', $valueOperation) !== 0) {
$valueOperation = preg_replace( $valueOperation = preg_replace(
'/_'.$macroKey.'_/', '/_'.$macroKey.'_/',
@ -3003,6 +3004,7 @@ class AgentWizard extends HTML
); );
// Change the macros for values. // Change the macros for values.
foreach ($dataCombined as $macroKey => $macroValue) { foreach ($dataCombined as $macroKey => $macroValue) {
$macroKey = trim($macroKey);
if (preg_match('/_'.$macroKey.'_/', $valueOperation) !== 0) { if (preg_match('/_'.$macroKey.'_/', $valueOperation) !== 0) {
$valueOperation = preg_replace( $valueOperation = preg_replace(
'/_'.$macroKey.'_/', '/_'.$macroKey.'_/',
@ -3030,6 +3032,14 @@ class AgentWizard extends HTML
} }
} }
// If we not retrieve information (P.E. connection refused).
if (empty($moduleBlocks) === true) {
$this->message['type'][] = 'warning';
$this->message['message'][] = __(
'No information could be retrieved.'
);
$this->showMessage();
} else {
// Create the final table with all of data received. // Create the final table with all of data received.
foreach ($moduleBlocks as $module) { foreach ($moduleBlocks as $module) {
// Prepare the blocks. If its new, create a new index. // Prepare the blocks. If its new, create a new index.
@ -3064,6 +3074,7 @@ class AgentWizard extends HTML
// Add Create Modules form. // Add Create Modules form.
$this->createModulesForm(); $this->createModulesForm();
} }
}
/** /**
@ -5544,13 +5555,13 @@ class AgentWizard extends HTML
string $unit='', string $unit='',
?int $type=0 ?int $type=0
) { ) {
$output = '';
try { try {
// Avoid non-numeric or arithmetic chars for security reasons. // Avoid non-numeric or arithmetic chars for security reasons.
if (preg_match('/(([^0-9\s\+\-\*\/\(\).,])+)/', $operation) === 1) { if (preg_match('/(([^0-9\s\+\-\*\/\(\).,])+)/', $operation) === 1) {
throw new Exception(sprintf(__("The operation '%s' is not permitted. Review for remote components."), $operation)); throw new Exception(sprintf(__("The operation '%s' is not permitted. Review for remote components."), $operation));
} else { } else {
// Get the result of the operation and set it. // Get the result of the operation and set it.
$output = '';
eval('$output = '.$operation.';'); eval('$output = '.$operation.';');
// If this module has unit, attach to current value. // If this module has unit, attach to current value.
$output = $this->replacementUnit( $output = $this->replacementUnit(