Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
De widget#4
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
Uh oh!
There was an error while loading. Please reload this page.
De widget #4
Changes from all commits
10983c17000efb4affd1bf54c3b64aa37913d50bd0515e438c7dca90d38b5e9b84049f6f7ebc575288384af651bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ## [Unreleased] | ||
| - |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import demistomock as demisto | ||
| from CommonServerPython import * | ||
| def main(): | ||
| res = {"total": 0} | ||
| res_data = [] | ||
| top = demisto.args().get("top") or 10 | ||
| try: | ||
| employees = demisto.executeCommand("code42-departingemployee-get-all", {})[0]["Contents"] | ||
| res["total"] = len(employees) | ||
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. If we are ignoring certain employees later, should we not set 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. Depending on what the count represents, if it represents all employees irrespective of whether they have alerts or not then this is ok. | ||
| # Get each employee on the Departing Employee List and their total alerts. | ||
| for employee in employees: | ||
| username = employee["userName"] | ||
| alerts = demisto.executeCommand("code42-alert-search", {"username": username})[0]["Contents"] | ||
| alerts_count = len(alerts) | ||
| # Ignores employees without alerts | ||
| if alerts_count: | ||
| employee_res = {"Username": username, "Alerts Count": alerts_count} | ||
| res_data.append(employee_res) | ||
| # Sort such that highest alert counts are first and get top. | ||
| res["data"] = sorted(res_data, key=lambda x: x["Alerts Count"], reverse=True)[:top] | ||
| demisto.results(res) | ||
| except Exception as e: | ||
| res["total"] = -1 | ||
| res["data"] = str(e) | ||
| # Submit final results to Cortex XSOAR | ||
| demisto.results(res) | ||
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. Do we need line 27, seems redundant, | ||
| if __name__ in ("__main__", "__builtin__", "builtins"): | ||
| main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| args: | ||
| - defaultValue: 10 | ||
| description: To limit results to x number of employees with the highest alert count. | ||
| name: top | ||
| type: number | ||
| comment: Gets all departing employees and alerts for each. | ||
| commonfields: | ||
| id: 468c8e6f-6f50-486f-8cde-7dabe4cbeb2b | ||
| version: -1 | ||
| dependson: | ||
| must: | ||
| - Code42|||code42-departingemployee-get-all | ||
| - Code42|||code42-alerts-search | ||
| dockerimage: demisto/py42:1.0.0.9242 | ||
| enabled: true | ||
| name: Code42GetDepartingEmployeeAlerts | ||
| pswd: "" | ||
| runas: DBotWeakRole | ||
| runonce: false | ||
| script: '' | ||
| scripttarget: 0 | ||
| subtype: python3 | ||
| tags: ['dynamic-section', 'widget'] | ||
| type: python |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| { | ||
| "category": "", | ||
| "dataType": "scripts", | ||
| "dateRange": { | ||
| "fromDate": "0001-01-01T00:00:00Z", | ||
| "fromDateLicense": "0001-01-01T00:00:00Z", | ||
| "period": { | ||
| "by": "", | ||
| "byFrom": "days", | ||
| "byTo": "", | ||
| "field": "", | ||
| "fromValue": null, | ||
| "toValue": null | ||
| }, | ||
| "toDate": "0001-01-01T00:00:00Z" | ||
| }, | ||
| "id": "570ec235-7ee4-43ea-8fc7-eba94a0cca71", | ||
| "isPredefined": false, | ||
| "name": "Departing Employee Alerts", | ||
| "params": { | ||
| "tableColumns": [ | ||
| { | ||
| "displayed": true, | ||
| "isDefault": true, | ||
| "key": "Username" | ||
| }, | ||
| { | ||
| "displayed": true, | ||
| "isDefault": true, | ||
| "key": "Alerts Count" | ||
| } | ||
| ] | ||
| }, | ||
| "query": "Code42GetDepartingEmployeeAlerts", | ||
| "size": 0, | ||
| "sort": null, | ||
| "sortValues": null, | ||
| "version": -1, | ||
| "widgetType": "table" | ||
| } |
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.
room for list comprehension....
alert_context = [map_to_code42_alert_context(alert) for alert in alerts]