Skip to content

Commit

Permalink
Codacy issue: subprocess call - check for execution of untrusted input.
Browse files Browse the repository at this point in the history
  • Loading branch information
breyerml committed Feb 18, 2025
1 parent 778cc04 commit 00e8084
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions utility_scripts/plssvm_target_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import ctypes
from pathlib import Path
import subprocess
import shutil

# parse command line arguments
parser = argparse.ArgumentParser()
Expand All @@ -38,7 +39,10 @@ def cond_print(msg=""):
"sse4_2": False,
}

result = subprocess.run(["lscpu"], capture_output=True, text=True, check=True)
lscpu_path = shutil.which("lscpu") # finds the safe, absolute path
if not lscpu_path:
raise FileNotFoundError("lscpu not found on system!")
result = subprocess.run([lscpu_path], capture_output=True, text=True, check=True)
for simd_version in simd_version_support:
if simd_version in str(result.stdout):
simd_version_support[simd_version] = True
Expand Down Expand Up @@ -107,10 +111,13 @@ def cond_print(msg=""):
plssvm_target_platforms.append("amd:" + ",".join(set(amd_gpus)))

# Intel GPU information
intel_gpus = []
pci_entry = subprocess.run(["lspci", "-nn"], capture_output=True, text=True, check=True)
lspci_path = shutil.which("lspci") # finds the safe, absolute path
if not lspci_path:
raise FileNotFoundError("lspci not found on system!")
pci_entry = subprocess.run([lspci_path, "-nn"], capture_output=True, text=True, check=True)
output_lines = [line for line in pci_entry.stdout.splitlines() if "VGA" in line or "DISPLAY" in line]

intel_gpus = []
for vga in output_lines:
# check if the device is an Intel GPU
if "Intel" in vga:
Expand Down

0 comments on commit 00e8084

Please sign in to comment.