From 0842553f8a74e3d1b7f0623d1ff3f238a4397227 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Tue, 19 Jan 2021 14:36:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20celery=20=E7=AD=89?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=96=87=E4=BB=B6=E7=9A=84=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E6=BC=8F=E6=B4=9E=20(#5469)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: xinwen --- apps/ops/utils.py | 8 +++++++- apps/ops/ws.py | 2 +- data/caution.txt | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 data/caution.txt diff --git a/apps/ops/utils.py b/apps/ops/utils.py index d8c186dd6..5ce4494a6 100644 --- a/apps/ops/utils.py +++ b/apps/ops/utils.py @@ -1,11 +1,13 @@ # ~*~ coding: utf-8 ~*~ import os +import uuid from django.utils.translation import ugettext_lazy as _ from common.utils import get_logger, get_object_or_none from common.tasks import send_mail_async from orgs.utils import org_aware_func +from jumpserver.const import PROJECT_DIR from .models import Task, AdHoc @@ -79,8 +81,12 @@ def send_server_performance_mail(path, usage, usages): def get_task_log_path(base_path, task_id, level=2): task_id = str(task_id) + try: + uuid.UUID(task_id) + except: + return os.path.join(PROJECT_DIR, 'data', 'caution.txt') + rel_path = os.path.join(*task_id[:level], task_id + '.log') path = os.path.join(base_path, rel_path) os.makedirs(os.path.dirname(path), exist_ok=True) return path - diff --git a/apps/ops/ws.py b/apps/ops/ws.py index f21c79570..e9cb38d28 100644 --- a/apps/ops/ws.py +++ b/apps/ops/ws.py @@ -22,7 +22,7 @@ class TaskLogWebsocket(JsonWebsocketConsumer): def connect(self): user = self.scope["user"] - if user.is_authenticated and user.is_org_admin: + if user.is_authenticated: self.accept() else: self.close() diff --git a/data/caution.txt b/data/caution.txt new file mode 100644 index 000000000..4e85670a1 --- /dev/null +++ b/data/caution.txt @@ -0,0 +1,2 @@ + 你想偷看啥 !!! + What are you trying to peek at !!! \ No newline at end of file