-
Notifications
You must be signed in to change notification settings - Fork 55
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
[SOAR-18543] Palo Alto Cortex XDR #3040
base: develop
Are you sure you want to change the base?
Conversation
82083d8
to
6c7ef56
Compare
plugins/palo_alto_cortex_xdr/unit_test/expected/monitor_alerts_full_page_state.json.exp
Show resolved
Hide resolved
dafd15d
to
d275283
Compare
…hange how custom config is named in line with other plugins | Update SDK | Update error handling to return response data in data field
d275283
to
a26e0fa
Compare
@@ -502,20 +511,24 @@ def build_request(self, url: str, headers: dict, post_body: dict) -> Response: | |||
request = requests.Request(method="post", url=url, headers=headers, json=post_body) | |||
|
|||
custom_config_exceptions = { | |||
HTTPStatusCodes.BAD_REQUEST: PluginException(cause="API Error. ", assistance="Bad request, invalid JSON."), | |||
HTTPStatusCodes.BAD_REQUEST: PluginException( | |||
cause=PluginException.causes.get(PluginException.Preset.BAD_REQUEST), |
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.
for readability I think this does the same thing by just passing the preset and the exception class gets the cause?( but could be remembering wrong)
HTTPStatusCodes.BAD_REQUEST: PluginException(preset=PluginException.Preset.BAD_REQUEST, assistance="Bad request, invalid JSON.")
data=error.data.text, | ||
status_code=error.data.status_code, | ||
) | ||
raise error |
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.
this looks like it'll skip _handle_401 which looks like we tend run into an issue with keys expiring and a refresh gets us up and running again? Although not sure if this code is ever hit as it looks like they expire after 15 minutes
if not start_time: | ||
start_time = self.convert_datetime_to_unix(now_date_time - timedelta(hours=DEFAULT_LOOKBACK_HOURS)) | ||
end_time = now_unix |
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.
is this not already handled in get_query_time
, and we always return a start_time so we never hit this bit of code?
self.logger.info("Adjusting start time to cutoff value") | ||
start_time = max_lookback_unix | ||
# Reset search_from and search_to if this is not a backfill | ||
if not custom_config: |
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.
if we've passed an alert limit into the custom config this could break this logic? is it better to use the lookback type key we've used in other cases?
""" | ||
old_hashes = state.get(LAST_ALERT_HASH, []) | ||
deduped_alerts = 0 | ||
new_alerts = [] | ||
new_hashes = [] | ||
highest_timestamp = state.get(LAST_ALERT_TIME, 0) | ||
highest_timestamp = 0 | ||
|
||
# Create a new hash for every new alert | ||
for _, alert in enumerate(alerts): |
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.
I know this was already existing,do we need to use enumerate here?
Proposed Changes
Description
Describe the proposed changes:
PR Requirements
Developers, verify you have completed the following items by checking them off:
Testing
Unit Tests
Review our documentation on generating and writing plugin unit tests
In-Product Tests
If you are an InsightConnect customer or have access to an InsightConnect instance, the following in-product tests should be done:
Style
Review the style guide
USER nobody
in theDockerfile
when possiblerapid7/insightconnect-python-3-38-slim-plugin:{sdk-version-num}
andrapid7/insightconnect-python-3-38-plugin:{sdk-version-num}
insight-plugin validate
which callsicon_validate
to linthelp.md
Functional Checklist
tests/
directory created withinsight-plugin samples
tests/$action_bad.json
insight-plugin run -T tests/example.json --debug --jq
insight-plugin run -T all --debug --jq
(use PR format at end)insight-plugin run -R tests/example.json --debug --jq
insight-plugin run --debug --jq
(use PR format at end)Assessment
You must validate your work to reviewers:
insight-plugin validate
and make sure everything passesinsight-plugin run -A
. For single action validation:insight-plugin run tests/{file}.json -A
insight-plugin ... | pbcopy
) and paste the output in a new post on this PR