The following issues were found

selfdrive/hardware/eon/androidd.py
1 issues
Unable to import 'psutil'
Error

Line: 4 Column: 1

              #!/usr/bin/env python3
import os
import time
import psutil
from typing import Optional

from common.realtime import set_core_affinity, set_realtime_priority
from selfdrive.swaglog import cloudlog


            

Reported by Pylint.

selfdrive/hardware/tici/amplifier.py
1 issues
Unable to import 'smbus2'
Error

Line: 2 Column: 1

              #!/usr/bin/env python
from smbus2 import SMBus
from collections import namedtuple

# https://datasheets.maximintegrated.com/en/ds/MAX98089.pdf

AmpConfig = namedtuple('AmpConfig', ['name', 'value', 'register', 'offset', 'mask'])
EQParams = namedtuple('EQParams', ['K', 'k1', 'k2', 'c1', 'c2'])


            

Reported by Pylint.

selfdrive/loggerd/tests/loggerd_tests_common.py
1 issues
Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

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

                  uploader.fake_upload = True
    uploader.force_wifi = True
    uploader.allow_sleep = False
    self.seg_num = random.randint(1, 300)
    self.seg_format = "2019-04-18--12-52-54--{}"
    self.seg_format2 = "2019-05-18--11-22-33--{}"
    self.seg_dir = self.seg_format.format(self.seg_num)

  def tearDown(self):

            

Reported by Bandit.

selfdrive/loggerd/tests/test_uploader.py
1 issues
Try, Except, Pass detected.
Security

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

                      self.upload_order.append(j["key"])
      if j["event"] == "upload_ignored":
        self.upload_ignored.append(j["key"])
    except Exception:
      pass

log_handler = TestLogHandler()
cloudlog.addHandler(log_handler)


            

Reported by Bandit.

selfdrive/modeld/test/snpe_benchmark/benchmark.cc
1 issues
Resource leak: pFile
Error

Line: 105 CWE codes: 775

                fread(frame_buffer, length, 1, pFile);
  // std::cout << *(frame_buffer+length/4-1) << std::endl;
  std::copy(frame_buffer, frame_buffer+(length/4), input->begin());
}

void SaveITensor(const std::string& path, const zdl::DlSystem::ITensor* tensor)
{
   std::ofstream os(path, std::ofstream::binary);
   if (!os)

            

Reported by Cppcheck.

selfdrive/swaglog.py
1 issues
Unable to import 'zmq'
Error

Line: 7 Column: 1

              from pathlib import Path
from logging.handlers import BaseRotatingHandler

import zmq

from common.logging_extra import SwagLogger, SwagFormatter, SwagLogFileFormatter
from selfdrive.hardware import PC

if PC:

            

Reported by Pylint.

selfdrive/test/process_replay/test_processes.py
1 issues
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

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

                if FULL_TEST:
    tested_cars = set(c.lower() for c, _ in segments)
    untested = (set(interface_names) - set(excluded_interfaces)) - tested_cars
    assert len(untested) == 0, "Cars missing routes: %s" % (str(untested))

  results: Any = {}
  for car_brand, segment in segments:
    if (cars_whitelisted and car_brand.upper() not in args.whitelist_cars) or \
       (not cars_whitelisted and car_brand.upper() in args.blacklist_cars):

            

Reported by Bandit.

selfdrive/test/profiling/profiler.py
1 issues
No name 'car' in module 'cereal'
Error

Line: 8 Column: 1

              import pprofile  # pylint: disable=import-error
import pyprof2calltree  # pylint: disable=import-error

from cereal import car
from common.params import Params
from tools.lib.logreader import LogReader
from selfdrive.test.profiling.lib import SubMaster, PubMaster, SubSocket, ReplayDone
from selfdrive.test.process_replay.process_replay import CONFIGS
from selfdrive.car.toyota.values import CAR as TOYOTA

            

Reported by Pylint.

selfdrive/ui/qt/setup/installer.cc
1 issues
Subtracting pointers that point to different objects
Error

Line: 190 CWE codes: 570

                FILE *of = fopen("/data/continue.sh.new", "wb");
  assert(of != NULL);

  size_t num = str_continue_end - str_continue;
  size_t num_written = fwrite(str_continue, 1, num, of);
  assert(num == num_written);
  fclose(of);

  run("chmod +x /data/continue.sh.new");

            

Reported by Cppcheck.

tools/lib/auth_config.py
1 issues
Probable insecure usage of temp file/directory.
Security

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

              if PC:
  CONFIG_DIR = os.path.expanduser('~/.comma')
else:
  CONFIG_DIR = "/tmp/.comma"

mkdirs_exists_ok(CONFIG_DIR)


def get_token():

            

Reported by Bandit.