The following issues were found

pyextra/acados_template/generate_c_code_external_cost.py
14 issues
Unable to import 'casadi'
Error

Line: 35 Column: 1

              #

import os
from casadi import SX, MX, Function, transpose, vertcat, horzcat, hessian, CasadiMeta
from .utils import ALLOWED_CASADI_VERSIONS, casadi_version_warning


def generate_c_code_external_cost(model, stage_type, opts):


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 36 Column: 1

              
import os
from casadi import SX, MX, Function, transpose, vertcat, horzcat, hessian, CasadiMeta
from .utils import ALLOWED_CASADI_VERSIONS, casadi_version_warning


def generate_c_code_external_cost(model, stage_type, opts):

    casadi_version = CasadiMeta.version()

            

Reported by Pylint.

Unused transpose imported from casadi
Error

Line: 35 Column: 1

              #

import os
from casadi import SX, MX, Function, transpose, vertcat, horzcat, hessian, CasadiMeta
from .utils import ALLOWED_CASADI_VERSIONS, casadi_version_warning


def generate_c_code_external_cost(model, stage_type, opts):


            

Reported by Pylint.

Unused horzcat imported from casadi
Error

Line: 35 Column: 1

              #

import os
from casadi import SX, MX, Function, transpose, vertcat, horzcat, hessian, CasadiMeta
from .utils import ALLOWED_CASADI_VERSIONS, casadi_version_warning


def generate_c_code_external_cost(model, stage_type, opts):


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #
# Copyright 2019 Gianluca Frison, Dimitris Kouzoupis, Robin Verschueren,
# Andrea Zanelli, Niels van Duijkeren, Jonathan Frey, Tommaso Sartor,
# Branimir Novoselnik, Rien Quirynen, Rezart Qelibari, Dang Doan,
# Jonas Koenemann, Yutao Chen, Tobias Schöls, Jonas Schlagenhauf, Moritz Diehl
#
# This file is part of acados.
#
# The 2-Clause BSD License

            

Reported by Pylint.

Too many local variables (25/15)
Error

Line: 39 Column: 1

              from .utils import ALLOWED_CASADI_VERSIONS, casadi_version_warning


def generate_c_code_external_cost(model, stage_type, opts):

    casadi_version = CasadiMeta.version()
    casadi_opts = dict(mex=False, casadi_int="int", casadi_real="double")

    if casadi_version not in (ALLOWED_CASADI_VERSIONS):

            

Reported by Pylint.

Useless return at end of function or method
Error

Line: 39 Column: 1

              from .utils import ALLOWED_CASADI_VERSIONS, casadi_version_warning


def generate_c_code_external_cost(model, stage_type, opts):

    casadi_version = CasadiMeta.version()
    casadi_opts = dict(mex=False, casadi_int="int", casadi_real="double")

    if casadi_version not in (ALLOWED_CASADI_VERSIONS):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 1

              from .utils import ALLOWED_CASADI_VERSIONS, casadi_version_warning


def generate_c_code_external_cost(model, stage_type, opts):

    casadi_version = CasadiMeta.version()
    casadi_opts = dict(mex=False, casadi_int="int", casadi_real="double")

    if casadi_version not in (ALLOWED_CASADI_VERSIONS):

            

Reported by Pylint.

Unnecessary parens after 'in' keyword
Error

Line: 44 Column: 1

                  casadi_version = CasadiMeta.version()
    casadi_opts = dict(mex=False, casadi_int="int", casadi_real="double")

    if casadi_version not in (ALLOWED_CASADI_VERSIONS):
        casadi_version_warning(casadi_version)

    x = model.x
    p = model.p


            

Reported by Pylint.

Variable name "x" doesn't conform to snake_case naming style
Error

Line: 47 Column: 5

                  if casadi_version not in (ALLOWED_CASADI_VERSIONS):
        casadi_version_warning(casadi_version)

    x = model.x
    p = model.p

    if isinstance(x, MX):
        symbol = MX.sym
    else:

            

Reported by Pylint.

selfdrive/test/test_updated.py
14 issues
subprocess call with shell=True identified, security issue.
Security injection

Line: 78
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

                    cmd = (cmd,)

    for c in cmd:
      subprocess.check_output(c, cwd=cwd, shell=True)

  def _get_updated_proc(self):
    os.environ["PYTHONPATH"] = self.basedir
    os.environ["GIT_AUTHOR_NAME"] = "testy tester"
    os.environ["GIT_COMMITTER_NAME"] = "testy tester"

            

Reported by Bandit.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 9
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              import unittest
import shutil
import signal
import subprocess
import random

from common.basedir import BASEDIR
from common.params import Params


            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 33
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

                  self.neos_version = os.path.join(org_dir, "neos_version")
    self.neosupdate_dir = os.path.join(org_dir, "neosupdate")
    with open(self.neos_version, "w") as f:
      v = subprocess.check_output(r"bash -c 'source launch_env.sh && echo $REQUIRED_NEOS_VERSION'",
                                  cwd=BASEDIR, shell=True, encoding='utf8').strip()
      f.write(v)

    self.upper_dir = os.path.join(self.staging_dir, "upper")
    self.merged_dir = os.path.join(self.staging_dir, "merged")

            

