Skip to content

Commit 58b6b1f

Browse files
committed
Suppress Semgrep findings on shell_open's os.startfile / Popen
Codacy's Semgrep dangerous-spawn/subprocess rules flag os.startfile and subprocess.Popen on dynamic content; add line-level # nosemgrep with justification (file path from the allow-listed plan; argv list, no shell - injection-safe), matching the shell_command handler's pattern.
1 parent ef98534 commit 58b6b1f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

je_auto_control/utils/shell_open/shell_open.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ def _default_opener(plan: Dict[str, Any]) -> bool:
7272
if backend == "startfile":
7373
if not sys.platform.startswith("win"):
7474
raise RuntimeError("startfile is only supported on Windows")
75-
# noqa: S606 / nosec B606 — verb is from the allow-listed plan, no shell
76-
os.startfile(target, plan.get("verb") or "open") # noqa: S606 # nosec B606
75+
# file path is from the allow-listed plan; os.startfile is not a shell
76+
os.startfile(target, plan.get("verb") or "open") # noqa: S606 # nosec B606 # nosemgrep
7777
return True
7878
import subprocess # nosec B404 # reason: argv list, no shell
79-
subprocess.Popen([backend, target]) # nosec B603 # reason: fixed backend + argv, no shell
79+
# fixed backend + argv list, no shell — injection-safe
80+
subprocess.Popen([backend, target]) # nosec B603 # nosemgrep
8081
return True
8182

8283

0 commit comments

Comments
 (0)