Skip to content

Commit

Permalink
Merge pull request #373 from wazuh/fix-js-bugs
Browse files Browse the repository at this point in the history
Fix JavaScript code bugs
  • Loading branch information
crd1985 authored Apr 16, 2019
2 parents e9dbce0 + c286087 commit c1cfa6c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
11 changes: 9 additions & 2 deletions helpers/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ var disable_timeout = false;
exports.exec = function(cmd, args, stdin, callback) {
const child_process = require('child_process');

if (stdin != null)
stdin['ossec_path'] = config.ossec_path;
if (!(stdin instanceof Object)) {
err = "Error executing command: stdin value must be an object: " + stdin
logger.error("CMD - " + err);
error = true;
callback({"error": 1, "message": err});
return;
}

stdin['ossec_path'] = config.ossec_path;

// log
stdin['arguments']['wait_for_complete'] = disable_timeout;
Expand Down
4 changes: 1 addition & 3 deletions helpers/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ exports.select_param_to_json = function (select_param){
var select = {"fields": []};

if (typeof select_param == 'string') {
select_param.split(',').map(function(x) {
select['fields'].push(x);
});
select['fields'] = select_param.split(',');
} else {
select['fields'] = select_param;
}
Expand Down
12 changes: 6 additions & 6 deletions helpers/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ var LEVEL_DEBUG = 4;
var user = "";

var logger_level = LEVEL_INFO;
switch (config.logs) {
case "INFO", "info":
switch (config.logs.toLowerCase()) {
case "info":
logger_level = LEVEL_INFO;
break;
case "WARNING", "warning":
case "warning":
logger_level = LEVEL_WARNING;
break;
case "ERROR", "error":
case "error":
logger_level = LEVEL_ERROR;
break;
case "DEBUG", "debug":
case "debug":
logger_level = LEVEL_DEBUG;
break;
case "DISABLED", "disabled":
case "disabled":
logger_level = LEVEL_DISABLED;
break;
default:
Expand Down

0 comments on commit c1cfa6c

Please sign in to comment.