mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Python: Tests for new query: requests called with verify=False.
This commit is contained in:
32
python/ql/test/query-tests/Security/CWE-295/make_request.py
Normal file
32
python/ql/test/query-tests/Security/CWE-295/make_request.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import requests
|
||||
|
||||
#Simple cases
|
||||
requests.get('https://semmle.com', verify=True) # GOOD
|
||||
requests.get('https://semmle.com', verify=False) # BAD
|
||||
requests.post('https://semmle.com', verify=True) # GOOD
|
||||
requests.post('https://semmle.com', verify=False) # BAD
|
||||
|
||||
# Simple flow
|
||||
put = requests.put
|
||||
put('https://semmle.com', verify="/path/to/cert/") # GOOD
|
||||
put('https://semmle.com', verify=False) # BAD
|
||||
|
||||
#Other flow
|
||||
delete = requests.delete
|
||||
|
||||
def req1(verify=False):
|
||||
delete('https://semmle.com', verify) # BAD
|
||||
if verify:
|
||||
delete('https://semmle.com', verify) # GOOD
|
||||
if not verify:
|
||||
return
|
||||
delete('https://semmle.com', verify) # GOOD
|
||||
|
||||
patch = requests.patch
|
||||
|
||||
def req2(verify):
|
||||
patch('https://semmle.com', verify=verify) # BAD (from line 30)
|
||||
|
||||
req2(False) # BAD (at line 28)
|
||||
req2("/path/to/cert/") # GOOD
|
||||
|
||||
21
python/ql/test/query-tests/Security/lib/requests.py
Normal file
21
python/ql/test/query-tests/Security/lib/requests.py
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
def get(url, params=None, **kwargs):
|
||||
pass
|
||||
|
||||
def options(url, **kwargs):
|
||||
pass
|
||||
|
||||
def head(url, **kwargs):
|
||||
pass
|
||||
|
||||
def post(url, data=None, json=None, **kwargs):
|
||||
pass
|
||||
|
||||
def put(url, data=None, **kwargs):
|
||||
pass
|
||||
|
||||
def patch(url, data=None, **kwargs):
|
||||
pass
|
||||
|
||||
def delete(url, **kwargs):
|
||||
pass
|
||||
Reference in New Issue
Block a user