Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Address Bandit B404 subprocess findings in GitHub Actions Python (#37655)

Andrey Babushkin6eea050a4a0b
diff --git a/.github/actions/coverage_toolkit/collect_cpp_coverage.py b/.github/actions/coverage_toolkit/collect_cpp_coverage.py
index f03de1eb248..eadf8bb64e9 100644
--- a/.github/actions/coverage_toolkit/collect_cpp_coverage.py
+++ b/.github/actions/coverage_toolkit/collect_cpp_coverage.py
@@ -7,7 +7,8 @@ import os
import re
import shlex
import shutil
-import subprocess
+# Coverage CI: fixed toolchain argv (lcov/gcov/genhtml), no shell.
+import subprocess # nosec B404
from pathlib import Path
from coverage_workflow import CoverageContext, LOGGER, run_cmd
diff --git a/.github/actions/coverage_toolkit/coverage.py b/.github/actions/coverage_toolkit/coverage.py
index 1e35a8937b6..45b302fbdce 100644
--- a/.github/actions/coverage_toolkit/coverage.py
+++ b/.github/actions/coverage_toolkit/coverage.py
@@ -11,7 +11,8 @@ import logging
import os
from pathlib import Path
import shlex
-import subprocess
+# Coverage CI: run_cmd uses argv lists with shell=False unless explicitly opted in.
+import subprocess # nosec B404
import sys
from typing import Any
diff --git a/.github/actions/coverage_toolkit/run_tests.py b/.github/actions/coverage_toolkit/run_tests.py
index eb099cc985d..81137f009d9 100644
--- a/.github/actions/coverage_toolkit/run_tests.py
+++ b/.github/actions/coverage_toolkit/run_tests.py
@@ -9,7 +9,8 @@ import os
from pathlib import Path
import shlex
import shutil
-import subprocess
+# Coverage CI: pytest/coverage/python invoked as argv lists in the workflow workspace.
+import subprocess # nosec B404
import time
import xml.etree.ElementTree as ET
diff --git a/.github/scripts/agentic-workflows/remediate_transient_failure.py b/.github/scripts/agentic-workflows/remediate_transient_failure.py
index eaad7807857..03fe96ca785 100644
--- a/.github/scripts/agentic-workflows/remediate_transient_failure.py
+++ b/.github/scripts/agentic-workflows/remediate_transient_failure.py
@@ -25,7 +25,8 @@ because the default token cannot re-trigger ``merge_group`` check runs.
from __future__ import annotations
import os
-import subprocess
+# Merge-queue remediation: gh called with a fixed argv; PR/repo ids validated in common.py.
+import subprocess # nosec B404
from common import (
github_client,
diff --git a/.github/scripts/meat/build_report.py b/.github/scripts/meat/build_report.py
index 18e6578eb00..2b6568b2ea5 100644
--- a/.github/scripts/meat/build_report.py
+++ b/.github/scripts/meat/build_report.py
@@ -27,7 +27,8 @@ Output files:
import json
import os
import pathlib
-import subprocess
+# Posts report via gh using argv lists; comment body is passed as a dedicated argument.
+import subprocess # nosec B404
import sys
import textwrap
diff --git a/.github/scripts/meat/create_agent_pr.py b/.github/scripts/meat/create_agent_pr.py
index bd41bf67730..d274cd6ae28 100644
--- a/.github/scripts/meat/create_agent_pr.py
+++ b/.github/scripts/meat/create_agent_pr.py
@@ -22,7 +22,8 @@ Exit codes:
import argparse
import json
import pathlib
-import subprocess
+# Agent PR helper: git/gh invoked as argv lists; no shell string composition.
+import subprocess # nosec B404
import sys
import textwrap
diff --git a/.github/scripts/meat/enable_operator.py b/.github/scripts/meat/enable_operator.py
index 630c97545b6..3c4b7546d13 100644
--- a/.github/scripts/meat/enable_operator.py
+++ b/.github/scripts/meat/enable_operator.py
@@ -33,7 +33,8 @@ Shortcut for: run_agent.py enable-operator <context-file>
"""
import os
-import subprocess
+# Thin wrapper: re-execs run_agent.py via sys.executable and a fixed script path (no shell).
+import subprocess # nosec B404
import sys
diff --git a/.github/scripts/meat/install_copilot_env.py b/.github/scripts/meat/install_copilot_env.py
index 35149a4b804..021405e7289 100644
--- a/.github/scripts/meat/install_copilot_env.py
+++ b/.github/scripts/meat/install_copilot_env.py
@@ -18,7 +18,8 @@ import json
import os
import platform
import shutil
-import subprocess
+# Local setup helper: subprocess.run on fixed installer/version-check argv from this script only.
+import subprocess # nosec B404
import sys
from pathlib import Path
from typing import Optional
diff --git a/.github/scripts/meat/run_agent.py b/.github/scripts/meat/run_agent.py
index 58de781b6c0..25bf8cfe74d 100644
--- a/.github/scripts/meat/run_agent.py
+++ b/.github/scripts/meat/run_agent.py
@@ -20,7 +20,8 @@ Copilot CLI reference:
"""
import os
-import subprocess
+# Runs the copilot CLI with fixed flags; prompt is a separate -p argument, not a shell command.
+import subprocess # nosec B404
import sys
AGENTS = [
diff --git a/.github/scripts/meat/tests/conftest.py b/.github/scripts/meat/tests/conftest.py
index c3a2b92488f..766a7b55d51 100644
--- a/.github/scripts/meat/tests/conftest.py
+++ b/.github/scripts/meat/tests/conftest.py
@@ -20,7 +20,8 @@ SCRIPTS_DIR = pathlib.Path(__file__).parent.parent
def run_script(script: pathlib.Path, cwd, *args, extra_env=None):
"""Run a Python script as a subprocess, return CompletedProcess."""
- import subprocess
+ # Test harness only: sys.executable + script path argv, no shell.
+ import subprocess # nosec B404
env = os.environ.copy()
if extra_env: