2020-06-30 14:41:58 +02:00
include::../description.adoc[]
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
2021-06-04 14:23:34 +02:00
== Sensitive Code Example
2020-06-30 14:41:58 +02:00
For python3:
----
import http.cookies
setCookie = http.cookies.SimpleCookie()
setCookie['restricted_cookie'] = 'cookie_value'
setCookie['restricted_cookie']['domain'] = '.com' # Sensitive
setCookie['restricted_cookie']['path'] = '/'
----
For flask:
----
from flask import app, make_response, render_template
@app.route('/')
def index():
http_response = make_response(render_template())
http_response.set_cookie(
"restricted_cookie",
domain='.com', # Sensitive
path='/'
)
return http_response
----
== Compliant Solution
For python3:
2022-02-04 17:28:24 +01:00
[source,python]
2020-06-30 14:41:58 +02:00
----
import http.cookies
setCookie = http.cookies.SimpleCookie()
setCookie['restricted_cookie'] = 'cookie_value'
setCookie['restricted_cookie']['domain'] = '.sonarsource.com' # Compliant
setCookie['restricted_cookie']['path'] = '/'
----
For flask:
2022-02-04 17:28:24 +01:00
[source,python]
2020-06-30 14:41:58 +02:00
----
from flask import app, make_response, render_template
@app.route('/')
def index():
http_response = make_response(render_template())
http_response.set_cookie(
"restricted_cookie",
domain='sonarsource.com', # Compliant
path='/'
)
return http_response
----
include::../see.adoc[]
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== on 28 Oct 2019, 07:45:20 Alexandre Gigleux wrote:
To be reviewed. "NonCompliant" should be used for "Security Vulnerability" detection not for Security Hotspot. In the "Sensitive Code Examples" section, we should see only "Sensitive".
include::../comments-and-links.adoc[]
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]