Reported by Bandit.

subprocess call with shell=True seems safe, but may be changed in the future, consider rewriting without shell
Security injection

Line: 34
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

                  self.neosupdate_dir = os.path.join(org_dir, "neosupdate")
    with open(self.neos_version, "w") as f:
      v = subprocess.check_output(r"bash -c 'source launch_env.sh && echo $REQUIRED_NEOS_VERSION'",
                                  cwd=BASEDIR, shell=True, encoding='utf8').strip()
      f.write(v)

    self.upper_dir = os.path.join(self.staging_dir, "upper")
    self.merged_dir = os.path.join(self.staging_dir, "merged")
    self.finalized_dir = os.path.join(self.staging_dir, "finalized")

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 42
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

                  self.finalized_dir = os.path.join(self.staging_dir, "finalized")

    # setup local submodule remotes
    submodules = subprocess.check_output("git submodule --quiet foreach 'echo $name'",
                                         shell=True, cwd=BASEDIR, encoding='utf8').split()
    for s in submodules:
      sub_path = os.path.join(org_dir, s.split("_repo")[0])
      self._run(f"git clone {s} {sub_path}.git", cwd=BASEDIR)


            

Reported by Bandit.

subprocess call with shell=True seems safe, but may be changed in the future, consider rewriting without shell
Security injection

Line: 43
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              
    # setup local submodule remotes
    submodules = subprocess.check_output("git submodule --quiet foreach 'echo $name'",
                                         shell=True, cwd=BASEDIR, encoding='utf8').split()
    for s in submodules:
      sub_path = os.path.join(org_dir, s.split("_repo")[0])
      self._run(f"git clone {s} {sub_path}.git", cwd=BASEDIR)

    # setup two git repos, a remote and one we'll run updated in

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 92
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                  os.environ["UPDATER_NEOS_VERSION"] = self.neos_version
    os.environ["UPDATER_NEOSUPDATE_DIR"] = self.neosupdate_dir
    updated_path = os.path.join(self.basedir, "selfdrive/updated.py")
    return subprocess.Popen(updated_path, env=os.environ)

  def _start_updater(self, offroad=True, nosleep=False):
    self.params.put_bool("IsOffroad", offroad)
    self.updated_proc = self._get_updated_proc()
    if not nosleep:

            

Reported by Bandit.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 136
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                  # make a new dir and some new files
    new_dir = os.path.join(self.git_remote_dir, "this_is_a_new_dir")
    os.mkdir(new_dir)
    for _ in range(random.randrange(5, 30)):
      for d in (new_dir, random.choice(all_dirs)):
        with tempfile.NamedTemporaryFile(dir=d, delete=False) as f:
          f.write(os.urandom(random.randrange(1, 1000000)))

    # modify some files

            

Reported by Bandit.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 137
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                  new_dir = os.path.join(self.git_remote_dir, "this_is_a_new_dir")
    os.mkdir(new_dir)
    for _ in range(random.randrange(5, 30)):
      for d in (new_dir, random.choice(all_dirs)):
        with tempfile.NamedTemporaryFile(dir=d, delete=False) as f:
          f.write(os.urandom(random.randrange(1, 1000000)))

    # modify some files
    for f in random.sample(all_files, random.randrange(5, 50)):

            

Reported by Bandit.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 139
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                  for _ in range(random.randrange(5, 30)):
      for d in (new_dir, random.choice(all_dirs)):
        with tempfile.NamedTemporaryFile(dir=d, delete=False) as f:
          f.write(os.urandom(random.randrange(1, 1000000)))

    # modify some files
    for f in random.sample(all_files, random.randrange(5, 50)):
      with open(f, "w+") as ff:
        txt = ff.readlines()

            

Reported by Bandit.

selfdrive/debug/internal/sounds/test_sounds.py
14 issues
Unable to import 'common.basedir'
Error

Line: 7 Column: 1

              import subprocess
import time

from common.basedir import BASEDIR

if __name__ == "__main__":

  sound_dir = os.path.join(BASEDIR, "selfdrive/assets/sounds")
  sound_files = [f for f in os.listdir(sound_dir) if f.endswith(".wav")]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python3

import os
import subprocess
import time

from common.basedir import BASEDIR

if __name__ == "__main__":

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 4
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              #!/usr/bin/env python3

import os
import subprocess
import time

from common.basedir import BASEDIR

if __name__ == "__main__":

            

