make sure server scripts start with shebang

This commit is contained in:
wh1te909 2024-07-08 19:00:44 +00:00
parent b1bdc38283
commit df82914005
1 changed files with 6 additions and 2 deletions

View File

@ -495,8 +495,12 @@ class TestRunServerScript(APIView):
"This feature is disabled. It can be enabled in Global Settings." "This feature is disabled. It can be enabled in Global Settings."
) )
code: str = request.data["code"]
if not code.startswith("#!"):
return notify_error("Missing shebang!")
stdout, stderr, execution_time, retcode = run_server_script( stdout, stderr, execution_time, retcode = run_server_script(
body=request.data["code"], body=code,
args=request.data["args"], args=request.data["args"],
env_vars=request.data["env_vars"], env_vars=request.data["env_vars"],
timeout=request.data["timeout"], timeout=request.data["timeout"],
@ -506,7 +510,7 @@ class TestRunServerScript(APIView):
AuditLog.audit_test_script_run( AuditLog.audit_test_script_run(
username=request.user.username, username=request.user.username,
agent=None, agent=None,
script_body=request.data["code"], script_body=code,
debug_info={"ip": request._client_ip}, debug_info={"ip": request._client_ip},
) )