|
4 | 4 |
|
5 | 5 | import argparse |
6 | 6 | import json |
7 | | -import os |
8 | | -import pathlib |
9 | | -import platform |
10 | 7 | import subprocess # nosec B404 - required to invoke the trusted nitlsconfig CLI |
11 | 8 | import sys |
12 | 9 | from dataclasses import dataclass, field |
|
15 | 12 |
|
16 | 13 | ALLOWED_SCOPES: Tuple[str, ...] = ("client", "server") |
17 | 14 |
|
18 | | -NITLSCONFIG_CLI_ENV_VAR = "NITLSCONFIG_CLI" |
19 | | - |
20 | 15 | # Expected JSON root keys from nitlsconfig output. |
21 | 16 | ROLE_TO_JSON_ROOT_KEY = { |
22 | 17 | "client": "client", |
@@ -334,30 +329,9 @@ def run_nitlsconfig_command( |
334 | 329 | timeout=30, |
335 | 330 | ) # nosec B603 - argv is passed shell-free and executable selection is controlled |
336 | 331 | except FileNotFoundError as ex: |
337 | | - fallback_root = os.environ.get(NITLSCONFIG_CLI_ENV_VAR) |
338 | | - if fallback_root and fallback_root != executable: |
339 | | - suffix = ".exe" if platform.system().lower() == "windows" else "" |
340 | | - fallback_executable = pathlib.Path(fallback_root) / f"nitlsconfig{suffix}" |
341 | | - fallback_executable_str = str(fallback_executable) |
342 | | - fallback_argv = [fallback_executable_str, *command_args] |
343 | | - try: |
344 | | - completed = subprocess.run( |
345 | | - fallback_argv, |
346 | | - capture_output=True, |
347 | | - text=True, |
348 | | - check=False, |
349 | | - timeout=30, |
350 | | - ) # nosec B603 - argv is passed shell-free and fallback executable is explicit |
351 | | - argv = fallback_argv |
352 | | - except FileNotFoundError as fallback_ex: |
353 | | - raise ExecutableNotFoundError( |
354 | | - "Unable to find nitlsconfig executable. " |
355 | | - f"Tried {executable!r} and {NITLSCONFIG_CLI_ENV_VAR}={fallback_root!r}." |
356 | | - ) from fallback_ex |
357 | | - else: |
358 | | - raise ExecutableNotFoundError( |
359 | | - "Unable to find nitlsconfig executable. " f"Tried {executable!r}." |
360 | | - ) from ex |
| 332 | + raise ExecutableNotFoundError( |
| 333 | + "Unable to find nitlsconfig executable. " f"Tried {executable!r}." |
| 334 | + ) from ex |
361 | 335 |
|
362 | 336 | if completed.returncode != 0: |
363 | 337 | command_display = " ".join(argv) |
|
0 commit comments