-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathdojo_tools.py
67 lines (52 loc) · 2 KB
/
dojo_tools.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
"""
Example written by Aaron Weaver <[email protected]>
as part of the OWASP DefectDojo and OWASP AppSec Pipeline Security projects
Description: Creates a product in DefectDojo and returns information about the newly created product
"""
from defectdojo_api import defectdojo
import os
# Setup DefectDojo connection information
host = 'http://localhost:8000'
api_key = os.environ['DOJO_API_KEY']
user = 'admin1'
#Optionally, specify a proxy
proxies = {
'http': 'http://localhost:8080',
'https': 'http://localhost:8080',
}
#proxies=proxies
# Instantiate the DefectDojo api wrapper
dd = defectdojo.DefectDojoAPI(host, api_key, user, proxies=proxies, debug=False)
# List Tool Types
tool_types = dd.list_tool_types()
#print "Configured Tool Types"
#print tool_types.data_json(pretty=True)
list_credential_mappings = dd.list_credential_mappings(product_id_in=2)
print "Creds"
#print list_credential_mappings.data_json(pretty=True)
for cred in list_credential_mappings.data["objects"]:
print cred["id"]
print cred["credential"]
get_credential = dd.get_credential(dd.get_id_from_url(cred["credential"]))
print get_credential.data["selenium_script"]
if get_credential.data["selenium_script"] != "None":
file = open("testfile.py","w")
file.write(get_credential.data["selenium_script"])
file.close()
print get_credential.data_json(pretty=True)
"""
list_containers = dd.list_containers()
print "Containers"
print list_containers.data_json(pretty=True)
# Search Tool Types by Name
tool_types = dd.list_tool_types(name="Source Code Repository")
print "Source Code Repository Tool Types"
print tool_types.data["objects"][0]['id']
print tool_types.data_json(pretty=True)
print "Configured Source Code Repository Tools"
tool = dd.list_tools(tool_type_id=tool_types.data["objects"][0]['id'])
print tool.data_json(pretty=True)
print "Products Configured to use source code repos"
tool = dd.list_tool_products(tool_configuration_id=tool.data["objects"][0]['id'])
print tool.data_json(pretty=True)
"""