Reported by Bandit.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 11 Column: 1

              
if __name__ == "__main__":

  sound_dir = os.path.join(BASEDIR, "selfdrive/assets/sounds")
  sound_files = [f for f in os.listdir(sound_dir) if f.endswith(".wav")]

  play_sound = os.path.join(BASEDIR, "selfdrive/ui/test/play_sound")

  os.environ["LD_LIBRARY_PATH"] = ""

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 12 Column: 1

              if __name__ == "__main__":

  sound_dir = os.path.join(BASEDIR, "selfdrive/assets/sounds")
  sound_files = [f for f in os.listdir(sound_dir) if f.endswith(".wav")]

  play_sound = os.path.join(BASEDIR, "selfdrive/ui/test/play_sound")

  os.environ["LD_LIBRARY_PATH"] = ""


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 14 Column: 1

                sound_dir = os.path.join(BASEDIR, "selfdrive/assets/sounds")
  sound_files = [f for f in os.listdir(sound_dir) if f.endswith(".wav")]

  play_sound = os.path.join(BASEDIR, "selfdrive/ui/test/play_sound")

  os.environ["LD_LIBRARY_PATH"] = ""

  while True:
    for volume in range(10, 16):

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 16 Column: 1

              
  play_sound = os.path.join(BASEDIR, "selfdrive/ui/test/play_sound")

  os.environ["LD_LIBRARY_PATH"] = ""

  while True:
    for volume in range(10, 16):
      for sound in sound_files:
        p = subprocess.Popen([play_sound, os.path.join(sound_dir, sound), str(volume)])

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 18 Column: 1

              
  os.environ["LD_LIBRARY_PATH"] = ""

  while True:
    for volume in range(10, 16):
      for sound in sound_files:
        p = subprocess.Popen([play_sound, os.path.join(sound_dir, sound), str(volume)])
        time.sleep(1)
        p.terminate()

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 19 Column: 1

                os.environ["LD_LIBRARY_PATH"] = ""

  while True:
    for volume in range(10, 16):
      for sound in sound_files:
        p = subprocess.Popen([play_sound, os.path.join(sound_dir, sound), str(volume)])
        time.sleep(1)
        p.terminate()

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 20 Column: 1

              
  while True:
    for volume in range(10, 16):
      for sound in sound_files:
        p = subprocess.Popen([play_sound, os.path.join(sound_dir, sound), str(volume)])
        time.sleep(1)
        p.terminate()

            

Reported by Pylint.

selfdrive/debug/internal/sensor_test_bootloop.py
13 issues
Probable insecure usage of temp file/directory.
Security

Line: 13
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html

              # Required for sensord not to bus-error on startup
# commaai/cereal#22
try:
  os.mkdir("/dev/shm")
except FileExistsError:
  pass
except PermissionError:
  print("WARNING: failed to make /dev/shm")


            

Reported by Bandit.

Probable insecure usage of temp file/directory.
Security

Line: 20
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html

                print("WARNING: failed to make /dev/shm")

try:
  with open('/tmp/sensor-test-results.json', 'r') as infile:
    data = json.load(infile)
except Exception:
  data = {'sensor-pass': 0, 'sensor-fail': 0}

STARTUP_SCRIPT = "/data/data/com.termux/files/continue.sh"

            

Reported by Bandit.

Probable insecure usage of temp file/directory.
Security

Line: 45
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html

                data['sensor-fail'] += 1

  timestr = str(int(time.time()))
  with open('/tmp/dmesg-' + timestr + '.log', 'w') as dmesg_out:
    subprocess.call('dmesg', stdout=dmesg_out, shell=False)
  with open("/tmp/logcat-" + timestr + '.log', 'w') as logcat_out:
    subprocess.call(['logcat', '-d'], stdout=logcat_out, shell=False)

text += "Sensor pass history: " + str(data['sensor-pass']) + "\n"

            

Reported by Bandit.

Probable insecure usage of temp file/directory.
Security

Line: 47
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html

                timestr = str(int(time.time()))
  with open('/tmp/dmesg-' + timestr + '.log', 'w') as dmesg_out:
    subprocess.call('dmesg', stdout=dmesg_out, shell=False)
  with open("/tmp/logcat-" + timestr + '.log', 'w') as logcat_out:
    subprocess.call(['logcat', '-d'], stdout=logcat_out, shell=False)

text += "Sensor pass history: " + str(data['sensor-pass']) + "\n"
text += "Sensor fail history: " + str(data['sensor-fail']) + "\n"


            

Reported by Bandit.

Probable insecure usage of temp file/directory.
Security

Line: 55
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html

              
print(text)

with open('/tmp/sensor-test-results.json', 'w') as outfile:
  json.dump(data, outfile, indent=4)

with TextWindow(text) as status:
  for _ in range(100):
    if status.get_status() == 1:

            

Reported by Bandit.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 5
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              import sys
import os
import stat
import subprocess
import json
from common.text_window import TextWindow
import time

# Required for sensord not to bus-error on startup

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 35
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                sys.exit(-1)

sensord_env = {**os.environ, 'SENSOR_TEST': '1'}
process = subprocess.run("./sensord", cwd="/data/openpilot/selfdrive/sensord", env=sensord_env)  # pylint: disable=subprocess-run-check

if process.returncode == 40:
  text = "Current run: SUCCESS\n"
  data['sensor-pass'] += 1
else:

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 46
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

              
  timestr = str(int(time.time()))
  with open('/tmp/dmesg-' + timestr + '.log', 'w') as dmesg_out:
    subprocess.call('dmesg', stdout=dmesg_out, shell=False)
  with open("/tmp/logcat-" + timestr + '.log', 'w') as logcat_out:
    subprocess.call(['logcat', '-d'], stdout=logcat_out, shell=False)

