audit url open for permitted schemes. allowing use of file / or custom schemes is often unexpected

340 Views Asked by At

I am using the below code in python for sending request

def get(self, url):
 response = None
 try:
    ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_1 | ssl.PROTOCOL_TLSv1_2)
    if url.lower().startswith('https'):
        response = ur.urlopen(url, context=ctx)
        return response.read()
    else:
        raise ValueError from None
 except Exception as ex:
    print(str(ex))

I am getting error when performing code quality test using bandit enter image description here

0

There are 0 best solutions below