forked from certmichelin/PTART
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader_owasp_testing_guide.py
32 lines (28 loc) · 1.2 KB
/
loader_owasp_testing_guide.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
import json
import os
import django
#
# OWASP testing guide v4 Methodology loader.
#
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ptart.settings")
django.setup()
from ptart.models import Methodology, Module, Case
current_methodology = Methodology.objects.filter(name="OWASP Testing Guide V4")
if not current_methodology :
methodology = Methodology(name="OWASP Testing Guide V4")
methodology.save()
owasp_file = open('data/owasp_testing_guide_v4.json', 'r')
methodology_json = json.load(owasp_file)
for method in methodology_json['modules']:
module = Module(name=method, methodology=methodology)
module.save()
for case in methodology_json['modules'][method]['tests']:
steps = methodology_json['modules'][method]['tests'][case]['steps']
steps_consolidated = ""
for step in steps:
steps_consolidated = steps_consolidated + step + '\n\n'
case = Case(name=case, description=steps_consolidated, module=module)
case.save()
print("OWASP Testing Guide V4 methodology has been imported !")
else :
print("OWASP Testing Guide V4 methodology was already present in PTART!. No changes has been made.")