text += "Sensor pass history: " + str(data['sensor-pass']) + "\n"
text += "Sensor fail history: " + str(data['sensor-fail']) + "\n"

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 46
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

              
  timestr = str(int(time.time()))
  with open('/tmp/dmesg-' + timestr + '.log', 'w') as dmesg_out:
    subprocess.call('dmesg', stdout=dmesg_out, shell=False)
  with open("/tmp/logcat-" + timestr + '.log', 'w') as logcat_out:
    subprocess.call(['logcat', '-d'], stdout=logcat_out, shell=False)

text += "Sensor pass history: " + str(data['sensor-pass']) + "\n"
text += "Sensor fail history: " + str(data['sensor-fail']) + "\n"

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 48
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                with open('/tmp/dmesg-' + timestr + '.log', 'w') as dmesg_out:
    subprocess.call('dmesg', stdout=dmesg_out, shell=False)
  with open("/tmp/logcat-" + timestr + '.log', 'w') as logcat_out:
    subprocess.call(['logcat', '-d'], stdout=logcat_out, shell=False)

text += "Sensor pass history: " + str(data['sensor-pass']) + "\n"
text += "Sensor fail history: " + str(data['sensor-fail']) + "\n"

print(text)

            

Reported by Bandit.

selfdrive/manager/process.py
12 issues
Unable to import 'setproctitle'
Error

Line: 9 Column: 1

              from abc import ABC, abstractmethod
from multiprocessing import Process

from setproctitle import setproctitle  # pylint: disable=no-name-in-module

import cereal.messaging as messaging
import selfdrive.crash as crash
from common.basedir import BASEDIR
from common.params import Params

            

Reported by Pylint.

Unable to import 'cereal.messaging'
Error

Line: 11 Column: 1

              
from setproctitle import setproctitle  # pylint: disable=no-name-in-module

import cereal.messaging as messaging
import selfdrive.crash as crash
from common.basedir import BASEDIR
from common.params import Params
from common.realtime import sec_since_boot
from selfdrive.swaglog import cloudlog

            

Reported by Pylint.

No name 'messaging' in module 'cereal'
Error

Line: 11 Column: 1

              
from setproctitle import setproctitle  # pylint: disable=no-name-in-module

import cereal.messaging as messaging
import selfdrive.crash as crash
from common.basedir import BASEDIR
from common.params import Params
from common.realtime import sec_since_boot
from selfdrive.swaglog import cloudlog

            

Reported by Pylint.

No name 'log' in module 'cereal'
Error

Line: 18 Column: 1

              from common.realtime import sec_since_boot
from selfdrive.swaglog import cloudlog
from selfdrive.hardware import HARDWARE
from cereal import log

WATCHDOG_FN = "/dev/shm/wd_"
ENABLE_WATCHDOG = os.getenv("NO_WATCHDOG") is None



            

Reported by Pylint.

Probable insecure usage of temp file/directory.
Security

Line: 20
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html

              from selfdrive.hardware import HARDWARE
from cereal import log

WATCHDOG_FN = "/dev/shm/wd_"
ENABLE_WATCHDOG = os.getenv("NO_WATCHDOG") is None


def launcher(proc):
  try:

            

Reported by Bandit.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 5
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              import os
import signal
import time
import subprocess
from abc import ABC, abstractmethod
from multiprocessing import Process

from setproctitle import setproctitle  # pylint: disable=no-name-in-module


            

Reported by Bandit.

Starting a process without a shell.
Security injection

Line: 49
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b606_start_process_with_no_shell.html

              def nativelauncher(pargs, cwd):
  # exec the process
  os.chdir(cwd)
  os.execvp(pargs[0], pargs)


def join_process(process, timeout):
  # Process().join(timeout) will hang due to a python 3 bug: https://bugs.python.org/issue28382
  # We have to poll the exitcode instead

            

Reported by Bandit.

Try, Except, Pass detected.
Security

Line: 92
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html

                  try:
      fn = WATCHDOG_FN + str(self.proc.pid)
      self.last_watchdog_time = int(open(fn).read())
    except Exception:
      pass

    dt = sec_since_boot() - self.last_watchdog_time / 1e9

    if dt > self.watchdog_max_dt:

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 129
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

              
          if self.proc.exitcode is None:
            cloudlog.critical(f"unkillable process {self.name} failed to die!")
            os.system("date >> /data/unkillable_reboot")
            os.sync()
            HARDWARE.reboot()
            raise RuntimeError
        else:
          cloudlog.info(f"killing {self.name} with SIGKILL")

            

Reported by Bandit.

Starting a process with a shell: Seems safe, but may be changed in the future, consider rewriting without shell
Security injection

Line: 129
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              
          if self.proc.exitcode is None:
            cloudlog.critical(f"unkillable process {self.name} failed to die!")
            os.system("date >> /data/unkillable_reboot")
            os.sync()
            HARDWARE.reboot()
            raise RuntimeError
        else:
          cloudlog.info(f"killing {self.name} with SIGKILL")

            

Reported by Bandit.

selfdrive/debug/internal/core_voltage_sweep.py
12 issues
Starting a process with a shell, possible injection detected, security issue.
Security injection

