Skip to content

Commit

Permalink
Revert "Modify rule S3330: Add FastAPI (APPSEC-1260) (#3392)"
Browse files Browse the repository at this point in the history
This reverts commit 6429a96.
  • Loading branch information
egon-okerman-sonarsource committed Nov 6, 2023
1 parent b9a3733 commit 8dd7efe
Showing 1 changed file with 5 additions and 36 deletions.
41 changes: 5 additions & 36 deletions rules/S3330/python/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,33 @@ include::../recommended.adoc[]

== Sensitive Code Example

Using Flask:
Flask:

[source,python,diff-id=11,diff-type=noncompliant]
----
from flask import Response
@app.route('/')
def index():
response = Response()
response.set_cookie('key', 'value') # Sensitive
response.set_cookie('key', 'value') # Sensitive
return response
----

Using FastAPI:

[source,python,diff-id=21,diff-type=noncompliant]
----
from fastapi import FastAPI, Response
app = FastAPI()
@app.get('/')
async def index(response: Response):
response.set_cookie('key', 'value') # Sensitive
return {"message": "Hello world!"}
----


== Compliant Solution

Using Flask:
Flask:

[source,python,diff-id=11,diff-type=compliant]
[source,python]
----
from flask import Response
@app.route('/')
def index():
response = Response()
response.set_cookie('key', 'value', httponly=True)
response.set_cookie('key', 'value', httponly=True) # Compliant
return response
----

Using FastAPI:

[source,python,diff-id=21,diff-type=compliant]
----
from fastapi import FastAPI, Response
app = FastAPI()
@app.get('/')
async def index(response: Response):
response.set_cookie('key', 'value', httponly=True)
return {"message": "Hello world!"}
----


include::../see.adoc[]

ifdef::env-github,rspecator-view[]
Expand Down

0 comments on commit 8dd7efe

Please sign in to comment.