forked from shaniacht1/content
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomation-ClassifierNotifyAdmin.yml
More file actions
46 lines (39 loc) · 1.5 KB
/
automation-ClassifierNotifyAdmin.yml
File metadata and controls
46 lines (39 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
args:
- default: true
description: 'Mail address to notify '
name: sendTo
comment: Send mail to admin, notifying that classification failed
commonfields:
id: ClassifierNotifyAdmin
version: -1
dependson:
must:
- send-mail
name: ClassifierNotifyAdmin
runonce: false
script: |-
BRAND_LABEL = 'Label/Brand'
CLASSIFIER_DESCRIPTION_LABAL = 'Label/Classifier/Description'
INCIDENT_ID_LABEL = 'Label/id'
CONTEXT_SEPARATOR = '|'
MAIL_SUBJECT = 'Demisto warning: Failed to classify incident {0}'
ctx = demisto.context()
res = []
brand = demisto.get(ctx, BRAND_LABEL) or ''
description = demisto.get(ctx, CLASSIFIER_DESCRIPTION_LABAL) or ''
incident_id = demisto.get(ctx, INCIDENT_ID_LABEL) or ''
send_to = demisto.args()['sendTo'] if demisto.get(demisto.args(), 'sendTo') else ''
markdownString = '### Classification failed:\n'
markdownString += '* Brand: {0}\n'.format(brand) if brand else '* Brand was not provided\n'
markdownString += '* Description:\n{0}'.format(''.join(['** {0}\n'.format(st) for st in description.split(CONTEXT_SEPARATOR)])) if description else '* Description was not provided\n'
res.append({'ContentsFormat': formats['markdown'], 'Type': entryTypes['note'], 'Contents': markdownString})
if send_to:
resp = demisto.executeCommand("send-mail", {"to" : send_to, "subject" : MAIL_SUBJECT.format(incident_id), "body" : markdownString})
if isError(resp[0]):
res += resp
demisto.results(res)
scripttarget: 0
system: true
tags:
- Classifier
type: python