Line: 15
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              
if len(sys.argv) > 1:
  i = int(sys.argv[1])
  os.system("echo %d %d > /sys/kernel/debug/regulator/pm8994_s11/voltage" % (i,i))
  os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")
else:
  for i in range(900000, 465000, -10000):
    print("setting voltage to",i)
    os.system("echo %d %d > /sys/kernel/debug/regulator/pm8994_s11/voltage" % (i,i))

            

Reported by Bandit.

Starting a process with a shell, possible injection detected, security issue.
Security injection

Line: 20
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              else:
  for i in range(900000, 465000, -10000):
    print("setting voltage to",i)
    os.system("echo %d %d > /sys/kernel/debug/regulator/pm8994_s11/voltage" % (i,i))
    os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")
    time.sleep(1)


            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 7
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

              import time

print("starting at")
os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")
print("volts")

os.system("echo 99e8000.cpr3-ctrl > /sys/devices/soc/spm-regulator-10/regulator/regulator.56/99e8000.cpr3-ctrl-vdd/driver/unbind")
os.system("echo 1 > /sys/kernel/debug/regulator/pm8994_s11/enable")


            

Reported by Bandit.

Starting a process with a shell: Seems safe, but may be changed in the future, consider rewriting without shell
Security injection

Line: 7
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              import time

print("starting at")
os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")
print("volts")

os.system("echo 99e8000.cpr3-ctrl > /sys/devices/soc/spm-regulator-10/regulator/regulator.56/99e8000.cpr3-ctrl-vdd/driver/unbind")
os.system("echo 1 > /sys/kernel/debug/regulator/pm8994_s11/enable")


            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 10
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

              os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")
print("volts")

os.system("echo 99e8000.cpr3-ctrl > /sys/devices/soc/spm-regulator-10/regulator/regulator.56/99e8000.cpr3-ctrl-vdd/driver/unbind")
os.system("echo 1 > /sys/kernel/debug/regulator/pm8994_s11/enable")

if len(sys.argv) > 1:
  i = int(sys.argv[1])
  os.system("echo %d %d > /sys/kernel/debug/regulator/pm8994_s11/voltage" % (i,i))

            

Reported by Bandit.

Starting a process with a shell: Seems safe, but may be changed in the future, consider rewriting without shell
Security injection

Line: 10
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")
print("volts")

os.system("echo 99e8000.cpr3-ctrl > /sys/devices/soc/spm-regulator-10/regulator/regulator.56/99e8000.cpr3-ctrl-vdd/driver/unbind")
os.system("echo 1 > /sys/kernel/debug/regulator/pm8994_s11/enable")

if len(sys.argv) > 1:
  i = int(sys.argv[1])
  os.system("echo %d %d > /sys/kernel/debug/regulator/pm8994_s11/voltage" % (i,i))

            

Reported by Bandit.

Starting a process with a shell: Seems safe, but may be changed in the future, consider rewriting without shell
Security injection

Line: 11
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              print("volts")

os.system("echo 99e8000.cpr3-ctrl > /sys/devices/soc/spm-regulator-10/regulator/regulator.56/99e8000.cpr3-ctrl-vdd/driver/unbind")
os.system("echo 1 > /sys/kernel/debug/regulator/pm8994_s11/enable")

if len(sys.argv) > 1:
  i = int(sys.argv[1])
  os.system("echo %d %d > /sys/kernel/debug/regulator/pm8994_s11/voltage" % (i,i))
  os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 11
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

              print("volts")

os.system("echo 99e8000.cpr3-ctrl > /sys/devices/soc/spm-regulator-10/regulator/regulator.56/99e8000.cpr3-ctrl-vdd/driver/unbind")
os.system("echo 1 > /sys/kernel/debug/regulator/pm8994_s11/enable")

if len(sys.argv) > 1:
  i = int(sys.argv[1])
  os.system("echo %d %d > /sys/kernel/debug/regulator/pm8994_s11/voltage" % (i,i))
  os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")

            

Reported by Bandit.

Starting a process with a shell: Seems safe, but may be changed in the future, consider rewriting without shell
Security injection

Line: 16
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              if len(sys.argv) > 1:
  i = int(sys.argv[1])
  os.system("echo %d %d > /sys/kernel/debug/regulator/pm8994_s11/voltage" % (i,i))
  os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")
else:
  for i in range(900000, 465000, -10000):
    print("setting voltage to",i)
    os.system("echo %d %d > /sys/kernel/debug/regulator/pm8994_s11/voltage" % (i,i))
    os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 16
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

              if len(sys.argv) > 1:
  i = int(sys.argv[1])
  os.system("echo %d %d > /sys/kernel/debug/regulator/pm8994_s11/voltage" % (i,i))
  os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")
else:
  for i in range(900000, 465000, -10000):
    print("setting voltage to",i)
    os.system("echo %d %d > /sys/kernel/debug/regulator/pm8994_s11/voltage" % (i,i))
    os.system("cat /sys/kernel/debug/regulator/pm8994_s11/voltage")

            

Reported by Bandit.

selfdrive/boardd/tests/test_boardd_loopback.py
11 issues
No name 'messaging' in module 'cereal'
Error

Line: 8 Column: 1

              from collections import defaultdict
from functools import wraps

