kopia lustrzana https://github.com/snarfed/bridgy-fed
remove /memcache_command and /python_eval
too scary to have in the codebase even with auth around thempull/1696/head
rodzic
a1e5d4419d
commit
0c17d0a40e
|
@ -58,7 +58,7 @@ app.wsgi_app = flask_util.ndb_context_middleware(
|
||||||
app.wsgi_app, client=appengine_config.ndb_client, **common.NDB_CONTEXT_KWARGS)
|
app.wsgi_app, client=appengine_config.ndb_client, **common.NDB_CONTEXT_KWARGS)
|
||||||
|
|
||||||
|
|
||||||
app.add_url_rule('/hub/eval', view_func=pages.python_eval, methods=['POST'])
|
# app.add_url_rule('/hub/eval', view_func=pages.python_eval, methods=['POST'])
|
||||||
|
|
||||||
@app.get('/liveness_check')
|
@app.get('/liveness_check')
|
||||||
@app.get('/readiness_check')
|
@app.get('/readiness_check')
|
||||||
|
|
44
pages.py
44
pages.py
|
@ -461,47 +461,3 @@ def instance_info():
|
||||||
@flask_util.headers(CACHE_CONTROL)
|
@flask_util.headers(CACHE_CONTROL)
|
||||||
def log():
|
def log():
|
||||||
return logs.log()
|
return logs.log()
|
||||||
|
|
||||||
|
|
||||||
@app.post('/memcache')
|
|
||||||
def memcache_command():
|
|
||||||
"""Minimal memcache text protocol command handler.
|
|
||||||
|
|
||||||
Requires the Flask app's secret key in the Authorization HTTP header.
|
|
||||||
|
|
||||||
Example usage:
|
|
||||||
|
|
||||||
curl https://fed.brid.gy/memcache -H 'Authorization: ...' -d 'stats items'
|
|
||||||
|
|
||||||
https://docs.memcached.org/protocols/
|
|
||||||
https://github.com/memcached/memcached/blob/master/doc/protocol.txt
|
|
||||||
"""
|
|
||||||
if request.headers.get('Authorization') != app.config['SECRET_KEY']:
|
|
||||||
return '', 401
|
|
||||||
|
|
||||||
resp = memcache.memcache.raw_command(request.get_data(as_text=True),
|
|
||||||
end_tokens='END\r\n')
|
|
||||||
return resp.decode(), {'Content-Type': 'text/plain'}
|
|
||||||
|
|
||||||
|
|
||||||
@app.post('/app/eval')
|
|
||||||
def python_eval(which=None):
|
|
||||||
if request.headers.get('Authorization') != app.config['SECRET_KEY']:
|
|
||||||
return '', 401
|
|
||||||
|
|
||||||
import contextlib, io, traceback
|
|
||||||
|
|
||||||
input = request.get_data(as_text=True)
|
|
||||||
logger.info(f'python_eval got: {input}')
|
|
||||||
|
|
||||||
out = io.StringIO()
|
|
||||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(out):
|
|
||||||
try:
|
|
||||||
exec(input)
|
|
||||||
except BaseException as e:
|
|
||||||
logger.info(f'python_eval error! {e}')
|
|
||||||
traceback.print_exception(e, file=out)
|
|
||||||
finally:
|
|
||||||
output = out.getvalue()
|
|
||||||
logger.info(f'python_eval out: {output}')
|
|
||||||
return output, {'Content-Type': 'text/plain'}
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ app.add_url_rule('/queue/send', view_func=protocol.send_task, methods=['POST'])
|
||||||
app.add_url_rule('/queue/webmention', view_func=web.webmention_task, methods=['POST'])
|
app.add_url_rule('/queue/webmention', view_func=web.webmention_task, methods=['POST'])
|
||||||
app.add_url_rule('/cron/atproto-poll-chat', view_func=atproto.poll_chat_task,
|
app.add_url_rule('/cron/atproto-poll-chat', view_func=atproto.poll_chat_task,
|
||||||
methods=['GET'])
|
methods=['GET'])
|
||||||
app.add_url_rule('/router/eval', view_func=pages.python_eval, methods=['POST'])
|
# app.add_url_rule('/router/eval', view_func=pages.python_eval, methods=['POST'])
|
||||||
|
|
||||||
|
|
||||||
@app.get('/liveness_check')
|
@app.get('/liveness_check')
|
||||||
|
|
Ładowanie…
Reference in New Issue