The following issues were found

selfdrive/manager/test/test_manager.py
2 issues
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

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

                    os.environ['PREPAREONLY'] = '1'
      manager.main()
      t = time.monotonic() - start
      assert t < MAX_STARTUP_TIME, f"startup took {t}s, expected <{MAX_STARTUP_TIME}s"

  # ensure all processes exit cleanly
  def test_clean_exit(self):
    manager.manager_prepare()


            

Reported by Bandit.

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

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

                    exit_codes = [0, 1]
      if managed_processes[p].sigkill:
        exit_codes = [-signal.SIGKILL]
      assert exit_code in exit_codes, f"{p} died with {exit_code}"


if __name__ == "__main__":
  unittest.main()

            

Reported by Bandit.

tools/replay/rqplot.py
2 issues
No name 'messaging' in module 'cereal'
Error

Line: 6 Column: 1

              import sys
import matplotlib.pyplot as plt
import numpy as np
import cereal.messaging as messaging
import time

# tool to plot one or more signals live. Call ex:
#./rqplot.py log.carState.vEgo log.carState.aEgo


            

Reported by Pylint.

Unable to import 'cereal.messaging'
Error

Line: 6 Column: 1

              import sys
import matplotlib.pyplot as plt
import numpy as np
import cereal.messaging as messaging
import time

# tool to plot one or more signals live. Call ex:
#./rqplot.py log.carState.vEgo log.carState.aEgo


            

Reported by Pylint.

selfdrive/locationd/models/gnss_kf.py
2 issues
Unable to import 'sympy'
Error

Line: 6 Column: 1

              from typing import List

import numpy as np
import sympy as sp

from rednose.helpers.ekf_sym import EKF_sym, gen_code
from selfdrive.locationd.models.constants import ObservationKind
from selfdrive.locationd.models.loc_kf import parse_pr, parse_prr


            

Reported by Pylint.

Unable to import 'rednose.helpers.ekf_sym'
Error

Line: 8 Column: 1

              import numpy as np
import sympy as sp

from rednose.helpers.ekf_sym import EKF_sym, gen_code
from selfdrive.locationd.models.constants import ObservationKind
from selfdrive.locationd.models.loc_kf import parse_pr, parse_prr


class States():

            

Reported by Pylint.

selfdrive/crash.py
2 issues
Unable to import 'sentry_sdk'
Error

Line: 5 Column: 1

              from selfdrive.swaglog import cloudlog
from selfdrive.version import version

import sentry_sdk
from sentry_sdk.integrations.threading import ThreadingIntegration

def capture_exception(*args, **kwargs) -> None:
  cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1))


            

Reported by Pylint.

Unable to import 'sentry_sdk.integrations.threading'
Error

Line: 6 Column: 1

              from selfdrive.version import version

import sentry_sdk
from sentry_sdk.integrations.threading import ThreadingIntegration

def capture_exception(*args, **kwargs) -> None:
  cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1))

  try:

            

Reported by Pylint.

selfdrive/debug/can_print_changes.py
2 issues
Unable to import 'cereal.messaging'
Error

Line: 6 Column: 1

              import sys
from collections import defaultdict

import cereal.messaging as messaging
from common.realtime import sec_since_boot


def can_printer(bus=0):
  """Collects messages and prints when a new bit transition is observed.

            

Reported by Pylint.

No name 'messaging' in module 'cereal'
Error

Line: 6 Column: 1

              import sys
from collections import defaultdict

import cereal.messaging as messaging
from common.realtime import sec_since_boot


def can_printer(bus=0):
  """Collects messages and prints when a new bit transition is observed.

            

Reported by Pylint.

selfdrive/debug/can_printer.py
2 issues
No name 'messaging' in module 'cereal'
Error

Line: 7 Column: 1

              import sys
from collections import defaultdict

import cereal.messaging as messaging
from common.realtime import sec_since_boot


def can_printer(bus=0, max_msg=None, addr="127.0.0.1"):
  logcan = messaging.sub_sock('can', addr=addr)

            