import cereal.messaging as messaging
from cereal import car
from common.basedir import BASEDIR
from common.params import Params
from common.spinner import Spinner
from common.timeout import Timeout

            

Reported by Pylint.

Unable to import 'cereal.messaging'
Error

Line: 8 Column: 1

              from collections import defaultdict
from functools import wraps

import cereal.messaging as messaging
from cereal import car
from common.basedir import BASEDIR
from common.params import Params
from common.spinner import Spinner
from common.timeout import Timeout

            

Reported by Pylint.

No name 'car' in module 'cereal'
Error

Line: 9 Column: 1

              from functools import wraps

import cereal.messaging as messaging
from cereal import car
from common.basedir import BASEDIR
from common.params import Params
from common.spinner import Spinner
from common.timeout import Timeout
from panda import Panda

            

Reported by Pylint.

No name 'Panda' in module 'panda'
Error

Line: 14 Column: 1

              from common.params import Params
from common.spinner import Spinner
from common.timeout import Timeout
from panda import Panda
from selfdrive.boardd.boardd import can_list_to_can_capnp
from selfdrive.car import make_can_msg
from selfdrive.test.helpers import with_processes



            

Reported by Pylint.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 64
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                  spinner.update(f"boardd loopback {i}/{n}")

    sent_msgs = defaultdict(set)
    for _ in range(random.randrange(10)):
      to_send = []
      for __ in range(random.randrange(100)):
        bus = random.randrange(3)
        addr = random.randrange(1, 1<<29)
        dat = bytes([random.getrandbits(8) for _ in range(random.randrange(1, 9))])

            

Reported by Bandit.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 66
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                  sent_msgs = defaultdict(set)
    for _ in range(random.randrange(10)):
      to_send = []
      for __ in range(random.randrange(100)):
        bus = random.randrange(3)
        addr = random.randrange(1, 1<<29)
        dat = bytes([random.getrandbits(8) for _ in range(random.randrange(1, 9))])
        sent_msgs[bus].add((addr, dat))
        to_send.append(make_can_msg(addr, dat, bus))

            

Reported by Bandit.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 67
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                  for _ in range(random.randrange(10)):
      to_send = []
      for __ in range(random.randrange(100)):
        bus = random.randrange(3)
        addr = random.randrange(1, 1<<29)
        dat = bytes([random.getrandbits(8) for _ in range(random.randrange(1, 9))])
        sent_msgs[bus].add((addr, dat))
        to_send.append(make_can_msg(addr, dat, bus))
      sendcan.send(can_list_to_can_capnp(to_send, msgtype='sendcan'))

            

Reported by Bandit.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 68
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                    to_send = []
      for __ in range(random.randrange(100)):
        bus = random.randrange(3)
        addr = random.randrange(1, 1<<29)
        dat = bytes([random.getrandbits(8) for _ in range(random.randrange(1, 9))])
        sent_msgs[bus].add((addr, dat))
        to_send.append(make_can_msg(addr, dat, bus))
      sendcan.send(can_list_to_can_capnp(to_send, msgtype='sendcan'))


            

Reported by Bandit.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 69
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                    for __ in range(random.randrange(100)):
        bus = random.randrange(3)
        addr = random.randrange(1, 1<<29)
        dat = bytes([random.getrandbits(8) for _ in range(random.randrange(1, 9))])
        sent_msgs[bus].add((addr, dat))
        to_send.append(make_can_msg(addr, dat, bus))
      sendcan.send(can_list_to_can_capnp(to_send, msgtype='sendcan'))

    max_recv = 10

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 81
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      for m in msg.can:
          if m.src >= 128:
            k = (m.address, m.dat)
            assert k in sent_msgs[m.src-128]
            sent_msgs[m.src-128].discard(k)
      max_recv -= 1

    # if a set isn't empty, messages got dropped
    for bus in range(3):

            

Reported by Bandit.

pyextra/acados_template/__init__.py
11 issues
Unable to import '__init__.acados_model'
Error

Line: 34 Column: 1

              # POSSIBILITY OF SUCH DAMAGE.;
#

from .acados_model import *
from .generate_c_code_explicit_ode import *
from .generate_c_code_implicit_ode import *
from .generate_c_code_constraint import *
from .generate_c_code_nls_cost import *
from .acados_ocp import *

            

Reported by Pylint.

Unable to import '__init__.generate_c_code_explicit_ode'
Error

Line: 35 Column: 1

              #

from .acados_model import *
from .generate_c_code_explicit_ode import *
from .generate_c_code_implicit_ode import *
from .generate_c_code_constraint import *
from .generate_c_code_nls_cost import *
from .acados_ocp import *
from .acados_sim import *

            

Reported by Pylint.

Unable to import '__init__.generate_c_code_implicit_ode'
Error

Line: 36 Column: 1

              
from .acados_model import *
from .generate_c_code_explicit_ode import *
from .generate_c_code_implicit_ode import *
from .generate_c_code_constraint import *
from .generate_c_code_nls_cost import *
from .acados_ocp import *
from .acados_sim import *
from .acados_ocp_solver import *

            

Reported by Pylint.

Unable to import '__init__.generate_c_code_constraint'
Error

