From a9d60c85ebec2729ed38d2a4919a5d901ef42841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cuhel?= <79118988+HonzaCuhel@users.noreply.github.com> Date: Tue, 8 Oct 2024 08:38:50 +0200 Subject: [PATCH] Fix/solve sanic security issues (#109) * Solve sonic security issue * Renaming function * Update exporters --------- --- main.py | 5 ++++- requirements.txt | 2 +- yolo/exporter.py | 4 +--- yolov6r1/main.py | 4 +++- yolov6r1/requirements.txt | 2 +- yolov6r1/yolo/exporter.py | 4 +--- yolov6r3/main.py | 5 ++++- yolov6r3/requirements.txt | 2 +- yolov6r3/yolo/exporter.py | 4 +--- yolov7/main.py | 4 +++- yolov7/requirements.txt | 2 +- yolov7/yolo/exporter.py | 4 +--- .../utils/google_app_engine/additional_requirements.txt | 6 +++--- 13 files changed, 25 insertions(+), 23 deletions(-) diff --git a/main.py b/main.py index daa10cc..62b268c 100644 --- a/main.py +++ b/main.py @@ -18,9 +18,12 @@ import os import aiofiles +Sanic.START_METHOD_SET = True +Sanic.start_method = "fork" Config.KEEP_ALIVE = False Config.RESPONSE_TIMEOUT = 1000 app = Sanic(__name__) +print(app.start_method, app.START_METHOD_SET) app.config.static_path = (Path(__file__).parent / './client/build/static').resolve().absolute() if not app.config.static_path.exists(): raise RuntimeError("Client was not built. Please run `npm install && npm run build` to build the client") @@ -41,7 +44,7 @@ async def index(request): @app.get("/progress/") -async def index(request, key): +async def progress(request, key): return response.json({"progress": conversions.get(key, "none")}) diff --git a/requirements.txt b/requirements.txt index 212de7c..60029e0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -sanic==21.12.1 +sanic>=21.12.2 # torch==1.10.2 # torchvision==0.11.3 torch>=2.2.0 diff --git a/yolo/exporter.py b/yolo/exporter.py index 8754f93..15008f7 100644 --- a/yolo/exporter.py +++ b/yolo/exporter.py @@ -95,9 +95,7 @@ def export_blob(self): shaves=self.n_shaves, version="2022.1" if self.use_rvc2 else "2022.3_RVC3", use_cache=False, - output_dir=self.conv_path.resolve(), - url="https://blobconverter.luxonis.com" if self.use_rvc2 else \ - os.getenv("RVC3_BLOBCONVERTER", "https://blobconverter.luxonis.com") + output_dir=self.conv_path.resolve() ) self.f_blob = blob_path diff --git a/yolov6r1/main.py b/yolov6r1/main.py index b47f80f..2339220 100644 --- a/yolov6r1/main.py +++ b/yolov6r1/main.py @@ -15,6 +15,8 @@ import os import aiofiles +Sanic.START_METHOD_SET = True +Sanic.start_method = "fork" Config.KEEP_ALIVE = False Config.RESPONSE_TIMEOUT = 1000 app = Sanic(__name__) @@ -29,7 +31,7 @@ @app.get("/yolov6r1/progress/") -async def index(request, key): +async def progress(request, key): return response.json({"progress": conversions.get(key, "none")}) diff --git a/yolov6r1/requirements.txt b/yolov6r1/requirements.txt index 60d7ac3..a1eb167 100644 --- a/yolov6r1/requirements.txt +++ b/yolov6r1/requirements.txt @@ -1,4 +1,4 @@ -sanic==21.12.1 +sanic>=21.12.2 torch>=2.2.0 torchvision>=0.11.3 diff --git a/yolov6r1/yolo/exporter.py b/yolov6r1/yolo/exporter.py index 1d5becb..911c9cc 100644 --- a/yolov6r1/yolo/exporter.py +++ b/yolov6r1/yolo/exporter.py @@ -95,9 +95,7 @@ def export_blob(self): shaves=self.n_shaves, version="2022.1" if self.use_rvc2 else "2022.3_RVC3", use_cache=False, - output_dir=self.conv_path.resolve(), - url="https://blobconverter.luxonis.com" if self.use_rvc2 else \ - os.getenv("RVC3_BLOBCONVERTER", "https://blobconverter.luxonis.com") + output_dir=self.conv_path.resolve() ) self.f_blob = blob_path diff --git a/yolov6r3/main.py b/yolov6r3/main.py index 74502cc..a91167a 100644 --- a/yolov6r3/main.py +++ b/yolov6r3/main.py @@ -16,6 +16,9 @@ import os import aiofiles + +Sanic.START_METHOD_SET = True +Sanic.start_method = "fork" Config.KEEP_ALIVE = False Config.RESPONSE_TIMEOUT = 1000 app = Sanic(__name__) @@ -30,7 +33,7 @@ @app.get("/yolov6r3/progress/") -async def index(request, key): +async def progress(request, key): return response.json({"progress": conversions.get(key, "none")}) diff --git a/yolov6r3/requirements.txt b/yolov6r3/requirements.txt index 9621a91..f614fef 100644 --- a/yolov6r3/requirements.txt +++ b/yolov6r3/requirements.txt @@ -1,4 +1,4 @@ -sanic==21.12.1 +sanic>=21.12.2 torch>=2.2.0 torchvision>=0.11.3 diff --git a/yolov6r3/yolo/exporter.py b/yolov6r3/yolo/exporter.py index 0cbb727..d932520 100644 --- a/yolov6r3/yolo/exporter.py +++ b/yolov6r3/yolo/exporter.py @@ -95,9 +95,7 @@ def export_blob(self): shaves=self.n_shaves, version="2022.1" if self.use_rvc2 else "2022.3_RVC3", use_cache=False, - output_dir=self.conv_path.resolve(), - url="https://blobconverter.luxonis.com" if self.use_rvc2 else \ - os.getenv("RVC3_BLOBCONVERTER", "https://blobconverter.luxonis.com") + output_dir=self.conv_path.resolve() ) self.f_blob = blob_path diff --git a/yolov7/main.py b/yolov7/main.py index 96c3f6e..ba64cc8 100644 --- a/yolov7/main.py +++ b/yolov7/main.py @@ -15,6 +15,8 @@ import os import aiofiles +Sanic.START_METHOD_SET = True +Sanic.start_method = "fork" Config.KEEP_ALIVE = False Config.RESPONSE_TIMEOUT = 1000 app = Sanic(__name__) @@ -29,7 +31,7 @@ @app.get("/yolov7/progress/") -async def index(request, key): +async def progress(request, key): return response.json({"progress": conversions.get(key, "none")}) diff --git a/yolov7/requirements.txt b/yolov7/requirements.txt index 0b196fb..001abcf 100644 --- a/yolov7/requirements.txt +++ b/yolov7/requirements.txt @@ -1,4 +1,4 @@ -sanic==21.12.1 +sanic>=21.12.2 torch>=2.2.0 torchvision>=0.11.3 diff --git a/yolov7/yolo/exporter.py b/yolov7/yolo/exporter.py index 1d5becb..911c9cc 100644 --- a/yolov7/yolo/exporter.py +++ b/yolov7/yolo/exporter.py @@ -95,9 +95,7 @@ def export_blob(self): shaves=self.n_shaves, version="2022.1" if self.use_rvc2 else "2022.3_RVC3", use_cache=False, - output_dir=self.conv_path.resolve(), - url="https://blobconverter.luxonis.com" if self.use_rvc2 else \ - os.getenv("RVC3_BLOBCONVERTER", "https://blobconverter.luxonis.com") + output_dir=self.conv_path.resolve() ) self.f_blob = blob_path diff --git a/yolov7/yolo/yolov7/utils/google_app_engine/additional_requirements.txt b/yolov7/yolo/yolov7/utils/google_app_engine/additional_requirements.txt index 5fcc305..8b0ebe6 100644 --- a/yolov7/yolo/yolov7/utils/google_app_engine/additional_requirements.txt +++ b/yolov7/yolo/yolov7/utils/google_app_engine/additional_requirements.txt @@ -1,4 +1,4 @@ # add these requirements in your app on top of the existing ones -pip==18.1 -Flask==1.0.2 -gunicorn==19.9.0 +pip>=23.3 +flask>=2.2.5 +gunicorn>=22.0.0