-
Notifications
You must be signed in to change notification settings - Fork 13
/
example_without_api_token.py
75 lines (64 loc) · 1.8 KB
/
example_without_api_token.py
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
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python
"""
Example script
"""
from __future__ import print_function
import os
import sys
from pysigsci import sigsciapi
from pysigsci.sigsciapi import parse_time_delta
if "SIGSCI_EMAIL" in os.environ:
EMAIL = os.environ['SIGSCI_EMAIL']
else:
print('SIGSCI_EMAIL required.')
sys.exit()
if "SIGSCI_PASSWORD" in os.environ:
PASSWORD = os.environ['SIGSCI_PASSWORD']
else:
print('SIGSCI_PASSWORD required.')
sys.exit()
def main():
"""
Example main function
"""
# create sigsci api object
sigsci = sigsciapi.SigSciApi()
if "SIGSCI_CORP" in os.environ:
sigsci.corp = os.environ['SIGSCI_CORP']
else:
print('SIGSCI_CORP required.')
sys.exit()
if "SIGSCI_SITE" in os.environ:
sigsci.site = os.environ['SIGSCI_SITE']
else:
print('SIGSCI_SITE required.')
sys.exit()
if sigsci.auth(EMAIL, PASSWORD):
print(sigsci.bearer_token)
# List corps
print(sigsci.get_corps())
# Get corp by name
print(sigsci.get_corp())
# Update corp by name
data = {"displayName": "My Display Name"}
print(sigsci.update_corp(data))
# List corp users
print(sigsci.get_corp_users())
# List custom alerts
print(sigsci.get_custom_alerts())
# List events
print(sigsci.get_events())
# List requests
sigsci.site = "mysite"
params = {"q": "from:-1d tag:XSS"}
print(sigsci.get_requests(parameters=params))
# Get request feed
sigsci.site = "mysite"
params = {
"from": parse_time_delta("-1d"),
"until": parse_time_delta("-5m"),
"tags": "xss"
}
print(sigsci.get_request_feed(parameters=params))
if __name__ == '__main__':
main()