Fix MSSentinelSearch environment name and connection check in AzureSearchDriver#871
Fix MSSentinelSearch environment name and connection check in AzureSearchDriver#871
Conversation
…d override query method Co-authored-by: ianhelle <13070017+ianhelle@users.noreply.github.com>
…ation Co-authored-by: ianhelle <13070017+ianhelle@users.noreply.github.com>
Co-authored-by: ianhelle <13070017+ianhelle@users.noreply.github.com>
Co-authored-by: ianhelle <13070017+ianhelle@users.noreply.github.com>
- Add drop_duplicates(subset=['query']) before merge in get_whois_df to prevent row multiplication from duplicate whois results - Change net_df fixture scope from module to function for test isolation with random sampling - Add autouse fixture to clear LRU caches (get_whois_info, _whois_lookup) between tests to prevent state leakage
|
Thx for the review @FlorianBracq - |
FlorianBracq
left a comment
There was a problem hiding this comment.
Sorry, a few more changes would probably help IMO.
Feel free to correct me if you feel otherwise!
| the underlying provider result if an error. | ||
|
|
||
| """ | ||
| if not self._connected or self._query_client is None: |
There was a problem hiding this comment.
I thought we would overload _ensure_connected (or the property connected) in this class (and AzureSearch) to ensure both conditions (self._connected being True and self._query_client/auth_header not being None) are validated?
| title="Workspace not connected.", | ||
| help_uri=_HELP_URL, | ||
| ) | ||
| self._ensure_connected("Azure Monitor") |
There was a problem hiding this comment.
I would remove the hardcoded parameter as this would impact inheritance. Instead, we maybe want to add a new class variable that would contain the "display name" of the driver and use this?
| self._connected = True | ||
| logger.info("Created HTTP-based query client using /search endpoint.") | ||
|
|
||
| def query( |
There was a problem hiding this comment.
Isn't this the same implementation as in the parent class?
| If the driver is not connected. | ||
|
|
||
| """ | ||
| if not self._connected: |
There was a problem hiding this comment.
I read again the code for DriverBase, and I'm wondering why we are using _connected and not the property connected here?
It would be easier to overload (and probably to understand) the definition of the property connected in child class
| ) | ||
| # Check if authentication token is present | ||
|
|
||
| if "X-Redlock-Auth" not in self.client.headers: |
There was a problem hiding this comment.
this should probably move in the definition of property connected for this driver?
| self.set_driver_property( | ||
| DriverProps.EFFECTIVE_ENV, DataEnvironment.MSSentinelSearch.name | ||
| ) | ||
| # Override query filter to include MSSentinelSearch |
AzureSearchDriverinheritedEFFECTIVE_ENV="MSSentinel"from its parentAzureMonitorDriver, causing the QueryProvider to report the wrong environment name. Additionally, the inheritedquery()method checked for_query_client(used by parent) instead of_auth_header(used by this driver), causing "Workspace not connected" errors even after successful connection.Changes
__init__: SetEFFECTIVE_ENVto"MSSentinelSearch"after parent initialization"MSSentinelSearch"in supported environments tuple_ensure_connected()helper to check_auth_header is not None_ensure_connected()instead of parent's_query_clientcheckExample
Original prompt
This section details on the original issue you should resolve
<issue_title>[Bug]: New experimenal MSSentinelSearch data provider doesn't correctly use the AzureSearchDriver</issue_title>
<issue_description>Describe the bug
The
MSSentinelSearchquery provider / data environment seems to get confused between using the MSSentinel vs MSSentinelSearch data environments and fails to correctly connect the AzureSearchDriver.To Reproduce
Steps to reproduce the behavior:
Ianhelle/az monitor search driver 2025 02 05 #825 included in main.
Expected behavior
AzureSearchDriver is connected and used with the corresponding MSSentinelSearch data environment.
Screenshots and/or Traceback
Environment (please complete the following information):
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.