-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
forms.py
142 lines (132 loc) · 4.66 KB
/
forms.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
from django import forms
from scanEngine.models import EngineType, Configuration
from django_ace import AceWidget
from reNgine.validators import validate_short_name
class AddEngineForm(forms.ModelForm):
class Meta:
model = EngineType
fields = '__all__'
engine_name = forms.CharField(
required=True,
widget=forms.TextInput(
attrs={
"class": "form-control",
"id": "scan_engine_name",
"placeholder": "Custom Engine"}))
subdomain_discovery = forms.BooleanField(
required=False,
widget=forms.CheckboxInput(attrs={"checked": ""}))
dir_file_search = forms.BooleanField(
required=False,
widget=forms.CheckboxInput(attrs={}))
port_scan = forms.BooleanField(
required=False,
widget=forms.CheckboxInput(attrs={"checked": ""}))
fetch_url = forms.BooleanField(
required=False,
widget=forms.CheckboxInput(attrs={"checked": ""}))
vulnerability_scan = forms.BooleanField(
required=False,
widget=forms.CheckboxInput(attrs={"checked": ""}))
yaml_configuration = forms.CharField(widget=AceWidget(
mode="yaml",
theme="monokai",
width="100%",
height="450px",
tabsize=4,
fontsize=13,
toolbar=True,))
class UpdateEngineForm(forms.ModelForm):
class Meta:
model = EngineType
fields = '__all__'
engine_name = forms.CharField(
required=True,
widget=forms.TextInput(
attrs={
"class": "form-control",
"id": "scan_engine_name",
"placeholder": "Custom Engine"}))
subdomain_discovery = forms.BooleanField(
required=False,
widget=forms.CheckboxInput())
dir_file_search = forms.BooleanField(
required=False,
widget=forms.CheckboxInput())
port_scan = forms.BooleanField(
required=False,
widget=forms.CheckboxInput())
fetch_url = forms.BooleanField(
required=False,
widget=forms.CheckboxInput())
vulnerability_scan = forms.BooleanField(
required=False,
widget=forms.CheckboxInput())
yaml_configuration = forms.CharField(widget=AceWidget(
mode="yaml",
theme="monokai",
width="100%",
height="450px",
tabsize=4,
fontsize=13,
toolbar=True,))
def set_value(self, engine):
self.initial['engine_name'] = engine.engine_name
self.initial['subdomain_discovery'] = engine.subdomain_discovery
self.initial['dir_file_search'] = engine.dir_file_search
self.initial['port_scan'] = engine.port_scan
self.initial['fetch_url'] = engine.fetch_url
self.initial['yaml_configuration'] = engine.yaml_configuration
self.initial['vulnerability_scan'] = engine.vulnerability_scan
class AddWordlistForm(forms.Form):
name = forms.CharField(
required=True,
widget=forms.TextInput(
attrs={'class': 'form-control',
'id': 'name',
'placeholder': 'my awesome wordlist', }))
short_name = forms.CharField(
required=True,
validators=[validate_short_name],
widget=forms.TextInput(
attrs={
'class': 'form-control',
'id': 'short_name',
'placeholder': 'my_awesome_wordlist', }))
upload_file = forms.FileField(
required=True,
widget=forms.FileInput(
attrs={'class': 'custom-file-input',
'id': 'txtFile',
'multiple': '',
'accept': '.txt', }))
class ConfigurationForm(forms.ModelForm):
class Meta:
model = Configuration
fields = '__all__'
name = forms.CharField(
required=True,
widget=forms.TextInput(
attrs={'class': 'form-control',
'id': 'name',
'placeholder': 'Configuration Name', }))
short_name = forms.CharField(
required=True,
validators=[validate_short_name],
widget=forms.TextInput(
attrs={
'class': 'form-control',
'id': 'short_name',
'placeholder': 'my_awesome_configuration', }))
content = forms.CharField(widget=AceWidget(
mode="text",
theme="monokai",
width="100%",
height="450px",
tabsize=4,
fontsize=13,
toolbar=True,))
def set_value(self, configuration):
self.initial['name'] = configuration.name
self.initial['short_name'] = configuration.short_name
self.initial['content'] = configuration.content