Skip to content

Commit b8fe691

Browse files
authored
Merge pull request #163 from wazuh/poc/152-os-regex-removal
Removal of Dependencies to Libraries Before Migration
2 parents da7a0eb + 10ae0e9 commit b8fe691

File tree

17 files changed

+54
-59
lines changed

17 files changed

+54
-59
lines changed

src/common/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@ add_subdirectory(time_op)
44
add_subdirectory(file_op)
55
add_subdirectory(privsep_op)
66
add_subdirectory(pthreads_op)
7-
add_subdirectory(os_xml)
87
add_subdirectory(error_messages)
98
add_subdirectory(mem_op)
109
add_subdirectory(binaries_op)
11-
add_subdirectory(os_net)
12-
add_subdirectory(os_regex)
1310
add_subdirectory(regex_op)
14-
add_subdirectory(validate_op)
1511
add_subdirectory(randombytes)
1612
add_subdirectory(bzip2_op)
17-
add_subdirectory(string_op)
18-
add_subdirectory(expression)
1913
add_subdirectory(debug_op)
2014
add_subdirectory(logging_helper)
2115
add_subdirectory(networkHelper)

src/common/debug_op/CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,10 @@ target_link_libraries(debug_op
1111
mem_op
1212
privsep_op
1313
pthreads_op
14-
os_xml
1514
error_messages
16-
os_regex
17-
os_net
18-
string_op
1915
binaries_op
2016
regex_op
21-
validate_op
22-
expression
2317
randombytes
2418
bzip2_op
25-
cjson)
19+
cjson)
20+

src/common/debug_op/src/debug_op.c

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -278,47 +278,55 @@ void w_logging_init(){
278278
}
279279

