Fix RulesProperties::appendRules() #1901
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After a discussion on #1888 I noticed
RulesProperties::appendRules()
was not checking for duplicate IDs as well as throwing an error if there weresecMarkers
in more than one file (when calling any combination ofrules->load()
,rules->loadFromUri()
orrules->loadRemote()
more than once). To fix thesecMarker
issue, the if statement on rules_properties.h:441 just needed to be negated.This function also doesn't accurately check for duplicate IDs. The check can be circumvented by putting the rule in a different phase. To fix this, the ruleId list (
v
in this function) has to be populated completely before checking it against the other list.Before the patch is applied the example below will fail to load rules due to multiple files containing
secMarkers
test01.conf
test02.conf
test03.conf
After removing the
SecMarkers
from test02 and test03 the test will pass.And if you force a duplicate
ruleId
by changing the Id in test03 to 1, the test will still pass.After the patch all of these issues are dealt with in the correct manner.
The test will pass with the original conf files above and will fail if you change the ID in test03 to 1.