Commit e2712b10f3ff126bdc12d8f9ee710804f36528a9

Authored by Alexis Koralewski
1 parent ff2b2267
Exists in dev

new usage of delimiter in cmd parsing in agent_detail view

CHANGELOG
1   -02-02-2023 (AKo): v0.6.15.3
  1 +03-01-2023 (AKo): v0.6.15.4
  2 + - new usage of delimiter in cmd parsing in agent_detail view
  3 +
  4 +02-01-2023 (AKo): v0.6.15.3
2 5 - Fixing cmd parsing in agent_detail view
3 6  
4 7 12-12-2022 (AKo): v0.6.15.3
... ...
VERSION
1   -0.6.15.3
2 1 \ No newline at end of file
  2 +0.6.15.4
3 3 \ No newline at end of file
... ...
src/core/pyros_django/dashboard/views.py
... ... @@ -261,12 +261,11 @@ def agent_detail(request, agent_name):
261 261 for specific_cmd in agent_specific_cmd_to_list:
262 262 if "get_all_cmds" in specific_cmd or "get_specific_cmds" in specific_cmd:
263 263 continue
264   -
265 264 if "(" in specific_cmd:
266 265 splitted_cmd = specific_cmd.split("/")
267   - specific_cmd = splitted_cmd.pop()
  266 + specific_cmd = splitted_cmd.pop(0)
268 267 if len(splitted_cmd) > 0:
269   - description = splitted_cmd.pop()
  268 + description = splitted_cmd.pop(0)
270 269 else:
271 270 description = ""
272 271 cmd = specific_cmd.split("(")[0]
... ... @@ -286,34 +285,18 @@ def agent_detail(request, agent_name):
286 285 specific_cmd_with_args[cmd].append([arg_name,trim_values])
287 286 cmd_with_choices.append(cmd)
288 287 else:
289   - arguments = arg.split(",")
290   - bad_split_arg = False
291   - temp_arg = ""
  288 + arguments = arg.split("|")
292 289 for index ,arg in enumerate(arguments):
293   - if bad_split_arg:
294   - # if arg finish by ], this mean its the end
295   - if arg[-1] == "]" or index == len(arguments)-1 :
296   - bad_split_arg = False
297   - temp_arg += arg
298   - arg = temp_arg
299   - temp_arg = ""
300   - arg_name = arg.split(":")[0]
301   - arg_type = arg.split(":")[1]
302   - if arg_type.startswith("typing.Tuple["):
303   - trim_values = []
304   - values_type = re.findall(pattern="\[(.*?)\]",string=arg_type)
305   - args_type = values_type[0].split(" ")
306   - for arg in args_type:
307   - specific_cmd_with_args[cmd].append([arg_name,arg])
308   - continue
309   - else:
310   - temp_arg += arg
311   - # go to next iteration
312   - continue
313   - #arg,arg_type = arg.split(":")
314   - if ("typing.Tuple" in arg or "typing.List" in arg) and index != len(arguments)-1:
315   - bad_split_arg = True
316   - temp_arg = arg
  290 + if ("typing.Tuple" in arg or "typing.List" in arg):
  291 + arg_name = arg.split(":")[0]
  292 + arg_type = arg.split(":")[1]
  293 + trim_values = []
  294 + values_type = re.findall(pattern="\[(.*?)\]",string=arg_type)
  295 + if values_type:
  296 + # best way to tell user the type allowed in list or tuple is to put the raw content in one field
  297 + specific_cmd_with_args[cmd].append([arg_name+" "+str(values_type),"str"])
  298 + #for arg in values_type:
  299 + # specific_cmd_with_args[cmd].append([arg_name+" "+arg_type,arg])
317 300 else:
318 301 specific_cmd_with_args[cmd].append(arg.split(":"))
319 302 if request.GET.get("cmd"):
... ...