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

Fix agent mismatch in database when selecting agents with a mask #3351

Merged
merged 1 commit into from May 28, 2019

Conversation

vikman90
Copy link
Member

@vikman90 vikman90 commented May 20, 2019

Related issue
#2443

Description

The agent-info files follow this pattern:

queue/agent-info/$name-$ip

The database module splits the name of the file into two strings: the name and the IP. Then, it finds the agent in the DB using both parameters. This does not work if the agent was registered with an IP including a netmask:

  • The registered_ip field includes the netmask.
  • The file path will never include that, because the slask / is not permitted in file paths.

That prevents the module from finding the agent.

Solution

Make the BD query match either the exact IP parameter or that IP plus /_%. That means the regex /.+. This should not produce a name conflict since the name of the agent does not allow slashes (/).

Output

This fix just prevents the database module from producing debug logs.

agent_control should produce an output like this with this patch applied:

$ agent_control -l

Wazuh agent_control. List of available agents:
   ID: 000, Name: stretch64 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: centos, IP: 192.168.33.0/24, Active

Tests

  • Compilation without warnings in every supported platform
  • Source installation
  • Package installation
  • Source upgrade
  • Package upgrade
  • Review logs syntax and correct language

@vikman90 vikman90 added type/bug Something isn't working module/db Wazuh DB engine labels May 20, 2019
@vikman90 vikman90 requested a review from snaow May 20, 2019 11:36
@vikman90 vikman90 self-assigned this May 20, 2019
@vikman90 vikman90 changed the base branch from master to 3.9 May 20, 2019 13:00
@vikman90 vikman90 marked this pull request as ready for review May 20, 2019 14:07
@vikman90 vikman90 merged commit 80b0958 into 3.9 May 28, 2019
@vikman90 vikman90 deleted the 3.9-agent-db-2443 branch May 28, 2019 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/db Wazuh DB engine type/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants