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

Allow reuse ID and improve search algorithm finding available ID key #1594

Merged
merged 1 commit into from
Dec 15, 2018

Conversation

nhatking16591
Copy link
Contributor

@nhatking16591 nhatking16591 commented Dec 12, 2018

Problem:

  • Currently ossec doesn't support reuse ID for client key .
    • Even-though if i try to remove completely client key manually( remove from client.keys), current algorithm still can not found correct available ID as it work correctly only incase of IDs have an ordering.
    • This problem makes the number of ID keeps increase and when ID = MAX_AGENTS + AUTHD_FIRST_ID we can't register a new agent and have to rebuild ossec with higher MAXAGENTS.
  • Take so much time for searching an available ID
    Ossec use "Dichotomic search", we have to loop into all client.keys file each times check for ID exist (O (nlogn).

Solution:

  • Support reuse ID
  • Create BitMap to store every ID already allocated, and we only need to loop in entire of client key in 2 times. So this solution have complexity O(n) instead of O(nlogn) as previous version.

Test:
Already did a patch for ossec-hids 3.0.0 and did testing in my system everything working ok.

@atomicturtle atomicturtle merged commit 8302afc into ossec:master Dec 15, 2018
@atomicturtle
Copy link
Member

Excellent work on this, I know its going to help a lot of folks out. Let me know if you'd like an invite to the OSSEC slack channel: [email protected] . Its a fantastic place to collaborate with other developers

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.

2 participants