The following issues were found

tools/lib/tests/test_readers.py
2 issues
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

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

              
      print(frame_15[0])

      assert np.all(frame_first_30[0] == frame_0[0])
      assert np.all(frame_first_30[15] == frame_15[0])

    with tempfile.NamedTemporaryFile(suffix=".hevc") as fp:
      r = requests.get("https://github.com/commaai/comma2k19/blob/master/Example_1/b0c9d2329ad1606b%7C2018-08-02--08-34-47/40/video.hevc?raw=true")
      fp.write(r.content)

            

Reported by Bandit.

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

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

                    print(frame_15[0])

      assert np.all(frame_first_30[0] == frame_0[0])
      assert np.all(frame_first_30[15] == frame_15[0])

    with tempfile.NamedTemporaryFile(suffix=".hevc") as fp:
      r = requests.get("https://github.com/commaai/comma2k19/blob/master/Example_1/b0c9d2329ad1606b%7C2018-08-02--08-34-47/40/video.hevc?raw=true")
      fp.write(r.content)
      fp.flush()

            

Reported by Bandit.

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

Line: 4 Column: 1

              #!/usr/bin/env python3
import traceback

import cereal.messaging as messaging
from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery
from selfdrive.swaglog import cloudlog

EXT_DIAG_REQUEST = b'\x10\x03'
EXT_DIAG_RESPONSE = b'\x50\x03'

            

Reported by Pylint.

No name 'messaging' in module 'cereal'
Error

Line: 4 Column: 1

              #!/usr/bin/env python3
import traceback

import cereal.messaging as messaging
from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery
from selfdrive.swaglog import cloudlog

EXT_DIAG_REQUEST = b'\x10\x03'
EXT_DIAG_RESPONSE = b'\x50\x03'

            

Reported by Pylint.

common/file_helpers.py
2 issues
Unable to import 'atomicwrites'
Error

Line: 4 Column: 1

              import os
import shutil
import tempfile
from atomicwrites import AtomicWriter


def mkdirs_exists_ok(path):
  if path.startswith('http://') or path.startswith('https://'):
    raise ValueError('URL path')

            

Reported by Pylint.

Probable insecure usage of temp file/directory.
Security

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

                  return "/scratch/tmp"
  elif len(parts) > 2 and parts[2] == "runner":
    return "/{}/runner/tmp".format(parts[1])
  return "/tmp"


class AutoMoveTempdir():
  def __init__(self, target_path, temp_dir=None):
    self._target_path = target_path

            

Reported by Bandit.

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

Line: 5 Column: 1

              import argparse
import json

import cereal.messaging as messaging
from tools.lib.logreader import LogReader
from tools.lib.route import Route

LEVELS = {
  "DEBUG": 10,

            

Reported by Pylint.

Unable to import 'cereal.messaging'
Error

Line: 5 Column: 1

              import argparse
import json

import cereal.messaging as messaging
from tools.lib.logreader import LogReader
from tools.lib.route import Route

LEVELS = {
  "DEBUG": 10,

            

Reported by Pylint.

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

Line: 13 Column: 1

              # - since some messages are published at low frequency, keep this script running for at least 30s,
#   until all messages are received at least once

import cereal.messaging as messaging

logcan = messaging.sub_sock('can')
msgs = {}
while True:
  lc = messaging.recv_sock(logcan, True)

            

Reported by Pylint.

No name 'messaging' in module 'cereal'
Error

Line: 13 Column: 1

              # - since some messages are published at low frequency, keep this script running for at least 30s,
#   until all messages are received at least once

import cereal.messaging as messaging

logcan = messaging.sub_sock('can')
msgs = {}
while True:
  lc = messaging.recv_sock(logcan, True)

            

Reported by Pylint.

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

Line: 3 Column: 1

              #!/usr/bin/env python3
import time
import cereal.messaging as messaging


if __name__ == "__main__":
  sm = messaging.SubMaster(['deviceState', 'pandaState', 'modelV2', 'liveCalibration', 'driverMonitoringState', 'longitudinalPlan', 'lateralPlan'])

  i = 0

            

Reported by Pylint.

Unable to import 'cereal.messaging'
Error

Line: 3 Column: 1

              #!/usr/bin/env python3
import time
import cereal.messaging as messaging


if __name__ == "__main__":
  sm = messaging.SubMaster(['deviceState', 'pandaState', 'modelV2', 'liveCalibration', 'driverMonitoringState', 'longitudinalPlan', 'lateralPlan'])

  i = 0

            

Reported by Pylint.

tools/lib/logreader.py
2 issues
Unable to import 'capnp'
Error

Line: 6 Column: 1

              import sys
import bz2
import urllib.parse
import capnp

try:
  from xx.chffr.lib.filereader import FileReader
except ImportError:
  from tools.lib.filereader import FileReader

            

Reported by Pylint.

No name 'log' in module 'cereal'
Error

Line: 12 Column: 1

                from xx.chffr.lib.filereader import FileReader
except ImportError:
  from tools.lib.filereader import FileReader
from cereal import log as capnp_log

# this is an iterator itself, and uses private variables from LogReader
class MultiLogIterator(object):
  def __init__(self, log_paths, wraparound=True):
    self._log_paths = log_paths

            

Reported by Pylint.

selfdrive/debug/internal/fuzz_fw_fingerprint.py
2 issues
Unable to import 'tqdm'
Error

Line: 6 Column: 1

              import random
from collections import defaultdict

from tqdm import tqdm

from selfdrive.car.fw_versions import match_fw_to_car_fuzzy
from selfdrive.car.toyota.values import FW_VERSIONS as TOYOTA_FW_VERSIONS
from selfdrive.car.honda.values import FW_VERSIONS as HONDA_FW_VERSIONS
from selfdrive.car.hyundai.values import FW_VERSIONS as HYUNDAI_FW_VERSIONS

            

Reported by Pylint.

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

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

                  for candidate, fws in FWS.items():
      fw_dict = {}
      for (tp, addr, subaddr), fw_list in fws.items():
        fw_dict[(addr, subaddr)] = random.choice(fw_list)

      matches = match_fw_to_car_fuzzy(fw_dict, log=False, exclude=candidate)

      total += 1
      if len(matches) == 1:

            

Reported by Bandit.

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

Line: 2 Column: 1

              #!/usr/bin/env python3
import cereal.messaging as messaging

if __name__ == "__main__":
  modeld_sock = messaging.sub_sock("modelV2")

  last_frame_id = None
  start_t = None
  frame_cnt = 0

            

Reported by Pylint.

Unable to import 'cereal.messaging'
Error

Line: 2 Column: 1

              #!/usr/bin/env python3
import cereal.messaging as messaging

if __name__ == "__main__":
  modeld_sock = messaging.sub_sock("modelV2")

  last_frame_id = None
  start_t = None
  frame_cnt = 0

            

Reported by Pylint.

tools/zookeeper/enable_and_wait.py
1 issues
Starting a process with a shell, possible injection detected, security issue.
Security injection

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

              z.set_device_power(True)

def is_online(ip):
  return (os.system(f"ping -c 1 {ip} > /dev/null") == 0)

ip = str(sys.argv[1])
timeout = int(sys.argv[2])
start_time = time.time()
while not is_online(ip):

            

Reported by Bandit.