Line: 37 Column: 1

              from .acados_model import *
from .generate_c_code_explicit_ode import *
from .generate_c_code_implicit_ode import *
from .generate_c_code_constraint import *
from .generate_c_code_nls_cost import *
from .acados_ocp import *
from .acados_sim import *
from .acados_ocp_solver import *
from .acados_sim_solver import *

            

Reported by Pylint.

Unable to import '__init__.generate_c_code_nls_cost'
Error

Line: 38 Column: 1

              from .generate_c_code_explicit_ode import *
from .generate_c_code_implicit_ode import *
from .generate_c_code_constraint import *
from .generate_c_code_nls_cost import *
from .acados_ocp import *
from .acados_sim import *
from .acados_ocp_solver import *
from .acados_sim_solver import *
from .utils import *

            

Reported by Pylint.

Unable to import '__init__.acados_ocp'
Error

Line: 39 Column: 1

              from .generate_c_code_implicit_ode import *
from .generate_c_code_constraint import *
from .generate_c_code_nls_cost import *
from .acados_ocp import *
from .acados_sim import *
from .acados_ocp_solver import *
from .acados_sim_solver import *
from .utils import *

            

Reported by Pylint.

Unable to import '__init__.acados_sim'
Error

Line: 40 Column: 1

              from .generate_c_code_constraint import *
from .generate_c_code_nls_cost import *
from .acados_ocp import *
from .acados_sim import *
from .acados_ocp_solver import *
from .acados_sim_solver import *
from .utils import *

            

Reported by Pylint.

Unable to import '__init__.acados_ocp_solver'
Error

Line: 41 Column: 1

              from .generate_c_code_nls_cost import *
from .acados_ocp import *
from .acados_sim import *
from .acados_ocp_solver import *
from .acados_sim_solver import *
from .utils import *

            

Reported by Pylint.

Unable to import '__init__.acados_sim_solver'
Error

Line: 42 Column: 1

              from .acados_ocp import *
from .acados_sim import *
from .acados_ocp_solver import *
from .acados_sim_solver import *
from .utils import *

            

Reported by Pylint.

Unable to import '__init__.utils'
Error

Line: 43 Column: 1

              from .acados_sim import *
from .acados_ocp_solver import *
from .acados_sim_solver import *
from .utils import *

            

Reported by Pylint.

selfdrive/hardware/tici/hardware.py
10 issues
Starting a process with a shell, possible injection detected, security issue.
Security injection

Line: 276
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

                  for i in range(5, 8):
      # TODO: fix permissions with udev
      val = "0" if powersave_enabled else "1"
      os.system(f"sudo su -c 'echo {val} > /sys/devices/system/cpu/cpu{i}/online'")

  def get_gpu_usage_percent(self):
    try:
      used, total = open('/sys/class/kgsl/kgsl-3d0/gpubusy').read().strip().split()
      return 100.0 * int(used) / int(total)

            

Reported by Bandit.

No name 'log' in module 'cereal'
Error

Line: 7 Column: 1

              import subprocess
from pathlib import Path

from cereal import log
from selfdrive.hardware.base import HardwareBase, ThermalConfig
from selfdrive.hardware.tici.amplifier import Amplifier
from selfdrive.hardware.tici import iwlist

NM = 'org.freedesktop.NetworkManager'

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 4
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              import os
from functools import cached_property
from enum import IntEnum
import subprocess
from pathlib import Path

from cereal import log
from selfdrive.hardware.base import HardwareBase, ThermalConfig
from selfdrive.hardware.tici.amplifier import Amplifier

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 77
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

                          open('/proc/asound/card0/state').read().strip() == 'ONLINE')

  def reboot(self, reason=None):
    subprocess.check_output(["sudo", "reboot"])

  def uninstall(self):
    Path("/data/__system_reset__").touch()
    os.sync()
    self.reboot()

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 77
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                          open('/proc/asound/card0/state').read().strip() == 'ONLINE')

  def reboot(self, reason=None):
    subprocess.check_output(["sudo", "reboot"])

  def uninstall(self):
    Path("/data/__system_reset__").touch()
    os.sync()
    self.reboot()

            

Reported by Bandit.

Try, Except, Pass detected.
Security

Line: 112
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html

                            return NetworkType.cell3G
            else:
              return NetworkType.cell2G
    except Exception:
      pass

    return NetworkType.none

  def get_modem(self):

            

Reported by Bandit.

Try, Except, Pass detected.
Security

Line: 214
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html

                      modem = self.get_modem()
        strength = int(modem.Get(MM_MODEM, 'SignalQuality', dbus_interface=DBUS_PROPS, timeout=TIMEOUT)[0])
        network_strength = self.parse_strength(strength)
    except Exception:
      pass

    return network_strength

  def get_modem_version(self):

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 254
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

              
  def shutdown(self):
    # Note that for this to work and have the device stay powered off, the panda needs to be in UsbPowerMode::CLIENT!
    os.system("sudo poweroff")

  def get_thermal_config(self):
    return ThermalConfig(cpu=((1, 2, 3, 4, 5, 6, 7, 8), 1000), gpu=((48,49), 1000), mem=(15, 1000), bat=(None, 1), ambient=(65, 1000))

  def set_screen_brightness(self, percentage):

            

