From e2712b10f3ff126bdc12d8f9ee710804f36528a9 Mon Sep 17 00:00:00 2001 From: Alexis Koralewski Date: Tue, 3 Jan 2023 14:55:27 +0100 Subject: [PATCH] new usage of delimiter in cmd parsing in agent_detail view --- CHANGELOG | 5 ++++- VERSION | 2 +- src/core/pyros_django/dashboard/views.py | 43 +++++++++++++------------------------------ 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index dd3d014..38c3803 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ -02-02-2023 (AKo): v0.6.15.3 +03-01-2023 (AKo): v0.6.15.4 + - new usage of delimiter in cmd parsing in agent_detail view + +02-01-2023 (AKo): v0.6.15.3 - Fixing cmd parsing in agent_detail view 12-12-2022 (AKo): v0.6.15.3 diff --git a/VERSION b/VERSION index 2409bfd..3ac49ad 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.15.3 \ No newline at end of file +0.6.15.4 \ No newline at end of file diff --git a/src/core/pyros_django/dashboard/views.py b/src/core/pyros_django/dashboard/views.py index e8078b1..9065edb 100644 --- a/src/core/pyros_django/dashboard/views.py +++ b/src/core/pyros_django/dashboard/views.py @@ -261,12 +261,11 @@ def agent_detail(request, agent_name): for specific_cmd in agent_specific_cmd_to_list: if "get_all_cmds" in specific_cmd or "get_specific_cmds" in specific_cmd: continue - if "(" in specific_cmd: splitted_cmd = specific_cmd.split("/") - specific_cmd = splitted_cmd.pop() + specific_cmd = splitted_cmd.pop(0) if len(splitted_cmd) > 0: - description = splitted_cmd.pop() + description = splitted_cmd.pop(0) else: description = "" cmd = specific_cmd.split("(")[0] @@ -286,34 +285,18 @@ def agent_detail(request, agent_name): specific_cmd_with_args[cmd].append([arg_name,trim_values]) cmd_with_choices.append(cmd) else: - arguments = arg.split(",") - bad_split_arg = False - temp_arg = "" + arguments = arg.split("|") for index ,arg in enumerate(arguments): - if bad_split_arg: - # if arg finish by ], this mean its the end - if arg[-1] == "]" or index == len(arguments)-1 : - bad_split_arg = False - temp_arg += arg - arg = temp_arg - temp_arg = "" - arg_name = arg.split(":")[0] - arg_type = arg.split(":")[1] - if arg_type.startswith("typing.Tuple["): - trim_values = [] - values_type = re.findall(pattern="\[(.*?)\]",string=arg_type) - args_type = values_type[0].split(" ") - for arg in args_type: - specific_cmd_with_args[cmd].append([arg_name,arg]) - continue - else: - temp_arg += arg - # go to next iteration - continue - #arg,arg_type = arg.split(":") - if ("typing.Tuple" in arg or "typing.List" in arg) and index != len(arguments)-1: - bad_split_arg = True - temp_arg = arg + if ("typing.Tuple" in arg or "typing.List" in arg): + arg_name = arg.split(":")[0] + arg_type = arg.split(":")[1] + trim_values = [] + values_type = re.findall(pattern="\[(.*?)\]",string=arg_type) + if values_type: + # best way to tell user the type allowed in list or tuple is to put the raw content in one field + specific_cmd_with_args[cmd].append([arg_name+" "+str(values_type),"str"]) + #for arg in values_type: + # specific_cmd_with_args[cmd].append([arg_name+" "+arg_type,arg]) else: specific_cmd_with_args[cmd].append(arg.split(":")) if request.GET.get("cmd"): -- libgit2 0.21.2