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

CTI client prototype #238

Open
AlexRuiz7 opened this issue Jan 21, 2025 · 3 comments · May be fixed by #252
Open

CTI client prototype #238

AlexRuiz7 opened this issue Jan 21, 2025 · 3 comments · May be fixed by #252
Assignees
Labels
level/task Task issue type/enhancement Enhancement issue

Comments

@AlexRuiz7
Copy link
Member

AlexRuiz7 commented Jan 21, 2025

Description

The Content Manager plugin will interact with an external web service (CTI) which exposes an HTTP REST API.

For such communication to happen, we need to design and implement a prototype of a Java HTTP client that implements the CTI API interface and understands the responses.

---
title: Content Manager - HTTP clients
---
classDiagram
    HTTPclient <|-- CTIclient
    HTTPclient <|-- CommandManagerClient

    class HTTPclient{
        <<abstract>>
        +request(method, payload, callback)
    }
    class CTIclient{
        -int apiUrl
        +getConsumerInfo()
        +getContextChanges(fromOffset: int, toOffset: int)
    }
    class CommandManagerClient{
        -int apiUrl
        +postCommand()
    }
Loading

Functional requirements

The CTI client will:

  • fetch consumer information, such as its latest offset and snapshot URL.
  • fetch the list of changes in a context.

Implementation restrictions

  • The HTTP client is part of the Content Manager plugin.
  • The URL of the CTI API must be masked (secure setting).
  • Implementation of units tests.
  • Implementation of error handling.

Plan

  • HTTP client scaffolding.
  • Fetch consumer information.
  • Fetch changes in a context.
  • Register of the CTI API URL as a secure string. regular setting
@AlexRuiz7 AlexRuiz7 added level/task Task issue type/research Research issue labels Jan 21, 2025
@wazuhci wazuhci moved this to Backlog in XDR+SIEM/Release 5.0.0 Jan 21, 2025
@f-galland f-galland self-assigned this Jan 27, 2025
@wazuhci wazuhci moved this from Backlog to In progress in XDR+SIEM/Release 5.0.0 Jan 27, 2025
@f-galland
Copy link
Member

We are going to take advantage of the code from a previous iteration of the content manager from the Wazuh Server team available here:

The program uses a json object to gather its configuration, including the base URL and endpoint from the API.

The actionOrchestrator.hpp's run() method delegates handling of the request to the corresponding method:

  • runOffsetUpdate()
    • Creates and triggers a new orchestration that updates the offset in the database
  • runFileHashUpdate()
    • Performs a file hash update in the database with the specified hash. This comes in the json configuration
  • runContentUpdate()
    • Triggers a new orchestration that updates the content.
    • If an offset download is requested and the current offset is '0', a snapshot will be downloaded with the full content to avoid downloading many offsets at once.
  • runFullContentDownload()
    • Creates and triggers a new orchestration that downloads a snapshot from CTI.

@f-galland
Copy link
Member

f-galland commented Jan 27, 2025

These methods in create a FactoryContentUpdater object and pass it the configuration.

The create() method within FactoryContentUpdater:

Creates the corresponding instances for the orchestration in charge of processing certain contents based on the config values.

It achieves this by instantiating FactoryDownloader, FactoryDecompressor, PubSubPublisher, FactoryVersionUpdater and FactoryCleaner.
These are the classes where the actual logic for handling the http requests and file management happens.

@f-galland

This comment has been minimized.

@f-galland f-galland linked a pull request Jan 28, 2025 that will close this issue
@AlexRuiz7 AlexRuiz7 added type/enhancement Enhancement issue and removed type/research Research issue labels Jan 31, 2025
@wazuhci wazuhci moved this from In progress to Pending review in XDR+SIEM/Release 5.0.0 Jan 31, 2025
@wazuhci wazuhci moved this from Pending review to In progress in XDR+SIEM/Release 5.0.0 Feb 3, 2025
@wazuhci wazuhci moved this from In progress to Pending review in XDR+SIEM/Release 5.0.0 Feb 5, 2025
@wazuhci wazuhci moved this from Pending review to On hold in XDR+SIEM/Release 5.0.0 Feb 6, 2025
@wazuhci wazuhci moved this from On hold to Pending review in XDR+SIEM/Release 5.0.0 Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Task issue type/enhancement Enhancement issue
Projects
Status: Pending review
Development

Successfully merging a pull request may close this issue.

2 participants