Repository navigation
Conversation
CSIntelAPI.search_indicator called r.get("body").get("errors") on a
200 response. When the Falcon API returns a payload without a "body"
key this raises AttributeError on None, and when "body" is present but
carries no "errors" key len(None) raises TypeError -- both masking the
real response instead of returning it.
Resolve the errors list defensively before testing it, and reuse it in
the raised message instead of re-walking the response.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012VxctWivKrfQWn8tVD8qkT
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
BLUF —
crowdstrike_falconcrashed on 200 responses missingbodyorerrorsinstead of returning the payload.CSIntelAPI.search_indicator()incrowdstrike_falcon.pyvalidated a 200 response withlen(r.get("body").get("errors")), which raisesAttributeErrorifbodyis absent andTypeErroriferrorsis, even though the very next line already tolerates a missing body.(r.get("body") or {}).get("errors") or []and reuses it when raising, with regression tests added.Problem
CSIntelAPI.search_indicator()inmisp_modules/modules/expansion/crowdstrike_falcon.py(line 245 before this change) validated a successful response with:That assumes every HTTP 200 payload from the Falcon Intel API contains a
bodydict which in turn contains anerrorskey. Neither is guaranteed:bodykey — e.g.{"status_code": 200}— makesr.get("body")returnNone, so.get("errors")raisesAttributeError: 'NoneType' object has no attribute 'get'.errorskey — e.g.{"status_code": 200, "body": {"resources": []}}— makeslen(None)raiseTypeError: object of type 'NoneType' has no len().In both cases the module fails with an unrelated traceback instead of returning the response the caller asked for, which masks the actual API result. The success path on the next line already tolerates a missing body (
return r.get("body", {})), so the guard is stricter than the code immediately following it.Fix
Resolve the error list defensively before testing it, and reuse it when raising:
This keeps the existing behaviour whenever the API does report errors (same exception type and message format), and otherwise falls through to the existing
return r.get("body", {})— matching the tolerance that success path already has. It also avoids walking the response dict twice to build the message.Testing
poetry run pytest(the same invocation CI uses) — result: 107 passed, 5 subtests passed in 79.28s (0:01:19).tests/test_crowdstrike_falcon.py:test_search_indicator_without_body— 200 response with nobodykey returns{}instead of raisingAttributeError.test_search_indicator_without_errors_key— 200 response with a body but noerrorskey returns the body instead of raisingTypeError.test_search_indicator_raises_on_api_errors— a populatederrorslist still raises with the joined message, so the existing behaviour is preserved.No live Falcon credentials are needed; the tests patch the
Intelclient.🤖 Generated with Claude Code