@@ -25,10 +25,10 @@ def authenticate(username, password)
25
25
payload = {
26
26
:username => username ,
27
27
:password => password ,
28
- :json => 1 ,
28
+ :json => 1
29
29
}
30
- resp = http_post ( :uri => ' /session' , :data => payload )
31
- @token = "token=#{ resp [ 'token' ] } "
30
+ res = http_post ( :uri => " /session" , :data => payload )
31
+ @token = "token=#{ res [ 'token' ] } "
32
32
true
33
33
end
34
34
@@ -47,7 +47,7 @@ def authenticated
47
47
end
48
48
49
49
def get_server_properties
50
- http_get ( :uri => ' /server/properties' , :fields => x_cookie )
50
+ http_get ( :uri => " /server/properties" , :fields => x_cookie )
51
51
end
52
52
53
53
def user_add ( username , password , permissions , type )
@@ -56,9 +56,9 @@ def user_add(username, password, permissions, type)
56
56
:password => password ,
57
57
:permissions => permissions ,
58
58
:type => type ,
59
- :json => 1 ,
59
+ :json => 1
60
60
}
61
- http_post ( :uri => ' /users' , :fields => x_cookie , :data => payload )
61
+ http_post ( :uri => " /users" , :fields => x_cookie , :data => payload )
62
62
end
63
63
64
64
def user_delete ( user_id )
@@ -69,47 +69,51 @@ def user_delete(user_id)
69
69
def user_chpasswd ( user_id , password )
70
70
payload = {
71
71
:password => password ,
72
- :json => 1 ,
72
+ :json => 1
73
73
}
74
74
res = http_put ( :uri => "/users/#{ user_id } /chpasswd" , :data => payload , :fields => x_cookie )
75
75
return res . code
76
76
end
77
77
78
78
def user_logout
79
- res = http_delete ( :uri => ' /session' , :fields => x_cookie )
79
+ res = http_delete ( :uri => " /session" , :fields => x_cookie )
80
80
return res . code
81
81
end
82
82
83
83
def list_policies
84
- http_get ( :uri => ' /policies' , :fields => x_cookie )
84
+ http_get ( :uri => " /policies" , :fields => x_cookie )
85
85
end
86
86
87
87
def list_users
88
- http_get ( :uri => ' /users' , :fields => x_cookie )
88
+ http_get ( :uri => " /users" , :fields => x_cookie )
89
89
end
90
90
91
91
def list_folders
92
- http_get ( :uri => ' /folders' , :fields => x_cookie )
92
+ http_get ( :uri => " /folders" , :fields => x_cookie )
93
93
end
94
94
95
95
def list_scanners
96
- http_get ( :uri => ' /scanners' , :fields => x_cookie )
96
+ http_get ( :uri => " /scanners" , :fields => x_cookie )
97
97
end
98
98
99
99
def list_families
100
- http_get ( :uri => ' /plugins/families' , :fields => x_cookie )
100
+ http_get ( :uri => " /plugins/families" , :fields => x_cookie )
101
101
end
102
102
103
103
def list_plugins ( family_id )
104
104
http_get ( :uri => "/plugins/families/#{ family_id } " , :fields => x_cookie )
105
105
end
106
106
107
+ def list_template ( type )
108
+ res = http_get ( :uri => "/editor/#{ type } /templates" , :fields => x_cookie )
109
+ end
110
+
107
111
def plugin_details ( plugin_id )
108
112
http_get ( :uri => "/plugins/plugin/#{ plugin_id } " , :fields => x_cookie )
109
113
end
110
114
111
115
def is_admin
112
- res = http_get ( :uri => ' /session' , :fields => x_cookie )
116
+ res = http_get ( :uri => " /session" , :fields => x_cookie )
113
117
if res [ 'permissions' ] == 128
114
118
return true
115
119
else
@@ -118,7 +122,7 @@ def is_admin
118
122
end
119
123
120
124
def server_properties
121
- http_get ( :uri => ' /server/properties' , :fields => x_cookie )
125
+ http_get ( :uri => " /server/properties" , :fields => x_cookie )
122
126
end
123
127
124
128
def scan_create ( uuid , name , description , targets )
@@ -131,27 +135,27 @@ def scan_create(uuid, name, description, targets)
131
135
} ,
132
136
:json => 1
133
137
} . to_json
134
- http_post ( :uri => ' /scans' , :body => payload , :fields => x_cookie , :ctype => 'application/json' )
138
+ http_post ( :uri => " /scans" , :body => payload , :fields => x_cookie , :ctype => 'application/json' )
135
139
end
136
140
137
141
def scan_launch ( scan_id )
138
142
http_post ( :uri => "/scans/#{ scan_id } /launch" , :fields => x_cookie )
139
143
end
140
144
141
145
def server_status
142
- http_get ( :uri => ' /server/status' , :fields => x_cookie )
146
+ http_get ( :uri => " /server/status" , :fields => x_cookie )
143
147
end
144
148
145
149
def scan_list
146
- http_get ( :uri => ' /scans' , :fields => x_cookie )
150
+ http_get ( :uri => " /scans" , :fields => x_cookie )
147
151
end
148
152
149
153
def scan_details ( scan_id )
150
154
http_get ( :uri => "/scans/#{ scan_id } " , :fields => x_cookie )
151
155
end
152
156
153
157
def scan_pause ( scan_id )
154
- http_get ( :uri => "/scans/#{ scan_id } /pause" , :fields => x_cookie )
158
+ http_post ( :uri => "/scans/#{ scan_id } /pause" , :fields => x_cookie )
155
159
end
156
160
157
161
def scan_resume ( scan_id )
@@ -172,12 +176,12 @@ def scan_export(scan_id, format)
172
176
def scan_export_status ( scan_id , file_id )
173
177
request = Net ::HTTP ::Get . new ( "/scans/#{ scan_id } /export/#{ file_id } /status" )
174
178
request . add_field ( "X-Cookie" , @token )
175
- resp = @connection . request ( request )
176
- if resp . code == "200"
179
+ res = @connection . request ( request )
180
+ if res . code == "200"
177
181
return "ready"
178
182
else
179
- resp = JSON . parse ( resp . body )
180
- return resp
183
+ res = JSON . parse ( resp . body )
184
+ return res
181
185
end
182
186
end
183
187
@@ -186,35 +190,23 @@ def policy_delete(policy_id)
186
190
return res . code
187
191
end
188
192
189
- def report_list_hash
190
- raise NotImplementedError
191
- end
192
-
193
- def scan_list_hash
194
- raise NotImplementedError
195
- end
196
-
197
- def report_host_ports
198
- raise NotImplementedError
193
+ def host_detail ( scan_id , host_id )
194
+ res = http_get ( :uri => "/scans/#{ scan_id } /hosts/#{ host_id } " , :fields => x_cookie )
199
195
end
200
196
201
- def scan_new
197
+ def report_list
202
198
raise NotImplementedError
203
199
end
204
200
205
- def report_file_download
201
+ def report_del
206
202
raise NotImplementedError
207
203
end
208
204
209
- def template_list_hash
210
- raise NotImplementedError
211
- end
212
-
213
- def report_host
205
+ def report_host_ports
214
206
raise NotImplementedError
215
207
end
216
208
217
- def report_host_port_details
209
+ def report_download
218
210
raise NotImplementedError
219
211
end
220
212
0 commit comments