Skip to content

Commit b1cab54

Browse files
harmjeffclaude
andcommitted
fix(security): move nosemgrep to same line as subprocess call
Semgrep requires the suppression comment to be on the exact line of the finding. Preceding-line comments are not reliably associated with the call when both the finding and suppression are new (introduced in this PR). Moved all five nosemgrep suppressions to inline on the subprocess.run() / Popen() line itself, using the full rule ID: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent e00b731 commit b1cab54

4 files changed

Lines changed: 5 additions & 15 deletions

File tree

scripts/aidlc-evaluator/packages/cli-harness/src/cli_harness/adapters/claude_code_sdk.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,7 @@ def _exec_tool(name: str, tool_input: dict, run_folder: Path, rules_dir: Path) -
299299
if (val := os.environ.get(var)):
300300
env[var] = val
301301
try:
302-
# nosec B603 - shlex.split with shell=False, path validated via _resolve_safe
303-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
304-
result = subprocess.run(
302+
result = subprocess.run( # nosec B603 nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
305303
shlex.split(command),
306304
shell=False,
307305
cwd=str(cwd),

scripts/aidlc-evaluator/packages/cli-harness/src/cli_harness/adapters/kiro_cli.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ def _run_kiro_stage(stage_prompt: str, stage_name: str, is_first: bool) -> tuple
171171

172172
_log(f"{stage_name}: launching kiro ({len(stage_prompt)} chars)")
173173

174-
# nosec B603 - Executing user's Kiro CLI with validated configuration
175-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
176-
proc = subprocess.Popen(
174+
proc = subprocess.Popen( # nosec B603 nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
177175
cmd,
178176
cwd=str(workspace),
179177
stdout=subprocess.PIPE,

scripts/aidlc-evaluator/run.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ def check_docker_sandbox() -> bool:
9393
if cli is None:
9494
return False
9595
try:
96-
# nosec B603 - Static container CLI info command for sandbox availability check
97-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
98-
result = subprocess.run(
96+
result = subprocess.run( # nosec B603 nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
9997
[cli, "info"],
10098
stdout=subprocess.DEVNULL,
10199
stderr=subprocess.DEVNULL,
@@ -104,9 +102,7 @@ def check_docker_sandbox() -> bool:
104102
if result.returncode != 0:
105103
return False
106104

107-
# nosec B603 - Static container CLI images command with fixed arguments
108-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
109-
result = subprocess.run(
105+
result = subprocess.run( # nosec B603 nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
110106
[cli, "images", "-q", "aidlc-sandbox:latest"],
111107
capture_output=True,
112108
text=True,

scripts/aidlc-evaluator/scripts/run_git_compare.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,7 @@ def run_single_evaluation(
367367
log_file.write(f"{'=' * 70}\n\n")
368368
log_file.flush()
369369

370-
# nosec B603 - Executing trusted run_evaluation.py with git-compare config
371-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
372-
result = subprocess.run(cmd, stdout=log_file, stderr=subprocess.STDOUT)
370+
result = subprocess.run(cmd, stdout=log_file, stderr=subprocess.STDOUT) # nosec B603 nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
373371

374372
elapsed_s = time.monotonic() - start_monotonic
375373
status = "success" if result.returncode == 0 else "failed"

0 commit comments

Comments
 (0)