rspec/rules/S4825/python/rule.adoc

89 lines
1.8 KiB
Plaintext
Raw Normal View History

2020-06-30 12:49:37 +02:00
include::../description.adoc[]
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
2021-01-27 13:42:22 +01:00
``++httplib++`` module
2020-06-30 12:49:37 +02:00
----
import http.client.HTTPConnection
def send_request(url):
http.client.HTTPConnection(url) # Sensitive
----
2021-01-27 13:42:22 +01:00
``++request++`` library
2020-06-30 12:49:37 +02:00
----
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
----
2021-01-27 13:42:22 +01:00
Python 2 ``++urllib2++``
2020-06-30 12:49:37 +02:00
----
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
----
2021-01-27 13:42:22 +01:00
Python 3 ``++urllib++`` module
2020-06-30 12:49:37 +02:00
----
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[]
ifdef::env-github,rspecator-view[]
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]