280280
void os_logging_config(){
281-
OS_XML xml;
281+
// OS_XML xml;
282282
const char * xmlf[] = {"ossec_config", "logging", "log_format", NULL};
283283
char * logformat;
284284
char ** parts = NULL;
285285
int i;
286286

287287
pid = (int)getpid();
288288

289-
if (OS_ReadXML(OSSECCONF, &xml) < 0){
290-
flags.log_plain = 1;
291-
flags.log_json = 0;
292-
OS_ClearXML(&xml);
293-
mlerror_exit(LOGLEVEL_ERROR, XML_ERROR, OSSECCONF, xml.err, xml.err_line);
294-
}
295-
296-
logformat = OS_GetOneContentforElement(&xml, xmlf);
289+
// TODO: replace function OS_ReadXML
290+
// if (OS_ReadXML(OSSECCONF, &xml) < 0){
291+
// flags.log_plain = 1;
292+
// flags.log_json = 0;
293+
// TODO: replace function OS_ClearXML
294+
// OS_ClearXML(&xml);
295+
// TODO: replace XML_ERROR
296+
// mlerror_exit(LOGLEVEL_ERROR, XML_ERROR, OSSECCONF, xml.err, xml.err_line);
297+
// }
298+
// TODO: replace function OS_GetOneContentforElement
299+
// logformat = OS_GetOneContentforElement(&xml, xmlf);
297300

298301
if (!logformat || logformat[0] == '\0'){
299302

300303
flags.log_plain = 1;
301304
flags.log_json = 0;
302305

303306
free(logformat);
304-
OS_ClearXML(&xml);
305-
mdebug1(XML_NO_ELEM, "log_format");
307+
// TODO: replace function OS_ClearXML
308+
// OS_ClearXML(&xml);
309+
// TODO: replace XML_NO_ELEM
310+
// mdebug1(XML_NO_ELEM, "log_format");
306311

307312
}else{
308313

309-
parts = OS_StrBreak(',', logformat, 2);
314+
// TODO: replace function OS_StrBreak
315+
// parts = OS_StrBreak(',', logformat, 2);
310316
char * part;
311317
if (parts){
312318
for (i=0; parts[i]; i++){
313-
part = w_strtrim(parts[i]);
319+
// TODO: replace function w_strtrim
320+
// part = w_strtrim(parts[i]);
314321
if (!strcmp(part, "plain")){
315322
flags.log_plain = 1;
316323
}else if(!strcmp(part, "json")){
317324
flags.log_json = 1;
318325
}else{
319326
flags.log_plain = 1;
320327
flags.log_json = 0;
321-
mlerror_exit(LOGLEVEL_ERROR, XML_VALUEERR, "log_format", part);
328+
// TODO: replace XML_VALUEERR
329+
// mlerror_exit(LOGLEVEL_ERROR, XML_VALUEERR, "log_format", part);
322330
}
323331
}
324332
for (i=0; parts[i]; i++){
@@ -328,7 +336,8 @@ void os_logging_config(){
328336
}
329337

330338
free(logformat);
331-
OS_ClearXML(&xml);
339+
// TODO: replace function OS_ClearXML
340+
// OS_ClearXML(&xml);
332341
}
333342
}
334343

src/common/expression/include/expression.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#define PCRE2_CODE_UNIT_WIDTH 8
1414

1515
#include <pcre2.h>
16-
#include "os_regex.h"
1716
#include "os_ip.h"
1817

1918
#define OSMATCH_STR "osmatch"

src/common/file_op/src/file_op.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,7 +2202,9 @@ int cldir_ex_ignore(const char * name, const char ** ignore) {
22022202

22032203
while (dirent = readdir(dir), dirent) {
22042204
// Skip "." and ".."
2205-
if ((dirent->d_name[0] == '.' && (dirent->d_name[1] == '\0' || (dirent->d_name[1] == '.' && dirent->d_name[2] == '\0'))) || w_str_in_array(dirent->d_name, ignore)) {
2205+
// TODO: replace function w_str_in_array
2206+
// if ((dirent->d_name[0] == '.' && (dirent->d_name[1] == '\0' || (dirent->d_name[1] == '.' && dirent->d_name[2] == '\0'))) || w_str_in_array(dirent->d_name, ignore)) {
2207+
if (dirent->d_name[0] == '.' && (dirent->d_name[1] == '\0' || (dirent->d_name[1] == '.' && dirent->d_name[2] == '\0'))) {
22062208
continue;
22072209
}
22082210

@@ -3449,25 +3451,30 @@ char *w_homedir(char *arg) {
34493451
#ifdef __MACH__
34503452
pid_t pid = getpid();
34513453
if (proc_pidpath(pid, buff, PATH_MAX) > 0) {
3452-
buff = w_strtok_r_str_delim(delim, &buff);
3454+
// TODO: replace function w_strtok_r_str_delim
3455+
//buff = w_strtok_r_str_delim(delim, &buff);
34533456
}
34543457
#else
34553458
if (realpath("/proc/self/exe", buff) != NULL) {
34563459
dirname(buff);
3457-
buff = w_strtok_r_str_delim(delim, &buff);
3460+
// TODO: replace function w_strtok_r_str_delim
3461+
//buff = w_strtok_r_str_delim(delim, &buff);
34583462
}
34593463
else if (realpath("/proc/curproc/file", buff) != NULL) {
34603464
dirname(buff);
3461-
buff = w_strtok_r_str_delim(delim, &buff);
3465+
// TODO: replace function w_strtok_r_str_delim
3466+
//buff = w_strtok_r_str_delim(delim, &buff);
34623467
}
34633468
else if (realpath("/proc/self/path/a.out", buff) != NULL) {
34643469
dirname(buff);
3465-
buff = w_strtok_r_str_delim(delim, &buff);
3470+
// TODO: replace function w_strtok_r_str_delim
3471+
//buff = w_strtok_r_str_delim(delim, &buff);
34663472
}
34673473
#endif
34683474
else if (realpath(arg, buff) != NULL) {
34693475
dirname(buff);
3470-
buff = w_strtok_r_str_delim(delim, &buff);
3476+
// TODO: replace function w_strtok_r_str_delim
3477+
//buff = w_strtok_r_str_delim(delim, &buff);
34713478
} else {
34723479
// The path was not found so read WAZUH_HOME env var
34733480
char * home_env = NULL;

src/common/os_net/src/os_net.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -892,9 +892,10 @@ void resolve_hostname(char **hostname, int attempts) {
892892
char *f_ip;
893893

894894
assert(hostname != NULL);
895-
if (OS_IsValidIP(*hostname, NULL) == 1) {
896-
return;
897-
}
895+
// TODO: replace function OS_IsValidIP
896+
// if (OS_IsValidIP(*hostname, NULL) == 1) {
897+
// return;
898+
// }
898899

899900
tmp_str = strchr(*hostname, '/');
900901
if (tmp_str) {
@@ -1059,9 +1060,11 @@ int get_ipv6_string(struct in6_addr addr6, char *address, size_t address_size) {
10591060
}
10601061
#endif
10611062

1062-
if ((ret == OS_SUCCESS) && !OS_GetIPv4FromIPv6(address, IPSIZE)) {
1063-
OS_ExpandIPv6(address, IPSIZE);
1064-
}
1063+
// TODO: replace function OS_GetIPv4FromIPv6
1064+
// if ((ret == OS_SUCCESS) && !OS_GetIPv4FromIPv6(address, IPSIZE)) {
1065+
// TODO: replace function OS_ExpandIPv6
1066+
// OS_ExpandIPv6(address, IPSIZE);
1067+
// }
10651068

10661069
return ret;
10671070
}

src/common/pthreads_op/src/pthreads_op.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ int CreateThreadJoinable(pthread_t *lthread, void * (*function_pointer)(void *),
2929
return -1;
3030
}
3131

32-
read_size = 1024 * (size_t)getDefine_Int("wazuh", "thread_stack_size", 2048, 65536);
32+
// TODO: replace function getDefine_Int
33+
read_size = 1024 * (size_t) 65536;
34+
// read_size = 1024 * (size_t)getDefine_Int("wazuh", "thread_stack_size", 2048, 65536);
3335

3436
/* Set the maximum stack limit to new threads */
3537
if (pthread_attr_setstacksize(&attr, read_size)) {

src/common/string_op/src/string_op.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include "shared.h"
1212
#include "string.h"
13-
#include "os_regex.h"
1413
#include "string_op.h"
1514

1615
#ifdef WIN32

src/common/utils/include/shared.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,11 @@
119119
#include "mem_op.h"
120120
#include "privsep_op.h"
121121
#include "pthreads_op.h"
122-
#include "os_xml.h"
123122
#include "error_messages.h"
124-
#include "os_regex.h"
125-
#include "string_op.h"
126123
#include "binaries_op.h"
127124
#include "os_ip.h"
128-
#include "os_net.h"
129-
#include "expression.h"
130125
#include "randombytes.h"
131126
#include "bzip2_op.h"
132-
#include "validate_op.h"
133127

134128

135129
#ifndef LARGEFILE64_SOURCE

src/common/utils/tests/unit/wrappers/externals/pcre2/pcre2_wrappers.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#define PCRE2_CODE_UNIT_WIDTH 8
1515

1616
#include "shared.h"
17-
#include "expression.h"
1817

1918
#define w_pcre2_match_data_create_from_pattern wrap_pcre2_match_data_create_from_pattern
2019
#define w_pcre2_match wrap_pcre2_match

src/common/validate_op/src/validate_op.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include "shared.h"
1212
#include "validate_op.h"
13-
#include "expression.h"
1413
#include "os_net.h"
1514

1615
#ifdef WAZUH_UNIT_TESTING

src/common/version_op/src/version_op.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,9 @@ os_info *get_unix_version()
716716
char *key = strtok_r(buff, ":", &save_ptr);
717717
if (key) {
718718
const char *expected_key = "System Version";
719-
char *trimmed_key = w_strtrim(key);
719+
// TODO: replace function w_strtrim
720+
// char *trimmed_key = w_strtrim(key);
721+
char *trimmed_key = key;
720722
if (NULL != trimmed_key && strncmp(trimmed_key, expected_key, strlen(expected_key)) == 0) {
721723
char *value = strtok_r(NULL, " ", &save_ptr);
722724
if (value) {

src/modules/fim/src/whodata/syscheck_audit.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "../os_net/os_net.h"
1717
#include "syscheck_op.h"
1818
#include "audit_op.h"
19-
#include "string_op.h"
2019

2120
#define AUDIT_RULES_FILE "etc/audit_rules_wazuh.rules"
2221
#define AUDIT_RULES_LINK "/etc/audit/rules.d/audit_rules_wazuh.rules"

src/modules/inventory/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ target_include_directories(inventory PUBLIC
2424
${COMMON_FOLDER}/file_op/include
2525
${COMMON_FOLDER}/hashHelper/include
2626
${COMMON_FOLDER}/logging_helper/include
27-
${COMMON_FOLDER}/os_xml/include
2827
${COMMON_FOLDER}/privsep_op/include
2928
${COMMON_FOLDER}/pthreads_op/include
3029
${COMMON_FOLDER}/stringHelper/include
31-
${COMMON_FOLDER}/string_op/include
3230
${COMMON_FOLDER}/time_op/include
3331
${COMMON_FOLDER}/timeHelper/include
3432
${COMMON_FOLDER}/utils)
@@ -48,7 +46,6 @@ target_link_libraries(inventory PUBLIC
4846
OpenSSL::SSL
4947
OpenSSL::Crypto
5048
utils
51-
os_regex
5249
logging_helper
5350
pthreads_op
5451
MultiTypeQueue)

src/modules/inventory/src/inventory.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <shared.h>
1515
#include <defs.h>
1616
#include <logging_helper.h>
17-
#include <string_op.h>
1817
#include <pthreads_op.h>
1918

2019
#include <inventory.hpp>

src/modules/logcollector/include/journal_log.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "../config/localfile-config.h"
66

77
#include "cJSON.h"
8-
#include "expression.h"
98

109
/*******************************************************************************
1110
* NOTE: This module is not thread-safe.

src/modules/sca/src/wm_sca.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <os_net/os_net.h>
1414
#include <sys/stat.h>
1515
#include "os_crypto/sha256/sha256_op.h"
16-
#include "expression.h"
1716
#include "shared.h"
1817

1918
#undef minfo

0 commit comments

Comments
 (0)