rspec/rules/S5334/python/rule.adoc
2022-02-04 16:28:24 +00:00

39 lines
714 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
[source,python]
----
from flask import request
@app.route('/')
def index():
module = request.args.get("module")
exec("import urllib%s as urllib" % module) # Noncompliant
----
== Compliant Solution
[source,python]
----
from flask import request
@app.route('/')
def index():
module = request.args.get("module")
exec("import urllib%d as urllib" % int(module)) # Compliant; module is safely cast to an integer
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
endif::env-github,rspecator-view[]