Skip to content

SCA: Implement Execution Logic #687

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

Closed
4 tasks done
TomasTurina opened this issue Mar 20, 2025 · 10 comments · Fixed by #753
Closed
4 tasks done

SCA: Implement Execution Logic #687

TomasTurina opened this issue Mar 20, 2025 · 10 comments · Fixed by #753
Assignees
Labels
level/task Task issue module/sca Security Compliance Assessment type/enhancement Enhancement issue

Comments

@TomasTurina
Copy link
Member

TomasTurina commented Mar 20, 2025

Description

This task involves executing SCA policy checks, including commands, file and directory checks, registry evaluations, and process inspections. Each check must run as an independent coroutine to allow scan interruptions at any time. Common helper libraries (e.g., cmdHelper, file_helper, registryHelper) should be used to streamline implementation.

Tasks

  1. Research & Design

    • Define execution requirements for each check type.
    • Establish coroutine-based execution flow.
  2. Development

    • Implement execution logic for each check type.
    • Ensure coroutine-based execution for interruption support.
    • Integrate with common helper libraries.
  3. Unit Testing

    • Develop tests to validate each check execution.
    • Ensure proper handling of scan interruptions.
  4. Documentation

    • Document execution flow and helper library usage.
    • Provide examples of check execution behavior.

Definition of Done

  • Execution logic for all check types is implemented.
  • Coroutine-based execution supports scan interruption.
  • Unit tests validate execution correctness.
  • Documentation is complete and reviewed.
@TomasTurina TomasTurina added level/task Task issue module/sca Security Compliance Assessment type/enhancement Enhancement issue labels Mar 20, 2025
@wazuhci wazuhci moved this to Triage in XDR+SIEM/Release 5.0.0 Mar 21, 2025
@wazuhci wazuhci moved this from Triage to Backlog in XDR+SIEM/Release 5.0.0 Mar 21, 2025
@wazuhci wazuhci moved this from Backlog to In progress in XDR+SIEM/Release 5.0.0 Apr 10, 2025
@jr0me
Copy link
Member

jr0me commented Apr 11, 2025

Update

At the moment, I’m focused on analyzing the wm_sca_do_scan function to understand how the SCA module evaluates and processes individual checks. This includes examining how it handles different rule types (file, command, process, etc.), manages variable substitution, selects the appropriate regex engine, and applies aggregation strategies (ALL, ANY, NONE). I’m also looking into how results are collected, how events are built and sent, and how the function interacts with the cis_db_for_hash structure to prevent duplicate alerts.

@jr0me
Copy link
Member

jr0me commented Apr 14, 2025

Update

Started implementing an abstraction for the policy classes that will carry the execution logic.

@jr0me
Copy link
Member

jr0me commented Apr 15, 2025

Update

I continue to design and implement the rule evaluation classes.

@jr0me
Copy link
Member

jr0me commented Apr 22, 2025

Update

Refactored the current code, implemented parsing functions to separate rule types from pattern, negation marks, sorting variables and replacing them.

@jr0me jr0me linked a pull request Apr 23, 2025 that will close this issue
7 tasks
@jr0me
Copy link
Member

jr0me commented Apr 23, 2025

Update

Opened draft PR with most rule evaluators drafted #753

@jr0me
Copy link
Member

jr0me commented Apr 24, 2025

Update

Re implemented OsUtils to get the list of running processes for the process rule evaluation.

@jr0me
Copy link
Member

jr0me commented Apr 25, 2025

Implemented missing logic in evaluators and added tests to all of them but Registry type.

@jr0me
Copy link
Member

jr0me commented Apr 28, 2025

Fixed some issues that were incorporated with the latest rebase.
Added Registry tests.
Using Utils::Exec from cmdHelper doesn't work like the 4.x implementation, and command's output leak into the console. I'm looking into Boost::process to achieve a similar behavior as the one from 4.x

@jr0me
Copy link
Member

jr0me commented Apr 29, 2025

Implemented a new Utils::Exec based on boost::process. While keeping the old implementation as PipeOpen (renamed). Looking into generating event messages with results from policy checks.

@jr0me
Copy link
Member

jr0me commented Apr 30, 2025

Corrected some comments on PR, which is now opened and ready for review.

@wazuhci wazuhci moved this from In progress to Done in XDR+SIEM/Release 5.0.0 Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Task issue module/sca Security Compliance Assessment type/enhancement Enhancement issue
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants