Conversation
feature:dockerfileForArchitecture
…e cross-site scripting' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
| from unittest.mock import Mock, patch | ||
|
|
||
| os.environ["TIRA_WORKER_CONFIG"] = os.path.abspath( | ||
| os.path.join(os.path.dirname(__file__), "..", "tira-worker-config.yml") |
There was a problem hiding this comment.
This would be better to enter in https://github.com/tira-io/tira/blob/main/application/pyproject.toml#L33-L43
| try: | ||
| job = RunningProcesses.objects.get(uuid=job_id) | ||
| except: | ||
| return HttpResponseServerError(json.dumps({"status": 1, "message": "Job does not exist."})) |
There was a problem hiding this comment.
HttpResponseNotFound would be better suited
| @check_conditional_permissions(restricted=True) | ||
| def update_running_process_output(request: Request, vm_id: str, job_id: str) -> Response: | ||
| if request.method != "POST": | ||
| return HttpResponseServerError(json.dumps({"status": 1, "message": "Only Post allowed."})) |
There was a problem hiding this comment.
HttpResponseBadRequest would be better suited
| try: | ||
| data = json.loads(request.body) if request.body else request.POST.dict() | ||
| except json.JSONDecodeError: | ||
| return HttpResponseServerError(json.dumps({"status": 1, "message": "Could not parse request body as JSON."})) |
There was a problem hiding this comment.
HttpResponseBadRequest would be better suited
| return HttpResponseServerError(json.dumps({"status": 1, "message": "Could not parse request body as JSON."})) | ||
|
|
||
| if "output" not in data: | ||
| return HttpResponseServerError(json.dumps({"status": 1, "message": "A field output is expected."})) |
There was a problem hiding this comment.
HttpResponseBadRequest would be better suited
| def verify_image(self, image, platform): | ||
| client = self.__docker_client() | ||
| inspect_result = client.api.inspect_image(image) | ||
| allowed = set([platform]) |
There was a problem hiding this comment.
| allowed = set([platform]) | |
| allowed ={platform,} |
| client = self.__docker_client() | ||
| inspect_result = client.api.inspect_image(image) | ||
| allowed = set([platform]) | ||
| architecture = "unknow" |
There was a problem hiding this comment.
Maybe this could be a constant: ARCH_UNKNOWN so that people can compare against it
| } | ||
|
|
||
| if mount_directory: | ||
| additional_paths = 0 |
| if mount_directory: | ||
| additional_paths = 0 | ||
| for k, v in mount_directory.items(): | ||
| target_dir = "/tira-data/mounted/{additional_paths}" |
There was a problem hiding this comment.
Bug: Missing f before the string: f"/tira-data/mounted/{additional_paths}"?
| additional_paths = 0 | ||
| for k, v in mount_directory.items(): | ||
| target_dir = "/tira-data/mounted/{additional_paths}" | ||
| additional_paths += 1 | ||
| volumes[v] = {"bind": target_dir, "mode": "ro"} | ||
| environment[k] = target_dir |
There was a problem hiding this comment.
| additional_paths = 0 | |
| for k, v in mount_directory.items(): | |
| target_dir = "/tira-data/mounted/{additional_paths}" | |
| additional_paths += 1 | |
| volumes[v] = {"bind": target_dir, "mode": "ro"} | |
| environment[k] = target_dir | |
| for i, (k, v) in enumerate(mount_directory.items()): | |
| target_dir = f"/tira-data/mounted/{i}" | |
| volumes[v] = {"bind": target_dir, "mode": "ro"} | |
| environment[k] = target_dir |
No description provided.