Skip to content

Commit 438ad73

Browse files
committed
avoid names shadowing
1 parent eda9a3d commit 438ad73

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

lib/utils/api.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from lib.core.log import LOGGER_HANDLER
3333
from lib.core.optiondict import optDict
3434
from lib.core.subprocessng import Popen
35-
from thirdparty.bottle.bottle import error
35+
from thirdparty.bottle.bottle import error as return_error
3636
from thirdparty.bottle.bottle import get
3737
from thirdparty.bottle.bottle import hook
3838
from thirdparty.bottle.bottle import post
@@ -182,6 +182,7 @@ def engine_get_returncode(self):
182182
def engine_has_terminated(self):
183183
return isinstance(self.engine_get_returncode(), int)
184184

185+
185186
# Wrapper functions for sqlmap engine
186187
class StdDbOut(object):
187188
def __init__(self, taskid, messagetype="stdout"):
@@ -289,25 +290,26 @@ def security_headers(json_header=True):
289290
# HTTP Status Code functions #
290291
##############################
291292

292-
@error(401) # Access Denied
293+
294+
@return_error(401) # Access Denied
293295
def error401(error=None):
294296
security_headers(False)
295297
return "Access denied"
296298

297299

298-
@error(404) # Not Found
300+
@return_error(404) # Not Found
299301
def error404(error=None):
300302
security_headers(False)
301303
return "Nothing here"
302304

303305

304-
@error(405) # Method Not Allowed (e.g. when requesting a POST method via GET)
306+
@return_error(405) # Method Not Allowed (e.g. when requesting a POST method via GET)
305307
def error405(error=None):
306308
security_headers(False)
307309
return "Method not allowed"
308310

309311

310-
@error(500) # Internal Server Error
312+
@return_error(500) # Internal Server Error
311313
def error500(error=None):
312314
security_headers(False)
313315
return "Internal server error"
@@ -316,6 +318,7 @@ def error500(error=None):
316318
# Task management functions #
317319
#############################
318320

321+
319322
# Users' methods
320323
@get("/task/new")
321324
def task_new():
@@ -347,15 +350,16 @@ def task_delete(taskid):
347350
# Admin functions #
348351
###################
349352

353+
350354
@get("/admin/<taskid>/list")
351355
def task_list(taskid):
352356
"""
353357
List task pull
354358
"""
355359
if is_admin(taskid):
356360
logger.debug("Listed task pull")
357-
task_list = list(DataStore.tasks)
358-
return jsonize({"success": True, "tasks": task_list, "tasks_num": len(task_list)})
361+
tasks = list(DataStore.tasks)
362+
return jsonize({"success": True, "tasks": tasks, "tasks_num": len(tasks)})
359363
else:
360364
return jsonize({"success": False, "message": "Unauthorized"})
361365

@@ -379,6 +383,7 @@ def task_flush(taskid):
379383
# sqlmap core interact functions #
380384
##################################
381385

386+
382387
# Handle task's options
383388
@get("/option/<taskid>/list")
384389
def option_list(taskid):
@@ -420,6 +425,7 @@ def option_set(taskid):
420425

421426
return jsonize({"success": True})
422427

428+
423429
# Handle scans
424430
@post("/scan/<taskid>/start")
425431
def scan_start(taskid):
@@ -516,6 +522,7 @@ def scan_data(taskid):
516522
logger.debug("Retrieved data and error messages for scan for task ID %s" % taskid)
517523
return jsonize({"success": True, "data": json_data_message, "error": json_errors_message})
518524

525+
519526
# Functions to handle scans' logs
520527
@get("/scan/<taskid>/log/<start>/<end>")
521528
def scan_log_limited(taskid, start, end):
@@ -562,6 +569,7 @@ def scan_log(taskid):
562569
logger.debug("Retrieved log messages for scan for task ID %s" % taskid)
563570
return jsonize({"success": True, "log": json_log_messages})
564571

572+
565573
# Function to handle files inside the output directory
566574
@get("/download/<taskid>/<target>/<filename:path>")
567575
def download(taskid, target, filename):

0 commit comments

Comments
 (0)