rspec/rules/S4825/python/rule.adoc
2021-02-02 16:54:43 +01:00

82 lines
1.6 KiB
Plaintext

include::../description.adoc[]
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
``++httplib++`` module
----
import http.client.HTTPConnection
def send_request(url):
http.client.HTTPConnection(url) # Sensitive
----
``++request++`` library
----
import requests
def send_request(url, method):
requests.request(method, url) # Sensitive
requests.get(url) # Sensitive
requests.put(url) # Sensitive
requests.post(url) # Sensitive
requests.patch(url) # Sensitive
requests.delete(url) # Sensitive
requests.head(url) # Sensitive
requests.options(url) # Sensitive
----
Python 2 ``++urllib2++``
----
import urllib2
url = 'http://www.example.com/'
def open_url(url):
urllib2.urlopen(url) # Sensitive
req = urllib2.Request(url=url,
data=b'This is data')
urllib2.urlopen(req) # Sensitive
opener = urllib2.build_opener(urllib2.HTTPHandler)
opener.open(url) # Sensitive
----
Python 3 ``++urllib++`` module
----
import urllib.request
url = 'http://www.example.com/'
def open_url(url, proxy_handler, proxy_auth_handler, proxies):
urllib.request.urlopen(url) # Sensitive
req = urllib.request.Request(url=url,
data=b'This is data')
urllib.request.urlopen(req) # Sensitive
opener = urllib.request.build_opener(proxy_handler, proxy_auth_handler)
opener.open(url) # Sensitive
opener = urllib.request.FancyURLopener(proxies)
opener.open(url) # Sensitive
urllib.request.urlretrieve(url) # Sensitive
----
include::../see.adoc[]