Skip to content

Commit 05a903c

Browse files
feat: accept bandit advisories in-line for subprocess (#1077)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 5d44a2d commit 05a903c

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
@@ -238,7 +241,7 @@ def prepare_and_start_backend(
238241
LOG.debug(f"Args: {args}")
239242
LOG.debug(f"Environment variables: {env_copy}")
240243

241-
instance = ProductInstance(_start_program(args, env_copy).pid)
244+
instance = ProductInstance(__start_program(args, env_copy).pid)
242245

243246
return Modeler(
244247
host=host, port=port, timeout=timeout, product_instance=instance, backend_type=backend_type
@@ -278,7 +281,7 @@ def _manifest_path_provider(version: int, available_installations: Dict) -> str:
278281
)
279282

280283

281-
def _start_program(args: List[str], local_env: Dict[str, str]) -> subprocess.Popen:
284+
def __start_program(args: List[str], local_env: Dict[str, str]) -> subprocess.Popen:
282285
"""
283286
Start the program where the path is the first item of the ``args`` array argument.
284287
@@ -295,7 +298,8 @@ def _start_program(args: List[str], local_env: Dict[str, str]) -> subprocess.Pop
295298
subprocess.Popen
296299
The subprocess object.
297300
"""
298-
return subprocess.Popen(
301+
# private method and controlled input by library - excluding bandit check.
302+
return subprocess.Popen( # nosec B603
299303
args,
300304
stdin=subprocess.DEVNULL,
301305
stdout=subprocess.DEVNULL,

0 commit comments

Comments
 (0)