This repository has been archived by the owner on Aug 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
folders.py
85 lines (72 loc) · 1.82 KB
/
folders.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
76
77
78
79
80
81
82
83
84
85
from tenable_io.api.models import Folder
from tenable_io.client import TenableIOClient
from tenable_io.exceptions import TenableIOApiException
def example():
scan_name = u'my test scan'
folder_name = u'my test folder'
'''
Instantiate an instance of the TenableIOClient.
'''
client = TenableIOClient()
'''
Create a folder.
'''
folder = client.folder_helper.create(
name=folder_name
)
assert folder.name() == folder_name
'''
Create a scan for testing.
'''
scan = client.scan_helper.create(
name=scan_name,
text_targets='tenable.com',
template='discovery'
)
'''
Move scan to the newly created folder (method A).
'''
assert scan.folder().id != folder.id
scan.move_to(folder)
assert scan.folder().id == folder.id
'''
Move scan to trash (method A).
'''
scan.trash()
assert scan.folder().id != folder.id
'''
Move scan to the newly created folder (method B).
'''
folder.add(scan)
assert scan.folder().id == folder.id
'''
Move scan to trash (method B).
'''
trash_folder = client.folder_helper.trash_folder()
trash_folder.add(scan)
assert scan.folder().id == trash_folder.id
'''
Move scan to the main folder "My Scans".
'''
main_folder = client.folder_helper.main_folder()
main_folder.add(scan)
assert scan.folder().type() == Folder.TYPE_MAIN
'''
Stop all scans in folder.
'''
folder.add(scan)
scan.launch()
assert not scan.stopped()
folder.stop_scans()
assert scan.stopped()
'''
Delete folder and scan.
'''
folder.delete()
scan.delete()
assert client.folder_helper.id(folder.id) is None
try:
scan.details()
assert False
except TenableIOApiException:
pass