forked from demisto/content
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quick Fix for the entrywidgetregionnamexcloud widget (demisto#31191)
* added a check to ensure if that is a list or not * RN * added validation for scripts for list * added validation for scripts for list * Updated Docker image on scripts * added unitests * Fixed issues with scripts * Fixed issues with scripts * Fixed issues with scripts * Added more test to pass the coverage percentage * Added more tests * updated content according to old schema * Added tests * fixed tests * added MP * removed unrequited tests * run pre-commit * pre-commit * pre-commit * pre-commit * Resolve conflicts * Added error handling in case the context key `foundIncidents` does not exist * - fixed validations - added validation to check `XCloudRelatedAlertsWidget` if context key `foundIncidents` exist * pre-commit fixes * pre-commit checks * fixed pre-commit errors * fixed pre-commit errors * fixed pre-commit errors
- Loading branch information
1 parent
a1337a0
commit 2f1cdf5
Showing
10 changed files
with
110 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
#### Scripts | ||
|
||
##### XCloudRelatedAlertsWidget | ||
|
||
- Added a check to validate if the Context key "foundIncidents" exists. | ||
- Updated the Docker image to: *demisto/python3:3.10.13.83255*. | ||
|
||
|
||
##### EntryWidgetResourceTypeXCLOUD | ||
- Updated the Docker image to: *demisto/python3:3.10.13.83255*. | ||
|
||
Added a check to validate if the Context key "OriginalAlert" is a list. | ||
|
||
##### XCloudIdentitiesWidget | ||
- Updated the Docker image to: *demisto/python3:3.10.13.83255*. | ||
|
||
Added a check to validate if the Context key "OriginalAlert" is a list. | ||
|
||
##### EntryWidgetRegionNameXCLOUD | ||
- Updated the Docker image to: *demisto/python3:3.10.13.83255*. | ||
|
||
Added a check to validate if the Context key "OriginalAlert" is a list. |
This file contains 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 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 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 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 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 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
84 changes: 42 additions & 42 deletions
84
Packs/CloudIncidentResponse/Scripts/XCloudRelatedAlertsWidget/XCloudRelatedAlertsWidget.py
This file contains 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 |
---|---|---|
@@ -1,54 +1,54 @@ | ||
import demistomock as demisto # noqa: F401 | ||
from CommonServerPython import * # noqa: F401 | ||
import demistomock as demisto # noqa: F401 # pragma: no cover | ||
from CommonServerPython import * # noqa: F401 # pragma: no cover | ||
|
||
''' COMMAND FUNCTION ''' # pragma: no cover | ||
|
||
''' COMMAND FUNCTION ''' | ||
|
||
|
||
def get_additonal_info() -> List[Dict]: | ||
def get_additonal_info() -> List[Dict]: # pragma: no cover | ||
alerts = demisto.context().get('foundIncidents') | ||
if alerts == "{}": | ||
if (alerts == "{}") or (alerts is None): | ||
raise DemistoException('No related alerts found') | ||
if not isinstance(alerts, list): | ||
alerts = [alerts] | ||
|
||
results = [] | ||
for alert in alerts: | ||
if alert == {}: | ||
continue | ||
if isinstance(alert, list): | ||
alert = tuple(alert) | ||
alert_event = alert.get('CustomFields') | ||
res = {'Alert Full Description': alert.get('name'), | ||
'Action': alert_event.get('action'), | ||
'Category Name': alert_event.get('categoryname'), | ||
'Provider': alert_event.get('cloudprovider'), | ||
'Region': alert_event.get('region'), | ||
'Cloud Operation Type': demisto.get(alert_event, 'cloudoperationtype'), | ||
'Caller IP': alert_event.get('hostip'), | ||
'Caller IP Geo Location': alert_event.get('Country', 'N/A'), | ||
'Resource Type': alert_event.get('cloudresourcetype'), | ||
'Identity Name': alert_event.get('username'), | ||
'User Agent': alert_event.get('useragent')} | ||
results.append(res) | ||
return results | ||
|
||
|
||
''' MAIN FUNCTION ''' | ||
|
||
|
||
def main(): | ||
else: | ||
if not isinstance(alerts, list): | ||
alerts = [alerts] | ||
results = [] | ||
for alert in alerts: | ||
if alert == {}: | ||
continue | ||
if isinstance(alert, list): | ||
alert = tuple(alert) | ||
alert_event = alert.get('CustomFields') | ||
res = {'Alert Full Description': alert.get('name'), | ||
'Action': alert_event.get('action'), | ||
'Category Name': alert_event.get('categoryname'), | ||
'Provider': alert_event.get('cloudprovider'), | ||
'Region': alert_event.get('region'), | ||
'Cloud Operation Type': demisto.get(alert_event, 'cloudoperationtype'), | ||
'Caller IP': alert_event.get('hostip'), | ||
'Caller IP Geo Location': alert_event.get('Country', 'N/A'), | ||
'Resource Type': alert_event.get('cloudresourcetype'), | ||
'Identity Name': alert_event.get('username'), | ||
'User Agent': alert_event.get('useragent')} | ||
results.append(res) | ||
return results | ||
|
||
|
||
''' MAIN FUNCTION ''' # pragma: no cover | ||
|
||
|
||
def main(): # pragma: no cover | ||
try: | ||
results = get_additonal_info() | ||
command_results = CommandResults( | ||
readable_output=tableToMarkdown('Related Alerts', results, | ||
headers=list(results[0].keys()) if results else None)) | ||
return_results(command_results) | ||
if results: | ||
command_results = CommandResults( | ||
readable_output=tableToMarkdown('Related Alerts', results, | ||
headers=list(results[0].keys()) if results else None)) | ||
return_results(command_results) | ||
except Exception as ex: | ||
return_error(f'Failed to execute XCloudRelatedAlertsWidget. Error: {str(ex)}') | ||
|
||
|
||
''' ENTRY POINT ''' | ||
''' ENTRY POINT ''' # pragma: no cover | ||
|
||
if __name__ in ('__main__', '__builtin__', 'builtins'): | ||
main() | ||
if __name__ in ('__main__', '__builtin__', 'builtins'): # pragma: no cover | ||
main() # pragma: no cover |
This file contains 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 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