Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt file_op and bzip2_op compatibility for windows #433

Closed
ncvicchi opened this issue Dec 16, 2024 · 10 comments
Closed

Adapt file_op and bzip2_op compatibility for windows #433

ncvicchi opened this issue Dec 16, 2024 · 10 comments
Assignees
Labels

Comments

@ncvicchi
Copy link
Contributor

ncvicchi commented Dec 16, 2024

Description

file_op.c it is not being used for inventory (aka syscollector) in Windows, but it is used in Linux.
Since it might be used or necessary in the future, this issue requires that file_op and bzip2_op to be developed for Windows also.

Tasks

  1. Analyze Dependencies

    • Review the existing implementations of file_op.c and bzip2_op.c on Linux.
    • Identify the dependencies and features that need to be ported or adjusted for Windows.
  2. Develop Windows-Compatible Modules

    • Implement file_op.c functionality for Windows, ensuring compatibility with the Windows.
    • Port bzip2_op.c to Windows, leveraging an appropriate compression library (e.g., bzip2 with Windows-specific adjustments).
  3. Testing

    • Develop unit tests to validate the new Windows implementations.
    • Conduct cross-platform testing to ensure consistent behavior between Windows and Linux.

Related Issues and PRs

@cborla cborla changed the title Platform Abstraction Layer - file_op compatibility for windows Adapt file_op and bzip2_op compatibility for windows Dec 16, 2024
@wazuhci wazuhci moved this to Backlog in XDR+SIEM/Release 5.0.0 Dec 17, 2024
@wazuhci wazuhci moved this from Backlog to In progress in XDR+SIEM/Release 5.0.0 Jan 31, 2025
@xkazinx
Copy link
Member

xkazinx commented Feb 2, 2025

  • After updating Visual Studio 2022, I included both bzip2_op.c and file_op.h in a project to test compiling them, where bzip2_op.c compiles successfully, but not file_op.c , with errors in the following functions:
int check_path_type(const char *dir)
int UnmergeFiles(const char *finalpath, const char *optdir, int mode, char ***unmerged_files)
int MergeAppendFile(FILE *finalfp, const char *files, int path_offset)
int cldir_ex_ignore(const char * name, const char ** ignore)
char ** wreaddir(const char * name)
  • Most of them are because of the Dir object, and because of dirname function calls.
  • Function calls to dirname were fixed, with tests pending to confirm correct functionality.

@xkazinx
Copy link
Member

xkazinx commented Feb 4, 2025

  • Added Dir object alternative for windows for file_op.c.
  • Both bzip2_op.c and file_op.c compile and were pushed to determine if tests pass.

@xkazinx
Copy link
Member

xkazinx commented Feb 4, 2025

Tests have passed successfully, it will be determined if tests have to be developed for these changes.

@xkazinx
Copy link
Member

xkazinx commented Feb 5, 2025

  • Added file_op to CMakeLists.txt for WIN32.

  • bzip2 is already being built as a binary file for WIN32.

  • Added missing header files for os-specific pal files.

  • Compilation successful for Windows.

  • Pending:

    • Test compiling in Linux and MacOS.
    • Update tests

@xkazinx
Copy link
Member

xkazinx commented Feb 6, 2025

  • Compilation successful for Windows, MacOS and Linux, after:
    • Addition of error_messages as include directory for pal.
    • Addition of file_op as dependency for pal.
    • Fix of use of different headers based on OS.
  • Started to port tests from wazuh-agent\src\common\file_op\tests\unit\tests\test_file_op.c to google tests.
  • Next:
    • Determine whether file_op functions must be ported into the pal project.

@xkazinx
Copy link
Member

xkazinx commented Feb 7, 2025

  • Added file_op_test project:
    • After checking that tests src/common are mostly using the utils_unit_test project for testing, but that this project is disabled, the new file_op_test project was created, as the only tests running at src/common are LoggerTest and PalTimeTest.
    • After modifying src\common\file_op\CMakeLists.txt and src\common\file_op\CMakeLists.txt, the file_op project started to throw warnings-as-errors, where it will be determined next if these warnings need to be solved individually or if they can be ignored from the project configurations.
    • file_op_test.exe is now compiling and the tests from wazuh-agent\src\common\file_op\tests\unit\tests\test_file_op.c are being ported into this project with google tests.

@xkazinx
Copy link
Member

xkazinx commented Feb 10, 2025

  • 07/02/2025:
    • After adding dependencies to the file_op_test project, it stopped compiling, for which it will be consulted in Monday to determine if the CMakeLists.txt is being set correctly.
    • The windows related tests, along with common OS ones, were ported to google tests, pending to be tested once the project compiles.

@wazuhci wazuhci moved this from In progress to On hold in XDR+SIEM/Release 5.0.0 Feb 10, 2025
@cborla
Copy link
Member

cborla commented Feb 10, 2025

Is moved to on hold because release test needs to be completed.

@nbertoldo nbertoldo self-assigned this Feb 11, 2025
@wazuhci wazuhci moved this from On hold to In progress in XDR+SIEM/Release 5.0.0 Feb 11, 2025
@wazuhci wazuhci moved this from In progress to Pending review in XDR+SIEM/Release 5.0.0 Feb 13, 2025
@cborla
Copy link
Member

cborla commented Feb 13, 2025

This issue is included as part of another PR, because the c++ file wrapper will not be used.

@wazuhci wazuhci moved this from Pending review to Blocked in XDR+SIEM/Release 5.0.0 Feb 13, 2025
@cborla
Copy link
Member

cborla commented Feb 17, 2025

Fixed in Some common libraries improvements

@cborla cborla closed this as completed Feb 17, 2025
@wazuhci wazuhci moved this from Blocked to Done in XDR+SIEM/Release 5.0.0 Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants