-
Notifications
You must be signed in to change notification settings - Fork 22
feat(modules/ngsiem): add LogScale/CQL query execution for NG-SIEM #204
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
Open
paulnblacklock
wants to merge
4
commits into
CrowdStrike:main
Choose a base branch
from
paulnblacklock:ngsiem-query-execution
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6b16ca0
feat(modules/ngsiem): add LogScale/CQL query execution for NG-SIEM
paulnblacklock cbf8efc
feat(common): add NGSIEM API scope requirements
paulnblacklock 4c49101
refactor(modules/ngsiem): remove wrapper methods to align with module…
paulnblacklock a4d7b20
Merge branch 'CrowdStrike:main' into ngsiem-query-execution
paulnblacklock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,7 @@ def _format_error_response( | |
| Returns: | ||
| Dict[str, Any]: Formatted error response | ||
| """ | ||
| response = {"error": message} | ||
| response: Dict[str, Any] = {"error": message} | ||
|
|
||
| # Add details if provided | ||
| if details: | ||
|
|
@@ -116,6 +116,16 @@ def handle_api_response( | |
| """ | ||
| status_code = response.get("status_code") | ||
|
|
||
| # If no status_code is present, assume success (200) for responses with data | ||
| # This handles cases like NGSIEM query results that don't include status_code | ||
| if status_code is None: | ||
| # Check if response contains actual data (successful response) | ||
| if any(key in response for key in ["results", "search_id", "body", "resources"]): | ||
| status_code = 200 | ||
| else: | ||
| # Empty response without status_code - treat as error | ||
| status_code = 500 | ||
|
|
||
| if status_code != 200: | ||
| # Get a more descriptive error message based on status code | ||
| status_message = ERROR_CODE_DESCRIPTIONS.get( | ||
|
|
@@ -135,10 +145,15 @@ def handle_api_response( | |
| f"{error_message}: {status_message}", details=response, operation=operation | ||
| ) | ||
|
|
||
| # Extract resources from the response body | ||
| # Handle NGSIEM query responses - they have different structure than standard API responses | ||
| if ("search_id" in response and "results" in response) or (operation and "NG-SIEM Query" in operation): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could instead write a special API response handler for NG-SIEM operations or accept an optional lambda function to extract its contents. I'd incline for a NG-SIEM specific handler so that we also can cover any caveat on the error handling as well. |
||
| return response | ||
|
|
||
| # Extract resources from the response body for standard API responses | ||
| resources = response.get("body", {}).get("resources", []) | ||
|
|
||
| if not resources and default_result is not None: | ||
| return default_result | ||
|
|
||
| # For standard API responses, return resources list/dict as expected | ||
| return resources | ||
Oops, something went wrong.
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.
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.
Though I'm not fully familiar with the NG-SIEM API, this looks odd. Any HTTP response should contain a status line as per the RFC. In which cases have you noticed that this is
none?