Reported by Bandit.

Starting a process with a shell: Seems safe, but may be changed in the future, consider rewriting without shell
Security injection

Line: 254
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              
  def shutdown(self):
    # Note that for this to work and have the device stay powered off, the panda needs to be in UsbPowerMode::CLIENT!
    os.system("sudo poweroff")

  def get_thermal_config(self):
    return ThermalConfig(cpu=((1, 2, 3, 4, 5, 6, 7, 8), 1000), gpu=((48,49), 1000), mem=(15, 1000), bat=(None, 1), ambient=(65, 1000))

  def set_screen_brightness(self, percentage):

            

Reported by Bandit.

Try, Except, Pass detected.
Security

Line: 263
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html

                  try:
      with open("/sys/class/backlight/panel0-backlight/brightness", "w") as f:
        f.write(str(int(percentage * 10.23)))
    except Exception:
      pass

  def set_power_save(self, powersave_enabled):
    # amplifier, 100mW at idle
    self.amplifier.set_global_shutdown(amp_disabled=powersave_enabled)

            

Reported by Bandit.

selfdrive/test/test_models.py
10 issues
Unable to import 'parameterized'
Error

Line: 7 Column: 1

              import importlib
import unittest
from collections import defaultdict, Counter
from parameterized import parameterized_class

from cereal import log, car
from selfdrive.car.fingerprints import all_known_cars
from selfdrive.car.car_helpers import interfaces
from selfdrive.car.honda.values import HONDA_BOSCH

            

Reported by Pylint.

No name 'log' in module 'cereal'
Error

Line: 9 Column: 1

              from collections import defaultdict, Counter
from parameterized import parameterized_class

from cereal import log, car
from selfdrive.car.fingerprints import all_known_cars
from selfdrive.car.car_helpers import interfaces
from selfdrive.car.honda.values import HONDA_BOSCH
from selfdrive.car.honda.values import CAR as HONDA
from selfdrive.car.chrysler.values import CAR as CHRYSLER

            

Reported by Pylint.

No name 'car' in module 'cereal'
Error

Line: 9 Column: 1

              from collections import defaultdict, Counter
from parameterized import parameterized_class

from cereal import log, car
from selfdrive.car.fingerprints import all_known_cars
from selfdrive.car.car_helpers import interfaces
from selfdrive.car.honda.values import HONDA_BOSCH
from selfdrive.car.honda.values import CAR as HONDA
from selfdrive.car.chrysler.values import CAR as CHRYSLER

            

Reported by Pylint.

Unable to import 'panda.tests.safety'
Error

Line: 20 Column: 1

              from selfdrive.test.openpilotci import get_url
from tools.lib.logreader import LogReader

from panda.tests.safety import libpandasafety_py
from panda.tests.safety.common import package_can_msg

PandaType = log.PandaState.PandaType

ROUTES = {rt.car_fingerprint: rt.route for rt in routes}

            

Reported by Pylint.

No name 'tests' in module 'panda'
Error

Line: 20 Column: 1

              from selfdrive.test.openpilotci import get_url
from tools.lib.logreader import LogReader

from panda.tests.safety import libpandasafety_py
from panda.tests.safety.common import package_can_msg

PandaType = log.PandaState.PandaType

ROUTES = {rt.car_fingerprint: rt.route for rt in routes}

            

Reported by Pylint.

No name 'tests' in module 'panda'
Error

Line: 21 Column: 1

              from tools.lib.logreader import LogReader

from panda.tests.safety import libpandasafety_py
from panda.tests.safety.common import package_can_msg

PandaType = log.PandaState.PandaType

ROUTES = {rt.car_fingerprint: rt.route for rt in routes}


            

Reported by Pylint.

Unable to import 'panda.tests.safety.common'
Error

Line: 21 Column: 1

              from tools.lib.logreader import LogReader

from panda.tests.safety import libpandasafety_py
from panda.tests.safety.common import package_can_msg

PandaType = log.PandaState.PandaType

ROUTES = {rt.car_fingerprint: rt.route for rt in routes}


            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 71
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  CarInterface, CarController, CarState = interfaces[cls.car_model]

    cls.CP = CarInterface.get_params(cls.car_model, fingerprint, [])
    assert cls.CP

    cls.CI = CarInterface(cls.CP, CarController, CarState)
    assert cls.CI

  def test_car_params(self):

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 74
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  assert cls.CP

    cls.CI = CarInterface(cls.CP, CarController, CarState)
    assert cls.CI

  def test_car_params(self):
    if self.CP.dashcamOnly:
      self.skipTest("no need to check carParams for dashcamOnly")


            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 117
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  os.environ['NO_RADAR_SLEEP'] = "1"
    RadarInterface = importlib.import_module('selfdrive.car.%s.radar_interface' % self.CP.carName).RadarInterface
    RI = RadarInterface(self.CP)
    assert RI

    error_cnt = 0
    for msg in self.can_msgs:
      radar_data = RI.update((msg.as_builder().to_bytes(),))
      if radar_data is not None:

            

Reported by Bandit.