Descent098 / ahd

Detected subprocess popen call with shell equals True BAN-B602
Security
Major
2 years ago4 years old
subprocess call with shell=True identified, security issue.
335                current_path = current_path.replace("/", f"{os.sep}")
336            if os.path.isdir(current_path):
337                print(f"Running: cd {current_path} && {command} ".replace("\'",""))
338                subprocess.Popen(f"cd {current_path} && {command} ".replace("\'",""), shell=True)339            elif os.path.isfile(current_path):
340                print(f"Running: {command} {current_path}".replace("\'",""))
341                subprocess.Popen(f"{command} {current_path}".replace("\'",""), shell=True)
subprocess call with shell=True identified, security issue.
347            current_path = current_path.replace("/", f"{os.sep}")
348        if os.path.isdir(current_path):
349            print(f"Running: cd {paths[0]} && {command} ".replace("\'",""))
350            subprocess.Popen(f"cd {paths[0]} && {command} ".replace("\'",""), shell=True)351        elif os.path.isfile(current_path):
352            print(f"Running: {command} {current_path}".replace("\'",""))
353            subprocess.Popen(f"{command} {current_path}".replace("\'",""), shell=True)
subprocess call with shell=True identified, security issue.
338                subprocess.Popen(f"cd {current_path} && {command} ".replace("\'",""), shell=True)
339            elif os.path.isfile(current_path):
340                print(f"Running: {command} {current_path}".replace("\'",""))
341                subprocess.Popen(f"{command} {current_path}".replace("\'",""), shell=True)342
343    else: # if only a single path is specified instead of a 'list' of them
344        current_path = paths[0]
subprocess call with shell=True identified, security issue.
350            subprocess.Popen(f"cd {paths[0]} && {command} ".replace("\'",""), shell=True)
351        elif os.path.isfile(current_path):
352            print(f"Running: {command} {current_path}".replace("\'",""))
353            subprocess.Popen(f"{command} {current_path}".replace("\'",""), shell=True)354
355
356def _preprocess_paths(paths:str) -> str: