Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Check empty user object for the AD monitor #304

Merged
merged 1 commit into from
Nov 25, 2020

Conversation

kaituo
Copy link
Member

@kaituo kaituo commented Nov 25, 2020

Issue #, if available:

Description of changes:
When security is disabled, the user in the alerting config index is empty (not null). This caused AD monitor to add a backend role filter when querying anomaly results. Since backend roles don't exist when security is disabled, AD monitor gets empty hits and always returns false during trigger evaluation. The issue basically disables AD monitor for non-fgac domain.

This PR fixes the issue by checking the emptiness of a user: if its name is empty, don't add the backend role filter while querying.

Testing done:

  1. added a unit test to verify the backend role filter is not generated when a user is empty.
  2. Manually verified AD monitors can find anomalies after the fix.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

When security is disabled, the user in the alerting config index is empty (not null).  This caused AD monitor to add a backend role filter when querying anomaly results.  Since backend roles don't exist when security is disabled, AD monitor gets empty hits and always returns false during trigger evaluation.  The issue basically disables AD monitor for non-fgac domain.

This PR fixes the issue by checking the emptiness of a user: if its name is empty, don't add the backend role filter while querying.

Testing done:
1. added a unit test to verify the backend role filter is not generated when a user is empty.
2. Manually verified AD monitors can find anomalies after the fix.
@codecov
Copy link

codecov bot commented Nov 25, 2020

Codecov Report

Merging #304 (13241c6) into master (b704bb8) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #304   +/-   ##
=========================================
  Coverage     80.34%   80.34%           
  Complexity      196      196           
=========================================
  Files           151      151           
  Lines          5169     5169           
  Branches        674      674           
=========================================
  Hits           4153     4153           
- Misses          658      659    +1     
+ Partials        358      357    -1     
Impacted Files Coverage Δ Complexity Δ
...asticsearch/alerting/util/AnomalyDetectionUtils.kt 100.00% <100.00%> (ø) 0.00 <0.00> (ø)
...ing/destination/client/DestinationEmailClient.java 72.50% <0.00%> (-5.00%) 7.00% <0.00%> (-1.00%)
...distroforelasticsearch/alerting/util/IndexUtils.kt 71.42% <0.00%> (-2.39%) 0.00% <0.00%> (ø%)
...endistroforelasticsearch/alerting/MonitorRunner.kt 78.00% <0.00%> (-0.41%) 0.00% <0.00%> (ø%)
...ing/model/destination/DestinationContextFactory.kt 66.66% <0.00%> (ø) 0.00% <0.00%> (ø%)
...distroforelasticsearch/alerting/core/JobSweeper.kt 72.19% <0.00%> (+2.13%) 35.00% <0.00%> (+1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b704bb8...804022a. Read the comment docs.

@kaituo kaituo merged commit f124fa2 into opendistro-for-elasticsearch:master Nov 25, 2020
tlfeng pushed a commit that referenced this pull request Feb 6, 2021
When security is disabled, the user in the alerting config index is empty (not null).  This caused AD monitor to add a backend role filter when querying anomaly results.  Since backend roles don't exist when security is disabled, AD monitor gets empty hits and always returns false during trigger evaluation.  The issue basically disables AD monitor for non-fgac domain.

This PR fixes the issue by checking the emptiness of a user: if its name is empty, don't add the backend role filter while querying.

Testing done:
1. added a unit test to verify the backend role filter is not generated when a user is empty.
2. Manually verified AD monitors can find anomalies after the fix.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants