Skip to content

Commit 89c41aa

Browse files
feat: accept bandit advisories in-line for subprocess (#1077)
Co-authored-by: pyansys-ci-bot <pyansys.github.bot@ansys.com>
1 parent acb9504 commit 89c41aa

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

doc/changelog.d/1077.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat: accept bandit advisories in-line for subprocess

src/ansys/geometry/core/connection/product_instance.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
import os
2424
import signal
2525
import socket
26-
import subprocess
26+
27+
# Subprocess is needed to start the backend. But
28+
# the input is controlled by the library. Excluding bandit check.
29+
import subprocess # nosec B404
2730

2831
from ansys.tools.path import get_available_ansys_installations, get_latest_ansys_installation
2932
from beartype.typing import TYPE_CHECKING, Dict, List
@@ -302,7 +305,7 @@ def prepare_and_start_backend(
302305
LOG.debug(f"Args: {args}")
303306
LOG.debug(f"Environment variables: {env_copy}")
304307

305-
instance = ProductInstance(_start_program(args, env_copy).pid)
308+
instance = ProductInstance(__start_program(args, env_copy).pid)
306309

307310
# Verify that the backend is ready to accept connections
308311
# before returning the Modeler instance.
@@ -403,7 +406,7 @@ def _manifest_path_provider(
403406
raise RuntimeError(msg)
404407

405408

406-
def _start_program(args: List[str], local_env: Dict[str, str]) -> subprocess.Popen:
409+
def __start_program(args: List[str], local_env: Dict[str, str]) -> subprocess.Popen:
407410
"""
408411
Start the program where the path is the first item of the ``args`` array argument.
409412
@@ -420,7 +423,8 @@ def _start_program(args: List[str], local_env: Dict[str, str]) -> subprocess.Pop
420423
subprocess.Popen
421424
The subprocess object.
422425
"""
423-
return subprocess.Popen(
426+
# private method and controlled input by library - excluding bandit check.
427+
return subprocess.Popen( # nosec B603
424428
args,
425429
stdin=subprocess.DEVNULL,
426430
stdout=subprocess.DEVNULL,

0 commit comments

Comments
 (0)