mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
38 lines
700 B
Python
38 lines
700 B
Python
from flask import Flask
|
|
app = Flask(__name__)
|
|
|
|
|
|
import traceback
|
|
|
|
def do_computation():
|
|
raise Exception("Secret info")
|
|
|
|
# BAD
|
|
@app.route('/bad')
|
|
def server_bad():
|
|
try:
|
|
do_computation()
|
|
except Exception as e:
|
|
return traceback.format_exc()
|
|
|
|
# GOOD
|
|
@app.route('/good')
|
|
def server_good():
|
|
try:
|
|
do_computation()
|
|
except Exception as e:
|
|
log(traceback.format_exc())
|
|
return "An internal error has occurred!"
|
|
|
|
#BAD
|
|
@app.route('/bad/with-flow')
|
|
def server_bad_flow():
|
|
try:
|
|
do_computation()
|
|
except Exception as e:
|
|
err = traceback.format_exc()
|
|
return format_error(err)
|
|
|
|
def format_error(msg):
|
|
return "[ERROR] " + msg
|