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

Rule field validation during IndexRule Action #80

Merged
merged 18 commits into from
Nov 3, 2022

Conversation

petardz
Copy link
Contributor

@petardz petardz commented Oct 26, 2022

Description

Added new API ValidateRules which, for a given indexName and list of ruleIds, will return list of non-applicable ruleIds to given index

Issues Resolved

#90

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
@petardz petardz requested a review from a team October 26, 2022 18:03
@petardz petardz changed the title Customrule field validation Rule field validation during IndexRule Action Oct 26, 2022
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Oct 29, 2022

Codecov Report

Merging #80 (4f9a85e) into main (e477a09) will decrease coverage by 0.24%.
The diff coverage is 0.00%.

@@             Coverage Diff              @@
##               main      #80      +/-   ##
============================================
- Coverage     43.20%   42.95%   -0.25%     
- Complexity      858      859       +1     
============================================
  Files           167      167              
  Lines          5826     5862      +36     
  Branches        734      736       +2     
============================================
+ Hits           2517     2518       +1     
- Misses         3076     3112      +36     
+ Partials        233      232       -1     
Impacted Files Coverage Δ
...ensearch/securityanalytics/mapper/MapperUtils.java 60.93% <0.00%> (-8.71%) ⬇️
...g/opensearch/securityanalytics/model/Detector.java 71.27% <ø> (+0.36%) ⬆️
...a/org/opensearch/securityanalytics/model/Rule.java 0.00% <ø> (ø)
...yanalytics/transport/TransportIndexRuleAction.java 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Rule ruleDoc = new Rule(NO_ID, NO_VERSION, parsedRule, category, queries.stream().map(Object::toString).collect(Collectors.toList()), rule);
indexRule(ruleDoc);
//verify rule
verifyRule(backend.getQueryFields().keySet(), DetectorMonitorConfig.getRuleIndex(category), new ActionListener<>() {
Copy link
Member

Choose a reason for hiding this comment

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

What if the custom rule is created using the fields not part of the rule alias mapping, but using some additional fields from the Source Index. That still is a valid use case.
Should we revisit the approach, where the fields in rule could also be present in the source index mapping?

@getsaurabh02
Copy link
Member

Hi @petardz are we on it with the plan as we discussed ?

Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
getsaurabh02
getsaurabh02 previously approved these changes Nov 2, 2022
@getsaurabh02 getsaurabh02 dismissed their stale review November 2, 2022 03:54

Build/Test failures

Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
@sbcd90 sbcd90 merged commit bfb2b23 into opensearch-project:main Nov 3, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Nov 3, 2022
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
(cherry picked from commit bfb2b23)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Nov 3, 2022
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
(cherry picked from commit bfb2b23)
eirsep pushed a commit that referenced this pull request Nov 3, 2022
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
(cherry picked from commit bfb2b23)

Co-authored-by: Petar Dzepina <petar.dzepina@gmail.com>
eirsep pushed a commit that referenced this pull request Nov 3, 2022
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
(cherry picked from commit bfb2b23)

Co-authored-by: Petar Dzepina <petar.dzepina@gmail.com>
phaseshiftg pushed a commit to phaseshiftg/security-analytics that referenced this pull request Nov 5, 2022
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants