-
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-17529] Palo alto Cortex XDR Task #2754
Conversation
7242f11
to
ce4945c
Compare
825cab8
to
1ef0954
Compare
6179bb7
to
cd46e39
Compare
43e6241
to
6c22f28
Compare
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_incident_events/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_incident_events/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/util/api.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/util/api.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/tasks/monitor_alerts/task.py
Outdated
Show resolved
Hide resolved
e43cf70
to
1549cdd
Compare
35a2c1d
to
c63d7dc
Compare
f305af1
to
4e6aeb6
Compare
b20459b
to
d95e3c5
Compare
Looks good, @ablakley-r7 comments around plugin exceptions may need to be addressed before merging Validator is also failing on connection_version, is that expected? |
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/connection/connection.py
Outdated
Show resolved
Hide resolved
Yeah we need to raise a ticket around this, since the validator is looking for |
url = f"{fqdn}{endpoint}" | ||
|
||
request = requests.Request(method="post", url=url, headers=headers, json=post_body) | ||
response = make_request(_request=request, timeout=60, exception_data_location=ResponseExceptionData.RESPONSE) |
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.
We should make a ticket to update the error handling to include the custom plugin exceptions for each status code.
plugins/palo_alto_cortex_xdr/icon_palo_alto_cortex_xdr/connection/connection.py
Outdated
Show resolved
Hide resolved
* Logging to find credential headers * test * Fix logging * Spec file refresh * start parse custom config * Successful API Call * Update checksum * Get Alerts * API Call & Custom Config * Some updates * Change limit to 7500 * Return total count * Get timestamp if max limit * Custom testing for pagination * Rough Draft for pagination & switching out get_alerts_two with a better method * Tidy up * Convert alert_time to right format * Convert alert_time to right format * Convert alert_time to right format * Filters * Organise methods & start making request in task.py * Making api call in task.py * Checkpoint * Add headers retrievla in task * It's working * Loads of logging and notes * Ryan checkpoint * Ryan fibannoci murphy * More logging * Setting states * Pagination * Unit test framework * More unit test progress * Task Connection Test * Black . * Some changes and unit testing * Removing a few logger lines/ print statements * Removing monitor_incident_event task * More refactoring * Filter's added + Working * custom config and sort by working * Exception handling improved, still needs minor tweaks * Unit tests * Add url back * Remove lots of comments in task | fix unit test * Some abtracting | refactoring * help.md/plugin.spec updated with SDK bump and examples added. Working through comments * Exception handling working. removed unused constants/lines * changing connection_version, CHECKSUM and reverting changed methods in apy.py to original (change not needed) * Refactoring & making datetime/epoch conversions cleaner and easier * Fix connection SCA * Pagination progress * trying to debug pagination error * Fix SCA in action, refactor request to be in api.py * Remove unused imports * Improve comments * Debugging * Conversion custom_config bug fix * Pagination issue resolved * Drop pagination state * Add len * has_more_pages flag set to false after finished paginating * Tidy a bit * ;-; * Now to fix up the state * Strip Empty Spaces when Inputting API Keys * Tidyed state management * Rename search state variables * Remove testing items and update comments * Fix sca * CHECKSUM FIX * Unit Test Test / Possible workaround? * Unit Test * Change import path for a unit test * Version change and unit test * unit test fixing in progress * strip removed for int * Rename state variables, remove total count from state * Fix pagination again * Woops remove print statement * Comment out unit test * Remove last hash alert from drop state * Change version back to 4.1.0, make connection version 4 * Improving state * Some comments addressed * Remove some repeated logging, add another safety check in api.py * Remove all new unit tests for task * Rename vars, improve logging * Fix pagination again * Streamline datetimes, improve logging * Change version back to 4.0.0 * Fix the spec file * Fixed Task Connection test (updated to new method and params) * Tidy datetime more * Done * Remove authenitcation error in api.py, change post body logging to debug * Datetime fixed * Simplfy task connection test, remove some things in error handling * Fix SCA * Remove logger in connection --------- Co-authored-by: rjmurray <[email protected]>
* Logging to find credential headers * test * Fix logging * Spec file refresh * start parse custom config * Successful API Call * Update checksum * Get Alerts * API Call & Custom Config * Some updates * Change limit to 7500 * Return total count * Get timestamp if max limit * Custom testing for pagination * Rough Draft for pagination & switching out get_alerts_two with a better method * Tidy up * Convert alert_time to right format * Convert alert_time to right format * Convert alert_time to right format * Filters * Organise methods & start making request in task.py * Making api call in task.py * Checkpoint * Add headers retrievla in task * It's working * Loads of logging and notes * Ryan checkpoint * Ryan fibannoci murphy * More logging * Setting states * Pagination * Unit test framework * More unit test progress * Task Connection Test * Black . * Some changes and unit testing * Removing a few logger lines/ print statements * Removing monitor_incident_event task * More refactoring * Filter's added + Working * custom config and sort by working * Exception handling improved, still needs minor tweaks * Unit tests * Add url back * Remove lots of comments in task | fix unit test * Some abtracting | refactoring * help.md/plugin.spec updated with SDK bump and examples added. Working through comments * Exception handling working. removed unused constants/lines * changing connection_version, CHECKSUM and reverting changed methods in apy.py to original (change not needed) * Refactoring & making datetime/epoch conversions cleaner and easier * Fix connection SCA * Pagination progress * trying to debug pagination error * Fix SCA in action, refactor request to be in api.py * Remove unused imports * Improve comments * Debugging * Conversion custom_config bug fix * Pagination issue resolved * Drop pagination state * Add len * has_more_pages flag set to false after finished paginating * Tidy a bit * ;-; * Now to fix up the state * Strip Empty Spaces when Inputting API Keys * Tidyed state management * Rename search state variables * Remove testing items and update comments * Fix sca * CHECKSUM FIX * Unit Test Test / Possible workaround? * Unit Test * Change import path for a unit test * Version change and unit test * unit test fixing in progress * strip removed for int * Rename state variables, remove total count from state * Fix pagination again * Woops remove print statement * Comment out unit test * Remove last hash alert from drop state * Change version back to 4.1.0, make connection version 4 * Improving state * Some comments addressed * Remove some repeated logging, add another safety check in api.py * Remove all new unit tests for task * Rename vars, improve logging * Fix pagination again * Streamline datetimes, improve logging * Change version back to 4.0.0 * Fix the spec file * Fixed Task Connection test (updated to new method and params) * Tidy datetime more * Done * Remove authenitcation error in api.py, change post body logging to debug * Datetime fixed * Simplfy task connection test, remove some things in error handling * Fix SCA * Remove logger in connection --------- Co-authored-by: rjmurray <[email protected]>
* Palo Alto Cortex - Get Alerts: Fixed issue where trigger was failing due to empty or wrong typed output fields (#2535) * [SOAR-17528] Palo alto Plugin Refresh (#2740) * SDK Bump * Reverting Version * Updating help.md * [SOAR-17529] Palo alto Cortex XDR Task (#2754) * Logging to find credential headers * test * Fix logging * Spec file refresh * start parse custom config * Successful API Call * Update checksum * Get Alerts * API Call & Custom Config * Some updates * Change limit to 7500 * Return total count * Get timestamp if max limit * Custom testing for pagination * Rough Draft for pagination & switching out get_alerts_two with a better method * Tidy up * Convert alert_time to right format * Convert alert_time to right format * Convert alert_time to right format * Filters * Organise methods & start making request in task.py * Making api call in task.py * Checkpoint * Add headers retrievla in task * It's working * Loads of logging and notes * Ryan checkpoint * Ryan fibannoci murphy * More logging * Setting states * Pagination * Unit test framework * More unit test progress * Task Connection Test * Black . * Some changes and unit testing * Removing a few logger lines/ print statements * Removing monitor_incident_event task * More refactoring * Filter's added + Working * custom config and sort by working * Exception handling improved, still needs minor tweaks * Unit tests * Add url back * Remove lots of comments in task | fix unit test * Some abtracting | refactoring * help.md/plugin.spec updated with SDK bump and examples added. Working through comments * Exception handling working. removed unused constants/lines * changing connection_version, CHECKSUM and reverting changed methods in apy.py to original (change not needed) * Refactoring & making datetime/epoch conversions cleaner and easier * Fix connection SCA * Pagination progress * trying to debug pagination error * Fix SCA in action, refactor request to be in api.py * Remove unused imports * Improve comments * Debugging * Conversion custom_config bug fix * Pagination issue resolved * Drop pagination state * Add len * has_more_pages flag set to false after finished paginating * Tidy a bit * ;-; * Now to fix up the state * Strip Empty Spaces when Inputting API Keys * Tidyed state management * Rename search state variables * Remove testing items and update comments * Fix sca * CHECKSUM FIX * Unit Test Test / Possible workaround? * Unit Test * Change import path for a unit test * Version change and unit test * unit test fixing in progress * strip removed for int * Rename state variables, remove total count from state * Fix pagination again * Woops remove print statement * Comment out unit test * Remove last hash alert from drop state * Change version back to 4.1.0, make connection version 4 * Improving state * Some comments addressed * Remove some repeated logging, add another safety check in api.py * Remove all new unit tests for task * Rename vars, improve logging * Fix pagination again * Streamline datetimes, improve logging * Change version back to 4.0.0 * Fix the spec file * Fixed Task Connection test (updated to new method and params) * Tidy datetime more * Done * Remove authenitcation error in api.py, change post body logging to debug * Datetime fixed * Simplfy task connection test, remove some things in error handling * Fix SCA * Remove logger in connection --------- Co-authored-by: rjmurray <[email protected]> * Update cloud enabled (#2809) * Reset offsets when changing lookback (#2811) * Reset offsets when changing lookback * Reset query endtime back to now * Make it store the int not the datetime object * Pop last search to * Add default none incase of key error * Update pop * Palo Alto | Update error to return error.data (#2823) * Update error to return error.data * Remove print statements * Wrap it in a plugin exception * Palo Alto Cortex XDR - 17008 - Get Alerts: Fixed issue with triggers output validation (#2824) * Rename response to new response * Take headers away from initialisation (#2827) * Palo Alto | Fix start time moving bug, Refactor dedupe logic (#2833) * Add logging for final page, Ensure start & end time are fixed when paginating * Add now time into get alerts * End time and start time static again * Refactor dedupe logic * Remove custom config * Update SDK * Update checksum for task schema --------- Co-authored-by: igorski-r7 <[email protected]> Co-authored-by: rmurray-r7 <[email protected]>
Proposed Changes
Description
Task implementation for the
monitor_alerts
task. The task connection test and unit tests (started) has also been added and testing outputs have been provided below.Describe the proposed changes:
monitor_alerts
PluginValidator
is failingThe validator is failing because the
connection_version
is bumping from 2 -> 4 and the validator checks for +1 increments. We can ignore this in the context of this plugin and raise a ticket to fix this in the validatorsTesting
Task
Called the Task locally and it pulls the first 100 logs successfully whilst also returning
has_more_pages
as true.Task Connection Test
I tested by hitting the endpoint locally via Postman requests to ensure the correct exceptions show when inserting invalid data, and that when hitting the endpoint successfully the correct message shows.
Successful test:
![image](https://private-user-images.githubusercontent.com/171815685/366106590-c2169817-8660-4e9b-9d01-6888f60a8000.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6Imt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