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 agent metadata to latest changes requested #290

Merged
merged 5 commits into from
Nov 13, 2024

Conversation

TomasTurina
Copy link
Member

@TomasTurina TomasTurina commented Nov 12, 2024

Related issue
#256

Description

This PR includes the following changes/improvements:

  • Add the name to the agent metadata.
  • Report the ip as an array in the agent metadata.
  • Return agent metadata as a string to avoid conversions.
  • Fix the function getNextNAwaitable to return multiple messages.
  • Fix metadata cache.

Tests

  • Compilation without warnings in every supported platform
    • Linux
    • Windows
    • MAC OS X

Examples

  • Registration:
[2024-11-13 14:56:40] POST /security/user/authenticate
Headers:
Host: localhost
User-Agent: WazuhXDR/5.0.0 (Endpoint; aarch64; Linux)
Accept: application/json
Authorization: Basic d2F6dWg6d2F6dWg=


Body:



[2024-11-13 14:56:40] POST /agents
Headers:
Host: localhost
User-Agent: WazuhXDR/5.0.0 (Endpoint; aarch64; Linux)
Accept: application/json
Authorization: Bearer 1234567890
Content-Type: application/json
Content-Length: 277


Body:
{"agent":{"groups":[],"host":{"architecture":"aarch64","hostname":"tomas","ip":["192.168.64.15"],"os":{"name":"Ubuntu","platform":"Linux"}},"id":"632c61c2-5df5-45f2-bf45-b5d968f4cea3","key":"LeAuQ3QsnaefDrULb0SXB2Q8OHHP9rv8","name":"tomas","type":"Endpoint","version":"5.0.0"}}
  • Stateless:
[2024-11-13 14:57:42] POST /api/v1/authentication
Headers:
Host: localhost
User-Agent: WazuhXDR/5.0.0 (Endpoint; aarch64; Linux)
Accept: application/json
Content-Type: application/json
Content-Length: 89


Body:
{"uuid":"632c61c2-5df5-45f2-bf45-b5d968f4cea3", "key":"LeAuQ3QsnaefDrULb0SXB2Q8OHHP9rv8"}


[2024-11-13 14:58:04] POST /api/v1/events/stateless
Headers:
Host: localhost
User-Agent: WazuhXDR/5.0.0 (Endpoint; aarch64; Linux)
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ3YXp1aCIsImF1ZCI6IldhenVoIENvbW11bmljYXRpb25zIEFQSSIsImlhdCI6MTczMTUwOTg2MiwiZXhwIjoxNzMxNTA5OTIyLCJ1dWlkIjoiZWRhYjllZjYtZjAyZC00YTRiLWJhYTQtZjJhZDEyNzg5ODkwIn0.Zm21lvSUIcaTzZmbTZv7VVKDCtkm3m6Mp7HBuL7A1ek
Content-Type: application/json
Content-Length: 451


Body:
{"agent":{"groups":[],"host":{"architecture":"aarch64","hostname":"tomas","ip":["192.168.64.15"],"os":{"name":"Ubuntu","platform":"Linux"}},"id":"632c61c2-5df5-45f2-bf45-b5d968f4cea3","name":"tomas","type":"Endpoint","version":"5.0.0"}}
{"module":"logcollector","type":"file"}
{"event":{"ingested":"2024-11-13T14:58:04.446Z","module":"logcollector","original":"alksjdaslkd","provider":"syslog"},"log":{"file":{"path":"/test/test.log"}},"tags":["mvp"]}

Copy link
Member

@Nicogp Nicogp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@cborla cborla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jr0me jr0me force-pushed the fix/256-add-name-to-register branch 3 times, most recently from 4485ce8 to 3ab8b5c Compare November 13, 2024 12:38
Due to recent changes in the agent's info implementation,
where the sql logic was replaced with the SQLiteManager,
a bug was introduced in the ResetToDefaults method by which
the AgentInfo tables were not being cleaned up.
@jr0me jr0me force-pushed the fix/256-add-name-to-register branch from 3ab8b5c to e8a87b2 Compare November 13, 2024 12:45
@TomasTurina TomasTurina merged commit 679e456 into master Nov 13, 2024
5 checks passed
@TomasTurina TomasTurina deleted the fix/256-add-name-to-register branch November 13, 2024 15:47
Copy link
Member

@jr0me jr0me left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants