Skip to content

Commit

Permalink
Revert "Unit tests for syscollector legacy decoder #10368 (#15985)"
Browse files Browse the repository at this point in the history
This reverts commit 695c6e5.
  • Loading branch information
GGP1 authored and fdalmaup committed Nov 3, 2023
1 parent 30bc532 commit d30171c
Show file tree
Hide file tree
Showing 2 changed files with 642 additions and 2,357 deletions.
44 changes: 19 additions & 25 deletions src/analysisd/decoders/syscollector.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@
#include "wazuhdb_op.h"
#include "wazuh_db/wdb.h"

#ifdef WAZUH_UNIT_TESTING
#define STATIC
#else
#define STATIC static
#endif

STATIC int error_package = 0;
STATIC int prev_package_id = 0;
STATIC int error_port = 0;
STATIC int prev_port_id = 0;
STATIC int error_process = 0;
STATIC int prev_process_id = 0;
static int error_package = 0;
static int prev_package_id = 0;
static int error_port = 0;
static int prev_port_id = 0;
static int error_process = 0;
static int prev_process_id = 0;

static int decode_netinfo( Eventinfo *lf, cJSON * logJSON, int *socket);
static int decode_osinfo( Eventinfo *lf, cJSON * logJSON, int *socket);
Expand Down Expand Up @@ -846,8 +840,8 @@ int decode_netinfo(Eventinfo *lf, cJSON * logJSON, int *socket) {
msg_type = cJSON_GetObjectItem(logJSON, "type")->valuestring;

if (!msg_type) {
merror("Invalid message. Type not found."); // LCOV_EXCL_LINE
goto end; // LCOV_EXCL_LINE
merror("Invalid message. Type not found.");
goto end;
} else if (strcmp(msg_type, "network_end") == 0) {

cJSON * scan_id = cJSON_GetObjectItem(logJSON, "ID");
Expand All @@ -862,8 +856,8 @@ int decode_netinfo(Eventinfo *lf, cJSON * logJSON, int *socket) {
goto end;
}
} else {
merror("at decode_netinfo(): unknown type found."); // LCOV_EXCL_LINE
goto end; // LCOV_EXCL_LINE
merror("at decode_netinfo(): unknown type found.");
goto end;
}
}

Expand Down Expand Up @@ -1198,8 +1192,8 @@ int decode_port( Eventinfo *lf, cJSON * logJSON,int *socket) {
msg_type = cJSON_GetObjectItem(logJSON, "type")->valuestring;

if (!msg_type) {
merror("Invalid message. Type not found."); // LCOV_EXCL_LINE
goto end; // LCOV_EXCL_LINE
merror("Invalid message. Type not found.");
goto end;
} else if (strcmp(msg_type, "port_end") == 0) {
if (error_port) {
if (scan_id->valueint == prev_port_id) {
Expand Down Expand Up @@ -1520,8 +1514,8 @@ int decode_package( Eventinfo *lf,cJSON * logJSON,int *socket) {
msg_type = cJSON_GetObjectItem(logJSON, "type")->valuestring;

if (!msg_type) {
merror("Invalid message. Type not found."); // LCOV_EXCL_LINE
goto end; // LCOV_EXCL_LINE
merror("Invalid message. Type not found.");
goto end;
} else if (strcmp(msg_type, "program_end") == 0) {
if (error_package) {
if (scan_id->valueint == prev_package_id) {
Expand Down Expand Up @@ -1590,9 +1584,9 @@ int decode_hotfix(Eventinfo *lf, cJSON * logJSON, int *socket) {
msg_type = cJSON_GetObjectItem(logJSON, "type")->valuestring;

if (!msg_type) {
merror("Invalid message. Type not found."); // LCOV_EXCL_LINE
free(msg); // LCOV_EXCL_LINE
return -1; // LCOV_EXCL_LINE
merror("Invalid message. Type not found.");
free(msg);
return -1;
} else if (strcmp(msg_type, "hotfix_end") == 0) {
snprintf(msg, OS_SIZE_1024 - 1, "agent %s hotfix del %d", lf->agent_id, scan_id->valueint);

Expand Down Expand Up @@ -1932,8 +1926,8 @@ int decode_process(Eventinfo *lf, cJSON * logJSON,int *socket) {
msg_type = cJSON_GetObjectItem(logJSON, "type")->valuestring;

if (!msg_type) {
merror("Invalid message. Type not found."); // LCOV_EXCL_LINE
goto end; // LCOV_EXCL_LINE
merror("Invalid message. Type not found.");
goto end;
} else if (strcmp(msg_type, "process_end") == 0) {

if (error_process) {
Expand Down

0 comments on commit d30171c

Please sign in to comment.