Files

67 lines
1.8 KiB
Python

'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/securecookie-00/BenchmarkTest00593', methods=['GET'])
def BenchmarkTest00593_get():
return BenchmarkTest00593_post()
@app.route('/benchmark/securecookie-00/BenchmarkTest00593', methods=['POST'])
def BenchmarkTest00593_post():
RESPONSE = ""
param = ""
headers = request.headers.getlist("BenchmarkTest00593")
if headers:
param = headers[0]
import helpers.ThingFactory
thing = helpers.ThingFactory.createThing()
bar = thing.doSomething(param)
from flask import make_response
import io
import helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
cookie = 'SomeCookie'
value = input.decode('utf-8')
RESPONSE += (
f'Created cookie: \'{cookie}\' with value \'{helpers.utils.escape_for_html(value)}\' and secure flag set to false.'
)
RESPONSE = make_response(RESPONSE)
RESPONSE.set_cookie(cookie, value,
path=request.path,
secure=False,
httponly=True)
return RESPONSE