Reported by Pylint.

Unable to import 'cereal.messaging'
Error

Line: 7 Column: 1

              import sys
from collections import defaultdict

import cereal.messaging as messaging
from common.realtime import sec_since_boot


def can_printer(bus=0, max_msg=None, addr="127.0.0.1"):
  logcan = messaging.sub_sock('can', addr=addr)

            

Reported by Pylint.

selfdrive/debug/check_freq.py
2 issues
No name 'messaging' in module 'cereal'
Error

Line: 8 Column: 1

              import numpy as np
from collections import defaultdict, deque
from common.realtime import sec_since_boot
import cereal.messaging as messaging


if __name__ == "__main__":
  context = messaging.Context()
  poller = messaging.Poller()

            

Reported by Pylint.

Unable to import 'cereal.messaging'
Error

Line: 8 Column: 1

              import numpy as np
from collections import defaultdict, deque
from common.realtime import sec_since_boot
import cereal.messaging as messaging


if __name__ == "__main__":
  context = messaging.Context()
  poller = messaging.Poller()

            

Reported by Pylint.

selfdrive/boardd/set_time.py
2 issues
Starting a process with a shell, possible injection detected, security issue.
Security injection

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

                  panda_time = datetime.datetime(a[0], a[1], a[2], a[4], a[5], a[6])
    if panda_time > MIN_DATE:
      logger.info(f"adjusting time from '{sys_time}' to '{panda_time}'")
      os.system(f"TZ=UTC date -s '{panda_time}'")
  except Exception:
    logger.warn("Failed to fetch time from panda")

if __name__ == "__main__":
  import logging

            

Reported by Bandit.

Unable to import 'usb1'
Error

Line: 5 Column: 1

              import datetime
import os
import struct
import usb1

REQUEST_IN = usb1.ENDPOINT_IN | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE
MIN_DATE = datetime.datetime(year=2021, month=4, day=1)

def set_time(logger):

            

Reported by Pylint.

selfdrive/debug/check_timings.py
2 issues
No name 'messaging' in module 'cereal'
Error

Line: 8 Column: 1

              import numpy as np
from collections import defaultdict, deque

import cereal.messaging as messaging

socks = {s: messaging.sub_sock(s, conflate=False) for s in sys.argv[1:]}
ts = defaultdict(lambda: deque(maxlen=100))

if __name__ == "__main__":

            

Reported by Pylint.

Unable to import 'cereal.messaging'
Error

Line: 8 Column: 1

              import numpy as np
from collections import defaultdict, deque

import cereal.messaging as messaging

socks = {s: messaging.sub_sock(s, conflate=False) for s in sys.argv[1:]}
ts = defaultdict(lambda: deque(maxlen=100))

if __name__ == "__main__":

            

Reported by Pylint.

pyextra/acados_template/c_templates_tera/acados_sim_solver_sfun.in.c
2 issues
Unmatched '{'. Configuration: ''.
Error

Line: 61

              
    {# compute number of input ports #}
    {%- set n_inputs = 1 %}  {# x0 #}
    {%- if dims.nu > 0 %}  {# u0 -#}
        {%- set n_inputs = n_inputs + 1 -%}
    {%- endif %}
    {%- if dims.np > 0 %}  {# parameters #}
        {%- set n_inputs = n_inputs + 1 -%}
    {%- endif %}

            

Reported by Cppcheck.

Unmatched '{'. Configuration: 'MATLAB_MEX_FILE'.
Error

Line: 61

              
    {# compute number of input ports #}
    {%- set n_inputs = 1 %}  {# x0 #}
    {%- if dims.nu > 0 %}  {# u0 -#}
        {%- set n_inputs = n_inputs + 1 -%}
    {%- endif %}
    {%- if dims.np > 0 %}  {# parameters #}
        {%- set n_inputs = n_inputs + 1 -%}
    {%- endif %}

            

Reported by Cppcheck.