wazuh / wazuh-agent

Wazuh agent, the Wazuh agent for endpoints.
GNU Affero General Public License v3.0
32 stars 18 forks source link

Replace `os_regex` with `RE2` in the Agent #152

Open cborla opened 2 months ago

cborla commented 2 months ago

Parent issue:

Description

Deprecate or remove the non-standard os_regex library and replace it with the standard RE2 library. This will improve compatibility and long-term maintainability of the Inventory module.

Tasks

Testing tasks

LucioDonda commented 2 months ago

Update 16/09/2024

LucioDonda commented 2 months ago

Update 17/09/2024

LucioDonda commented 2 months ago

Update 18/09/2024

After the team daily I came across that I was pointing to the wrong file. New analysis was made:

1) int OSRegex_Compile(const char *pattern, OSRegex *reg, int flags); Brief: Compile a regular expression to be used later Usage:

2) const char *OSRegex_Execute(const char *str, OSRegex *reg) __attribute__((nonnull(2))); Brief: Compares an already compiled OSRegex regular expression with a string Usage:

3) const char *OSRegex_Execute_ex(const char *str, OSRegex *reg, regex_matching *regex_match) __attribute__((nonnull(2))); Brief: Compares an already compiled OSRegex regular expression with a string (+ struct for pattern matches) Usage:

4) void OSRegex_FreePattern(OSRegex *reg); Brief: Release all the memory created by the compilation/execution phases Usage:

5) int OS_Regex(const char *pattern, const char *str); Brief: wrapper around the compile/execute functions. It should only be used when the pattern is only going to be used once. Usage:

6) int OSMatch_Compile(const char *pattern, OSMatch *reg, int flags); Brief: Compile a pattern to be used later. Usage:

7) int OSMatch_Execute(const char *str, size_t str_len, OSMatch *reg); Brief: Compare an already compiled pattern with a not NULL string. Usage:

8) void OSMatch_FreePattern(OSMatch *reg); Brief: Release all the memory created by the compilation/execution phases */ Usage:

9) int OS_Match2(const char *pattern, const char *str) __attribute__((nonnull(2))); Brief: No Info Usage:

10)int OS_WordMatch(const char *pattern, const char *str) __attribute__((nonnull)); Brief: Searches for pattern in the string OS_Match ??

11) char **OS_StrBreak(char match, const char *str, size_t size); Brief: Split a string into multiples pieces, divided by a char "match". Usage:

12)size_t OS_StrHowClosedMatch(const char *str1, const char *str2); Brief: Returns the number of characters that both strings have in similar

13) int OS_StrStartsWith(const char *str, const char *pattern) __attribute__((nonnull)); Brief: Verifies if a string starts with the provided pattern.

14) int OS_StrIsNum(const char *str); Brief: Checks if a specific string is numeric (like "129544") */ Usage:

15) void OSRegex_free_regex_matching (regex_matching *reg); Brief: Free memory of regex_matching struct Usage:

cborla commented 1 month ago

I will move this issue to backlog again because it has no priority.