-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGPlistDisconnectUsers.yml
64 lines (58 loc) · 1.93 KB
/
GPlistDisconnectUsers.yml
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
commonfields:
id: acc4a6fd-d2d5-4b1b-82d2-df63abf30633
version: 95
name: GPlistDisconnectUsers
script: |+
def search(context, path, value):
'''
searches a value in a context path.
@param context - context tree to search in
@param path - a path to search in the context
@value - value to search
'''
if isinstance(context, dict):
if len(path) > 0 and path[0] in context:
return search(context[path[0]], path[1:], value)
else:
return False
elif isinstance(context, list):
# in case current context has multiple objects, search them all.
return any([search(c, path, value) for c in context])
else:
# if we got to a leaf in the context
return len(path) == 0 and context == value
path = demisto.args().get(u'path', u'')
value = demisto.args().get(u'host')
ipadd = demisto.args().get("ipadd")
domain = demisto.args().get("domain")
retval = search(demisto.context(), path.split('.'), value)
# If users from previous users is not found in current users then delete if DNS has record
if not retval:
# !infoblox-get-refid domain=defense.local host=JUMPBOX-1 ipadd=172.16.2.201
raw = demisto.executeCommand('infoblox-get-refid', {'host': value.lower(), 'domain': domain.lower(), 'ipadd': ipadd, 'status': 'USED', 'deletes': 'yes' });
demisto.results(raw)
type: python
tags:
- Utility
comment: Search Global Protect users in context. Compare previous connected users
to current connected users and build delete list in context to remove DNS entries
enabled: true
args:
- name: path
description: Path in the context
- name: host
required: true
default: true
description: Hostname
- name: ipadd
required: true
description: IPv4 Address
- name: domain
required: true
description: Domain Name
scripttarget: 0
subtype: python2
timeout: 180ns
pswd: ""
runonce: false
runas: DBotWeakRole