rspec/rules/S4784/python/rule.adoc

70 lines
1.7 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
Django
2020-06-30 12:49:37 +02:00
----
from django.core.validators import RegexValidator
from django.urls import re_path
RegexValidator('(a*)*b') # Sensitive
def define_http_endpoint(view):
re_path(r'^(a*)*b/$', view) # Sensitive
----
2021-01-27 13:42:22 +01:00
``++re++`` module
2020-06-30 12:49:37 +02:00
----
import re
from re import compile, match, search, fullmatch, split, findall, finditer, sub, subn
input = 'input string'
replacement = 'replacement'
re.compile('(a*)*b') # Sensitive
re.match('(a*)*b', input) # Sensitive
re.search('(a*)*b', input) # Sensitive
re.fullmatch('(a*)*b', input) # Sensitive
re.split('(a*)*b', input) # Sensitive
re.findall('(a*)*b', input) # Sensitive
re.finditer('(a*)*b',input) # Sensitive
re.sub('(a*)*b', replacement, input) # Sensitive
re.subn('(a*)*b', replacement, input) # Sensitive
----
2021-01-27 13:42:22 +01:00
``++regex++`` module
2020-06-30 12:49:37 +02:00
----
import regex
from regex import compile, match, search, fullmatch, split, findall, finditer, sub, subn, subf, subfn, splititer
input = 'input string'
replacement = 'replacement'
regex.subf('(a*)*b', replacement, input) # Sensitive
regex.subfn('(a*)*b', replacement, input) # Sensitive
regex.splititer('(a*)*b', input) # Sensitive
regex.compile('(a*)*b') # Sensitive
regex.match('(a*)*b', input) # Sensitive
regex.search('(a*)*b', input) # Sensitive
regex.fullmatch('(a*)*b', input) # Sensitive
regex.split('(a*)*b', input) # Sensitive
regex.findall('(a*)*b', input) # Sensitive
regex.finditer('(a*)*b',input) # Sensitive
regex.sub('(a*)*b', replacement, input) # Sensitive
regex.subn('(a*)*b', replacement, input) # Sensitive
----
include::../exceptions.adoc[]
include::../see.adoc[]