diff --git a/google-cloud-functions/google_cloud_function.py b/google-cloud-functions/google_cloud_function.py index dc2d505..3caf28d 100644 --- a/google-cloud-functions/google_cloud_function.py +++ b/google-cloud-functions/google_cloud_function.py @@ -3,6 +3,7 @@ import shlex import subprocess import base64 +import hashlib # Set environment flag of MAX_EXECUTABLE, MAX_DATA_SIZE @@ -66,7 +67,8 @@ def execute(request): except ValueError: return bad_request("Timeout format invalid") - path = "/tmp/execute.sh" + hash = hashlib.sha256(executable).hexdigest().upper() + path = f"/tmp/{hash}.sh" with open(path, "w") as f: f.write(executable.decode()) diff --git a/lambda/lambda_function.py b/lambda/lambda_function.py index 893fa4e..46e354d 100644 --- a/lambda/lambda_function.py +++ b/lambda/lambda_function.py @@ -3,6 +3,7 @@ import shlex import base64 import subprocess +import hashlib HEADERS = { "content-type": "application/json", @@ -75,7 +76,8 @@ def lambda_handler(event, context): except ValueError: return bad_request("Timeout format invalid") - path = "/tmp/execute.sh" + hash = hashlib.sha256(executable).hexdigest().upper() + path = f"/tmp/{hash}.sh" with open(path, "w") as f: f.write(executable.decode())