-
Notifications
You must be signed in to change notification settings - Fork 339
Fix MSSentinelSearch environment name and connection check in AzureSearchDriver #871
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, a few more changes would probably help IMO.
Feel free to correct me if you feel otherwise!
ianhelle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes caused a bit of test upheaval but all good calls!
- Add connected property override in AzureSearchDriver, AzureMonitorDriver, and PrismaCloudDriver to validate both connection flag and client/header presence - Remove redundant query() method override from AzureSearchDriver (now uses parent implementation with proper connection checking) - Update DriverBase._ensure_connected() to check self.connected property instead of self._connected to enable child class customization - Simplify _ensure_connected() calls across all drivers (remove provider name parameter) - Use string literals for query filter data_environments instead of enum .name (fixes enum alias issues) - Update tests to match stricter connection checking requirements These changes ensure robust connection state validation across all drivers and prevent queries from running with incomplete connection state. Related to PR #871
FlorianBracq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks great!
- Change SubscriptionClient import from azure.mgmt.resource.subscriptions
to azure.mgmt.subscription (removed in azure-mgmt-resource v25)
- Use SubscriptionClient directly instead of generic client() call to
satisfy mypy type narrowing in _check_client and _legacy_auth
- Change Items.sku and Items.identity types to Any to match SDK types
- Add api_versions None guard in _get_api
- Use split('@', maxsplit=1) in query_source.py (ruff PLC0207)
- Remove stale azure.mgmt.resource.subscriptions mock from docs conf.py
- Update expected error messages from 'not connected to Splunk/OpenObserve' to 'not connected to SplunkDriver/OpenObserveDriver' to match the _ensure_connected implementation using class names
- Replace _create_not_connected_err('Splunk') calls with _ensure_connected()
in splunk_driver.py for consistency with other drivers
- Update test assertions to match _ensure_connected class name format
('not connected to SplunkDriver/OpenObserveDriver')
…github.com/microsoft/msticpy into copilot/fix-azure-search-driver-connection
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.