-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
26 lines (18 loc) · 808 Bytes
/
run.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
import tenableApi
exportID = tenableApi.assetExport()
assets = tenableApi.getAssets(exportID,1)
agent_groups = tenableApi.listAgentGroups()
print('[*] Looking for asset groups...')
for agentGroup in agent_groups:
#Get all information about the AG
agentGroupDetails = tenableApi.getAgentGroupDetail(agentGroup)
# Get assets ids based on agent group
targets = tenableApi.getTargetAssets(agentGroup,assets)
if targets:
agentGroupName = agentGroupDetails['name']
#Identify the tag name based on the Asset group Name
tag = tenableApi.getTagId(agentGroupName)
if tag:
#Tag assets
print('[*] Applying tags for agent group: {}, Agents: {}'.format(agentGroupName,len(targets)))
tenableApi.tagAssets(tag,targets)