The following issues were found

collectors/python.d.plugin/bind_rndc/bind_rndc.chart.py
21 issues
Unable to import 'bases.FrameworkServices.SimpleService'
Error

Line: 10 Column: 1

              from collections import defaultdict
from subprocess import Popen

from bases.FrameworkServices.SimpleService import SimpleService
from bases.collection import find_binary

update_every = 30

ORDER = [

            

Reported by Pylint.

Unable to import 'bases.collection'
Error

Line: 11 Column: 1

              from subprocess import Popen

from bases.FrameworkServices.SimpleService import SimpleService
from bases.collection import find_binary

update_every = 30

ORDER = [
    'name_server_statistics',

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # -*- coding: utf-8 -*-
# Description: bind rndc netdata python.d module
# Author: ilyam8
# SPDX-License-Identifier: GPL-3.0-or-later

import os
from collections import defaultdict
from subprocess import Popen


            

Reported by Pylint.

Consider possible security implications associated with Popen module.
Security blacklist

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

              
import os
from collections import defaultdict
from subprocess import Popen

from bases.FrameworkServices.SimpleService import SimpleService
from bases.collection import find_binary

update_every = 30

            

Reported by Bandit.

Constant name "update_every" doesn't conform to UPPER_CASE naming style
Error

Line: 13 Column: 1

              from bases.FrameworkServices.SimpleService import SimpleService
from bases.collection import find_binary

update_every = 30

ORDER = [
    'name_server_statistics',
    'incoming_queries',
    'outgoing_queries',

            

Reported by Pylint.

Line too long (115/100)
Error

Line: 41 Column: 1

                          ['nms_dropped_queries', 'dropped_queries', 'incremental'],
        ]},
    'incoming_queries': {
        'options': [None, 'Incoming Queries', 'queries', 'incoming queries', 'bind_rndc.incoming_queries', 'line'],
        'lines': [
        ]},
    'outgoing_queries': {
        'options': [None, 'Outgoing Queries', 'queries', 'outgoing queries', 'bind_rndc.outgoing_queries', 'line'],
        'lines': [

            

Reported by Pylint.

Line too long (115/100)
Error

Line: 45 Column: 1

                      'lines': [
        ]},
    'outgoing_queries': {
        'options': [None, 'Outgoing Queries', 'queries', 'outgoing queries', 'bind_rndc.outgoing_queries', 'line'],
        'lines': [
        ]},
    'named_stats_size': {
        'options': [None, 'Named Stats File Size', 'MiB', 'file size', 'bind_rndc.stats_size', 'line'],
        'lines': [

            

Reported by Pylint.

Line too long (103/100)
Error

Line: 49 Column: 1

                      'lines': [
        ]},
    'named_stats_size': {
        'options': [None, 'Named Stats File Size', 'MiB', 'file size', 'bind_rndc.stats_size', 'line'],
        'lines': [
            ['stats_size', None, 'absolute', 1, 1 << 20]
        ]
    }
}

            

Reported by Pylint.

Missing class docstring
Error

Line: 90 Column: 1

              STATS = ['Name Server Statistics', 'Incoming Queries', 'Outgoing Queries']


class Service(SimpleService):
    def __init__(self, configuration=None, name=None):
        SimpleService.__init__(self, configuration=configuration, name=name)
        self.order = ORDER
        self.definitions = CHARTS
        self.named_stats_path = self.configuration.get('named_stats_path', '/var/log/bind/named.stats')

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 90 Column: 1

              STATS = ['Name Server Statistics', 'Incoming Queries', 'Outgoing Queries']


class Service(SimpleService):
    def __init__(self, configuration=None, name=None):
        SimpleService.__init__(self, configuration=configuration, name=name)
        self.order = ORDER
        self.definitions = CHARTS
        self.named_stats_path = self.configuration.get('named_stats_path', '/var/log/bind/named.stats')

            

Reported by Pylint.

collectors/proc.plugin/sys_fs_btrfs.c
20 issues
system - This causes a new program to execute and is difficult to use safely
Security

Line: 73 Column: 44 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

                  RRDSET *st_allocation_system;
    RRDDIM *rd_allocation_system_free;
    RRDDIM *rd_allocation_system_used;
    declare_btrfs_allocation_section_field(system, total_bytes)
    declare_btrfs_allocation_section_field(system, bytes_used)
    declare_btrfs_allocation_section_field(system, disk_total)
    declare_btrfs_allocation_section_field(system, disk_used)

    BTRFS_DISK *disks;

            

Reported by FlawFinder.

system - This causes a new program to execute and is difficult to use safely
Security

Line: 74 Column: 44 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

                  RRDDIM *rd_allocation_system_free;
    RRDDIM *rd_allocation_system_used;
    declare_btrfs_allocation_section_field(system, total_bytes)
    declare_btrfs_allocation_section_field(system, bytes_used)
    declare_btrfs_allocation_section_field(system, disk_total)
    declare_btrfs_allocation_section_field(system, disk_used)

    BTRFS_DISK *disks;


            

Reported by FlawFinder.

system - This causes a new program to execute and is difficult to use safely
Security

Line: 75 Column: 44 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

                  RRDDIM *rd_allocation_system_used;
    declare_btrfs_allocation_section_field(system, total_bytes)
    declare_btrfs_allocation_section_field(system, bytes_used)
    declare_btrfs_allocation_section_field(system, disk_total)
    declare_btrfs_allocation_section_field(system, disk_used)

    BTRFS_DISK *disks;

    struct btrfs_node *next;

            

Reported by FlawFinder.

system - This causes a new program to execute and is difficult to use safely
Security

Line: 76 Column: 44 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

                  declare_btrfs_allocation_section_field(system, total_bytes)
    declare_btrfs_allocation_section_field(system, bytes_used)
    declare_btrfs_allocation_section_field(system, disk_total)
    declare_btrfs_allocation_section_field(system, disk_used)

    BTRFS_DISK *disks;

    struct btrfs_node *next;
} BTRFS_NODE;

            

Reported by FlawFinder.

system - This causes a new program to execute and is difficult to use safely
Security

Line: 397 Column: 45 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

                      // --------------------------------------------------------------------
        // allocation/system

        init_btrfs_allocation_section_field(system, total_bytes);
        init_btrfs_allocation_section_field(system, bytes_used);
        init_btrfs_allocation_section_field(system, disk_total);
        init_btrfs_allocation_section_field(system, disk_used);



            

Reported by FlawFinder.

system - This causes a new program to execute and is difficult to use safely
Security

Line: 398 Column: 45 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

                      // allocation/system

        init_btrfs_allocation_section_field(system, total_bytes);
        init_btrfs_allocation_section_field(system, bytes_used);
        init_btrfs_allocation_section_field(system, disk_total);
        init_btrfs_allocation_section_field(system, disk_used);


        // --------------------------------------------------------------------

            

Reported by FlawFinder.

system - This causes a new program to execute and is difficult to use safely
Security

Line: 399 Column: 45 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

              
        init_btrfs_allocation_section_field(system, total_bytes);
        init_btrfs_allocation_section_field(system, bytes_used);
        init_btrfs_allocation_section_field(system, disk_total);
        init_btrfs_allocation_section_field(system, disk_used);


        // --------------------------------------------------------------------
        // find all disks related to this node

            

Reported by FlawFinder.

system - This causes a new program to execute and is difficult to use safely
Security

Line: 400 Column: 45 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

                      init_btrfs_allocation_section_field(system, total_bytes);
        init_btrfs_allocation_section_field(system, bytes_used);
        init_btrfs_allocation_section_field(system, disk_total);
        init_btrfs_allocation_section_field(system, disk_used);


        // --------------------------------------------------------------------
        // find all disks related to this node
        // and collect their sizes

            

Reported by FlawFinder.

system - This causes a new program to execute and is difficult to use safely
Security

Line: 501 Column: 60 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

                               || collect_btrfs_allocation_section_field(data, disk_used) != 0
                 || collect_btrfs_allocation_section_field(metadata, disk_total) != 0
                 || collect_btrfs_allocation_section_field(metadata, disk_used) != 0
                 || collect_btrfs_allocation_section_field(system, disk_total) != 0
                 || collect_btrfs_allocation_section_field(system, disk_used) != 0) {
                error("BTRFS: failed to collect physical disks allocation for '%s'", node->id);
                // make it refresh btrfs at the next iteration
                refresh_delta = refresh_every;
                continue;

            

Reported by FlawFinder.

system - This causes a new program to execute and is difficult to use safely
Security

Line: 502 Column: 60 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

                               || collect_btrfs_allocation_section_field(metadata, disk_total) != 0
                 || collect_btrfs_allocation_section_field(metadata, disk_used) != 0
                 || collect_btrfs_allocation_section_field(system, disk_total) != 0
                 || collect_btrfs_allocation_section_field(system, disk_used) != 0) {
                error("BTRFS: failed to collect physical disks allocation for '%s'", node->id);
                // make it refresh btrfs at the next iteration
                refresh_delta = refresh_every;
                continue;
            }

            

Reported by FlawFinder.

collectors/python.d.plugin/zscores/zscores.chart.py
19 issues
Unable to import 'pandas'
Error

Line: 11 Column: 1

              
import requests
import numpy as np
import pandas as pd

from bases.FrameworkServices.SimpleService import SimpleService
from netdata_pandas.data import get_data, get_allmetrics

priority = 60000

            

Reported by Pylint.

Unable to import 'bases.FrameworkServices.SimpleService'
Error

Line: 13 Column: 1

              import numpy as np
import pandas as pd

from bases.FrameworkServices.SimpleService import SimpleService
from netdata_pandas.data import get_data, get_allmetrics

priority = 60000
update_every = 5
disabled_by_default = True

            

Reported by Pylint.

Unable to import 'netdata_pandas.data'
Error

Line: 14 Column: 1

              import pandas as pd

from bases.FrameworkServices.SimpleService import SimpleService
from netdata_pandas.data import get_data, get_allmetrics

priority = 60000
update_every = 5
disabled_by_default = True


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # -*- coding: utf-8 -*-
# Description: zscores netdata python.d module
# Author: andrewm4894
# SPDX-License-Identifier: GPL-3.0-or-later

from datetime import datetime
import re

import requests

            

Reported by Pylint.

Constant name "priority" doesn't conform to UPPER_CASE naming style
Error

Line: 16 Column: 1

              from bases.FrameworkServices.SimpleService import SimpleService
from netdata_pandas.data import get_data, get_allmetrics

priority = 60000
update_every = 5
disabled_by_default = True

ORDER = [
    'z',

            

Reported by Pylint.

Constant name "update_every" doesn't conform to UPPER_CASE naming style
Error

Line: 17 Column: 1

              from netdata_pandas.data import get_data, get_allmetrics

priority = 60000
update_every = 5
disabled_by_default = True

ORDER = [
    'z',
    '3stddev'

            

Reported by Pylint.

Constant name "disabled_by_default" doesn't conform to UPPER_CASE naming style
Error

Line: 18 Column: 1

              
priority = 60000
update_every = 5
disabled_by_default = True

ORDER = [
    'z',
    '3stddev'
]

            

Reported by Pylint.

Missing class docstring
Error

Line: 37 Column: 1

              }


class Service(SimpleService):
    def __init__(self, configuration=None, name=None):
        SimpleService.__init__(self, configuration=configuration, name=name)
        self.host = self.configuration.get('host', '127.0.0.1:19999')
        self.charts_regex = re.compile(self.configuration.get('charts_regex', 'system.*'))
        self.charts_to_exclude = self.configuration.get('charts_to_exclude', '').split(',')

            

Reported by Pylint.

Too many instance attributes (19/7)
Error

Line: 37 Column: 1

              }


class Service(SimpleService):
    def __init__(self, configuration=None, name=None):
        SimpleService.__init__(self, configuration=configuration, name=name)
        self.host = self.configuration.get('host', '127.0.0.1:19999')
        self.charts_regex = re.compile(self.configuration.get('charts_regex', 'system.*'))
        self.charts_to_exclude = self.configuration.get('charts_to_exclude', '').split(',')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 65 Column: 5

                      self.df_std = pd.DataFrame()
        self.df_z_history = pd.DataFrame()

    def check(self):
        _ = get_allmetrics(self.host, self.charts_in_scope, wide=True, col_sep='.')
        return True

    def validate_charts(self, chart, data, algorithm='absolute', multiplier=1, divisor=1):
        """If dimension not in chart then add it.

            

Reported by Pylint.

collectors/python.d.plugin/litespeed/litespeed.chart.py
19 issues
Unable to import 'bases.FrameworkServices.SimpleService'
Error

Line: 11 Column: 1

              import re
from collections import namedtuple

from bases.FrameworkServices.SimpleService import SimpleService

update_every = 10

# charts order (can be overridden if you want less charts, or different order)
ORDER = [

            

Reported by Pylint.

Probable insecure usage of temp file/directory.
Security

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

                      SimpleService.__init__(self, configuration=configuration, name=name)
        self.order = ORDER
        self.definitions = CHARTS
        self.path = self.configuration.get('path', '/tmp/lshttpd/')
        self.files = list()

    def check(self):
        if not self.path:
            self.error('"path" not specified')

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              # -*- coding: utf-8 -*-
# Description: litespeed netdata python.d module
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later

import glob
import os
import re
from collections import namedtuple

            

Reported by Pylint.

Constant name "update_every" doesn't conform to UPPER_CASE naming style
Error

Line: 13 Column: 1

              
from bases.FrameworkServices.SimpleService import SimpleService

update_every = 10

# charts order (can be overridden if you want less charts, or different order)
ORDER = [
    'net_throughput_http',  # net throughput
    'net_throughput_https',  # net throughput

            

Reported by Pylint.

Line too long (106/100)
Error

Line: 46 Column: 1

                      ]
    },
    'connections_http': {
        'options': [None, 'Connections HTTP', 'conns', 'connections', 'litespeed.connections', 'stacked'],
        'lines': [
            ['conn_free', 'free', 'absolute'],
            ['conn_used', 'used', 'absolute']
        ]
    },

            

Reported by Pylint.

Line too long (107/100)
Error

Line: 53 Column: 1

                      ]
    },
    'connections_https': {
        'options': [None, 'Connections HTTPS', 'conns', 'connections', 'litespeed.connections', 'stacked'],
        'lines': [
            ['ssl_conn_free', 'free', 'absolute'],
            ['ssl_conn_used', 'used', 'absolute']
        ]
    },

            

Reported by Pylint.

Line too long (117/100)
Error

Line: 66 Column: 1

                      ]
    },
    'requests_processing': {
        'options': [None, 'Requests In Processing', 'requests', 'requests', 'litespeed.requests_processing', 'line'],
        'lines': [
            ['requests_processing', 'processing', 'absolute']
        ]
    },
    'pub_cache_hits': {

            

Reported by Pylint.

Class name "t" doesn't conform to PascalCase naming style
Error

Line: 91 Column: 1

                  }
}

t = namedtuple('T', ['key', 'id', 'mul'])

T = [
    t('BPS_IN', 'bps_in', 8),
    t('BPS_OUT', 'bps_out', 8),
    t('SSL_BPS_IN', 'ssl_bps_in', 8),

            

Reported by Pylint.

Missing class docstring
Error

Line: 128 Column: 1

              }


class Service(SimpleService):
    def __init__(self, configuration=None, name=None):
        SimpleService.__init__(self, configuration=configuration, name=name)
        self.order = ORDER
        self.definitions = CHARTS
        self.path = self.configuration.get('path', '/tmp/lshttpd/')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 136 Column: 5

                      self.path = self.configuration.get('path', '/tmp/lshttpd/')
        self.files = list()

    def check(self):
        if not self.path:
            self.error('"path" not specified')
            return False

        fs = glob.glob(os.path.join(self.path, '.rtreport*'))

            

Reported by Pylint.

collectors/python.d.plugin/python_modules/third_party/monotonic.py
19 issues
Using the global statement
Error

Line: 156 Column: 21

              
                def monotonic():
                    """Monotonic clock, cannot go backward."""
                    global get_tick_count_last_sample
                    global get_tick_count_wraparounds

                    with get_tick_count_lock:
                        current_sample = GetTickCount()
                        if current_sample < get_tick_count_last_sample:

            

Reported by Pylint.

Using the global statement
Error

Line: 157 Column: 21

                              def monotonic():
                    """Monotonic clock, cannot go backward."""
                    global get_tick_count_last_sample
                    global get_tick_count_wraparounds

                    with get_tick_count_lock:
                        current_sample = GetTickCount()
                        if current_sample < get_tick_count_last_sample:
                            get_tick_count_wraparounds += 1

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 198 Column: 13

              
        # Perform a sanity-check.
        if monotonic() - monotonic() > 0:
            raise ValueError('monotonic() is not monotonic!')

    except Exception as e:
        raise RuntimeError('no suitable implementation for this system: ' + repr(e))

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 201 Column: 9

                          raise ValueError('monotonic() is not monotonic!')

    except Exception as e:
        raise RuntimeError('no suitable implementation for this system: ' + repr(e))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 59 Column: 5

                  import threading


    def clock_clock_gettime_c_library():
        return ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True).clock_gettime


    def clock_clock_gettime_rt_library():
        return ctypes.CDLL(ctypes.util.find_library('rt'), use_errno=True).clock_gettime

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 63 Column: 5

                      return ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True).clock_gettime


    def clock_clock_gettime_rt_library():
        return ctypes.CDLL(ctypes.util.find_library('rt'), use_errno=True).clock_gettime


    def clock_clock_gettime_c_library_synology6():
        return ctypes.CDLL('/usr/lib/libc.so.6', use_errno=True).clock_gettime

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 67 Column: 5

                      return ctypes.CDLL(ctypes.util.find_library('rt'), use_errno=True).clock_gettime


    def clock_clock_gettime_c_library_synology6():
        return ctypes.CDLL('/usr/lib/libc.so.6', use_errno=True).clock_gettime


    def clock_clock_gettime_rt_library_synology6():
        return ctypes.CDLL('/usr/lib/librt.so.1', use_errno=True).clock_gettime

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 71 Column: 5

                      return ctypes.CDLL('/usr/lib/libc.so.6', use_errno=True).clock_gettime


    def clock_clock_gettime_rt_library_synology6():
        return ctypes.CDLL('/usr/lib/librt.so.1', use_errno=True).clock_gettime


    def clock_gettime_linux():
        # see https://github.com/netdata/netdata/issues/7976

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 75 Column: 5

                      return ctypes.CDLL('/usr/lib/librt.so.1', use_errno=True).clock_gettime


    def clock_gettime_linux():
        # see https://github.com/netdata/netdata/issues/7976
        order = [
            clock_clock_gettime_c_library,
            clock_clock_gettime_rt_library,
            clock_clock_gettime_c_library_synology6,

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 98 Column: 13

                          #  <https://developer.apple.com/library/mac/qa/qa1398/>
            libc = ctypes.CDLL('/usr/lib/libc.dylib', use_errno=True)

            class mach_timebase_info_data_t(ctypes.Structure):
                """System timebase info. Defined in <mach/mach_time.h>."""
                _fields_ = (('numer', ctypes.c_uint32),
                            ('denom', ctypes.c_uint32))

            mach_absolute_time = libc.mach_absolute_time

            

Reported by Pylint.

collectors/python.d.plugin/python_modules/urllib3/poolmanager.py
19 issues
Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              import functools
import logging

from ._collections import RecentlyUsedContainer
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool
from .connectionpool import port_by_scheme
from .exceptions import LocationValueError, MaxRetryError, ProxySchemeUnknown
from .packages.six.moves.urllib.parse import urljoin
from .request import RequestMethods

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              import logging

from ._collections import RecentlyUsedContainer
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool
from .connectionpool import port_by_scheme
from .exceptions import LocationValueError, MaxRetryError, ProxySchemeUnknown
from .packages.six.moves.urllib.parse import urljoin
from .request import RequestMethods
from .util.url import parse_url

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

              
from ._collections import RecentlyUsedContainer
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool
from .connectionpool import port_by_scheme
from .exceptions import LocationValueError, MaxRetryError, ProxySchemeUnknown
from .packages.six.moves.urllib.parse import urljoin
from .request import RequestMethods
from .util.url import parse_url
from .util.retry import Retry

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              from ._collections import RecentlyUsedContainer
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool
from .connectionpool import port_by_scheme
from .exceptions import LocationValueError, MaxRetryError, ProxySchemeUnknown
from .packages.six.moves.urllib.parse import urljoin
from .request import RequestMethods
from .util.url import parse_url
from .util.retry import Retry


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 11 Column: 1

              from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool
from .connectionpool import port_by_scheme
from .exceptions import LocationValueError, MaxRetryError, ProxySchemeUnknown
from .packages.six.moves.urllib.parse import urljoin
from .request import RequestMethods
from .util.url import parse_url
from .util.retry import Retry



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

              from .connectionpool import port_by_scheme
from .exceptions import LocationValueError, MaxRetryError, ProxySchemeUnknown
from .packages.six.moves.urllib.parse import urljoin
from .request import RequestMethods
from .util.url import parse_url
from .util.retry import Retry


__all__ = ['PoolManager', 'ProxyManager', 'proxy_from_url']

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 13 Column: 1

              from .exceptions import LocationValueError, MaxRetryError, ProxySchemeUnknown
from .packages.six.moves.urllib.parse import urljoin
from .request import RequestMethods
from .util.url import parse_url
from .util.retry import Retry


__all__ = ['PoolManager', 'ProxyManager', 'proxy_from_url']


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 14 Column: 1

              from .packages.six.moves.urllib.parse import urljoin
from .request import RequestMethods
from .util.url import parse_url
from .util.retry import Retry


__all__ = ['PoolManager', 'ProxyManager', 'proxy_from_url']



            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # SPDX-License-Identifier: MIT
from __future__ import absolute_import
import collections
import functools
import logging

from ._collections import RecentlyUsedContainer
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool
from .connectionpool import port_by_scheme

            

Reported by Pylint.

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

Line: 193 Column: 17

                          request_context.pop(key, None)

        if scheme == 'http':
            for kw in SSL_KEYWORDS:
                request_context.pop(kw, None)

        return pool_cls(host, port, **request_context)

    def clear(self):

            

Reported by Pylint.

libnetdata/log/log.c
19 issues
vprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 688 Column: 5 CWE codes: 134
Suggestion: Use a constant for the format specification

              
    va_start( args, fmt );
    printf("%s: %s DEBUG : %s : (%04lu@%-10.10s:%-15.15s): ", date, program_name, netdata_thread_tag(), line, file, function);
    vprintf(fmt, args);
    va_end( args );
    putchar('\n');

    if(output_log_syslog) {
        va_start( args, fmt );

            

Reported by FlawFinder.

vfprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 725 Column: 5 CWE codes: 134
Suggestion: Use a constant for the format specification

                  va_start( args, fmt );
    if(debug_flags) fprintf(stderr, "%s: %s INFO  : %s : (%04lu@%-10.10s:%-15.15s): ", date, program_name, netdata_thread_tag(), line, file, function);
    else            fprintf(stderr, "%s: %s INFO  : %s : ", date, program_name, netdata_thread_tag());
    vfprintf( stderr, fmt, args );
    va_end( args );

    fputc('\n', stderr);

    log_unlock();

            

Reported by FlawFinder.

vfprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 781 Column: 5 CWE codes: 134
Suggestion: Use a constant for the format specification

                  va_start( args, fmt );
    if(debug_flags) fprintf(stderr, "%s: %s %-5.5s : %s : (%04lu@%-10.10s:%-15.15s): ", date, program_name, prefix, netdata_thread_tag(), line, file, function);
    else            fprintf(stderr, "%s: %s %-5.5s : %s : ", date, program_name, prefix, netdata_thread_tag());
    vfprintf( stderr, fmt, args );
    va_end( args );

    if(__errno) {
        char buf[1024];
        fprintf(stderr, " (errno %d, %s)\n", __errno, strerror_result(strerror_r(__errno, buf, 1023), buf));

            

Reported by FlawFinder.

vfprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 824 Column: 5 CWE codes: 134
Suggestion: Use a constant for the format specification

                  va_start( args, fmt );
    if(debug_flags) fprintf(stderr, "%s: %s FATAL : %s : (%04lu@%-10.10s:%-15.15s): ", date, program_name, thread_tag, line, file, function);
    else            fprintf(stderr, "%s: %s FATAL : %s : ", date, program_name, thread_tag);
    vfprintf( stderr, fmt, args );
    va_end( args );

    perror(" # ");
    fputc('\n', stderr);


            

Reported by FlawFinder.

vfprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 865 Column: 9 CWE codes: 134
Suggestion: Use a constant for the format specification

                      fprintf(stdaccess, "%s: ", date);

        va_start( args, fmt );
        vfprintf( stdaccess, fmt, args );
        va_end( args );
        fputc('\n', stdaccess);

        if(web_server_is_multithreaded)
            netdata_mutex_unlock(&access_mutex);

            

Reported by FlawFinder.

open - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 512 Column: 13 CWE codes: 362

                      f = STDERR_FILENO;

    else {
        f = open(filename, O_WRONLY | O_APPEND | O_CREAT, 0664);
        if(f == -1) {
            error("Cannot open file '%s'. Leaving %d to its default.", filename, fd);
            if(fd_ptr) *fd_ptr = fd;
            return fp;
        }

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 608 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              
    if(reset) {
        if(prevented) {
            char date[LOG_DATE_LENGTH];
            log_date(date, LOG_DATE_LENGTH);
            fprintf(stderr, "%s: %s LOG FLOOD PROTECTION reset for process '%s' (prevented %lu logs in the last %ld seconds).\n"
                    , date
                    , program_name
                    , program_name

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 629 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              
    if(now - start > error_log_throttle_period) {
        if(prevented) {
            char date[LOG_DATE_LENGTH];
            log_date(date, LOG_DATE_LENGTH);
            fprintf(stderr, "%s: %s LOG FLOOD PROTECTION resuming logging from process '%s' (prevented %lu logs in the last %ld seconds).\n"
                    , date
                    , program_name
                    , program_name

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 651 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              
    if(counter > error_log_errors_per_period) {
        if(!prevented) {
            char date[LOG_DATE_LENGTH];
            log_date(date, LOG_DATE_LENGTH);
            fprintf(stderr, "%s: %s LOG FLOOD PROTECTION too many logs (%lu logs in %ld seconds, threshold is set to %lu logs in %ld seconds). Preventing more logs from process '%s' for %ld seconds.\n"
                    , date
                    , program_name
                    , counter

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 683 Column: 5 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              void debug_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) {
    va_list args;

    char date[LOG_DATE_LENGTH];
    log_date(date, LOG_DATE_LENGTH);

    va_start( args, fmt );
    printf("%s: %s DEBUG : %s : (%04lu@%-10.10s:%-15.15s): ", date, program_name, netdata_thread_tag(), line, file, function);
    vprintf(fmt, args);

            

Reported by FlawFinder.

libnetdata/circular_buffer/circular_buffer.c
19 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 32 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  if (buf->read == buf->write)
        buf->write = 0; // buffer is empty
    else if (buf->read < buf->write) {
        memcpy(new_data, buf->data + buf->read, buf->write - buf->read);
        buf->write -= buf->read;
    } else {
        size_t top_part = buf->size - buf->read;
        memcpy(new_data, buf->data + buf->read, top_part);
        memcpy(new_data + top_part, buf->data, buf->write);

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 36 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      buf->write -= buf->read;
    } else {
        size_t top_part = buf->size - buf->read;
        memcpy(new_data, buf->data + buf->read, top_part);
        memcpy(new_data + top_part, buf->data, buf->write);
        buf->write = top_part + buf->write;
    }
    buf->read = 0;


            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 37 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  } else {
        size_t top_part = buf->size - buf->read;
        memcpy(new_data, buf->data + buf->read, top_part);
        memcpy(new_data + top_part, buf->data, buf->write);
        buf->write = top_part + buf->write;
    }
    buf->read = 0;

    // Switch buffers

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 58 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  }
    // Guarantee: write + d_len cannot hit read
    if (buf->write + d_len < buf->size) {
        memcpy(buf->data + buf->write, d, d_len);
        buf->write += d_len;
    }
    else {
        size_t top_part = buf->size - buf->write;
        memcpy(buf->data + buf->write, d, top_part);

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 63 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  }
    else {
        size_t top_part = buf->size - buf->write;
        memcpy(buf->data + buf->write, d, top_part);
        memcpy(buf->data, d + top_part, d_len - top_part); 
        buf->write = d_len - top_part;
    }
    return 0;
}

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 64 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  else {
        size_t top_part = buf->size - buf->write;
        memcpy(buf->data + buf->write, d, top_part);
        memcpy(buf->data, d + top_part, d_len - top_part); 
        buf->write = d_len - top_part;
    }
    return 0;
}


            

Reported by FlawFinder.

read - Check buffer boundaries if used in a loop including recursive loops
Security

Line: 31 Column: 19 CWE codes: 120 20

                  char *new_data = mallocz(new_size);
    if (buf->read == buf->write)
        buf->write = 0; // buffer is empty
    else if (buf->read < buf->write) {
        memcpy(new_data, buf->data + buf->read, buf->write - buf->read);
        buf->write -= buf->read;
    } else {
        size_t top_part = buf->size - buf->read;
        memcpy(new_data, buf->data + buf->read, top_part);

            

Reported by FlawFinder.

read - Check buffer boundaries if used in a loop including recursive loops
Security

Line: 32 Column: 67 CWE codes: 120 20

                  if (buf->read == buf->write)
        buf->write = 0; // buffer is empty
    else if (buf->read < buf->write) {
        memcpy(new_data, buf->data + buf->read, buf->write - buf->read);
        buf->write -= buf->read;
    } else {
        size_t top_part = buf->size - buf->read;
        memcpy(new_data, buf->data + buf->read, top_part);
        memcpy(new_data + top_part, buf->data, buf->write);

            

Reported by FlawFinder.

read - Check buffer boundaries if used in a loop including recursive loops
Security

Line: 32 Column: 43 CWE codes: 120 20

                  if (buf->read == buf->write)
        buf->write = 0; // buffer is empty
    else if (buf->read < buf->write) {
        memcpy(new_data, buf->data + buf->read, buf->write - buf->read);
        buf->write -= buf->read;
    } else {
        size_t top_part = buf->size - buf->read;
        memcpy(new_data, buf->data + buf->read, top_part);
        memcpy(new_data + top_part, buf->data, buf->write);

            

Reported by FlawFinder.

read - Check buffer boundaries if used in a loop including recursive loops
Security

Line: 33 Column: 28 CWE codes: 120 20

                      buf->write = 0; // buffer is empty
    else if (buf->read < buf->write) {
        memcpy(new_data, buf->data + buf->read, buf->write - buf->read);
        buf->write -= buf->read;
    } else {
        size_t top_part = buf->size - buf->read;
        memcpy(new_data, buf->data + buf->read, top_part);
        memcpy(new_data + top_part, buf->data, buf->write);
        buf->write = top_part + buf->write;

            

Reported by FlawFinder.

collectors/python.d.plugin/freeradius/freeradius.chart.py
19 issues
Unable to import 'bases.FrameworkServices.SimpleService'
Error

Line: 9 Column: 1

              import re
from subprocess import Popen, PIPE

from bases.FrameworkServices.SimpleService import SimpleService
from bases.collection import find_binary

update_every = 15

PARSER = re.compile(r'((?<=-)[AP][a-zA-Z-]+) = (\d+)')

            

Reported by Pylint.

Unable to import 'bases.collection'
Error

Line: 10 Column: 1

              from subprocess import Popen, PIPE

from bases.FrameworkServices.SimpleService import SimpleService
from bases.collection import find_binary

update_every = 15

PARSER = re.compile(r'((?<=-)[AP][a-zA-Z-]+) = (\d+)')


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # -*- coding: utf-8 -*-
# Description: freeradius netdata python.d module
# Author: ilyam8
# SPDX-License-Identifier: GPL-3.0-or-later

import re
from subprocess import Popen, PIPE

from bases.FrameworkServices.SimpleService import SimpleService

            

Reported by Pylint.

Consider possible security implications associated with Popen module.
Security blacklist

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

              # SPDX-License-Identifier: GPL-3.0-or-later

import re
from subprocess import Popen, PIPE

from bases.FrameworkServices.SimpleService import SimpleService
from bases.collection import find_binary

update_every = 15

            

Reported by Bandit.

Constant name "update_every" doesn't conform to UPPER_CASE naming style
Error

Line: 12 Column: 1

              from bases.FrameworkServices.SimpleService import SimpleService
from bases.collection import find_binary

update_every = 15

PARSER = re.compile(r'((?<=-)[AP][a-zA-Z-]+) = (\d+)')

RADIUS_MSG = 'Message-Authenticator = 0x00, FreeRADIUS-Statistics-Type = 15, Response-Packet-Type = Access-Accept'


            

Reported by Pylint.

Line too long (114/100)
Error

Line: 16 Column: 1

              
PARSER = re.compile(r'((?<=-)[AP][a-zA-Z-]+) = (\d+)')

RADIUS_MSG = 'Message-Authenticator = 0x00, FreeRADIUS-Statistics-Type = 15, Response-Packet-Type = Access-Accept'

RADCLIENT_RETRIES = 1
RADCLIENT_TIMEOUT = 1

DEFAULT_HOST = 'localhost'

            

Reported by Pylint.

Line too long (111/100)
Error

Line: 60 Column: 1

                      ]
    },
    'proxy-auth': {
        'options': [None, 'Proxy Authentication', 'packets/s', 'authentication', 'freerad.proxy.auth', 'line'],
        'lines': [
            ['proxy-access-accepts', 'access-accepts', 'incremental'],
            ['proxy-access-rejects', 'access-rejects', 'incremental'],
            ['proxy-auth-dropped-requests', 'dropped-requests', 'incremental'],
            ['proxy-auth-duplicate-requests', 'duplicate-requests', 'incremental'],

            

Reported by Pylint.

Line too long (103/100)
Error

Line: 72 Column: 1

                      ]
    },
    'proxy-acct': {
        'options': [None, 'Proxy Accounting', 'packets/s', 'accounting', 'freerad.proxy.acct', 'line'],
        'lines': [
            ['proxy-accounting-requests', 'requests', 'incremental'],
            ['proxy-accounting-responses', 'responses', 'incremental'],
            ['proxy-acct-dropped-requests', 'dropped-requests', 'incremental'],
            ['proxy-acct-duplicate-requests', 'duplicate-requests', 'incremental'],

            

Reported by Pylint.

Too many arguments (6/5)
Error

Line: 86 Column: 1

              }


def radclient_status(radclient, retries, timeout, host, port, secret):
    # radclient -r 1 -t 1 -x 127.0.0.1:18121 status secret

    return '{radclient} -r {num_retries} -t {timeout} -x {host}:{port} status {secret}'.format(
        radclient=radclient,
        num_retries=retries,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 86 Column: 1

              }


def radclient_status(radclient, retries, timeout, host, port, secret):
    # radclient -r 1 -t 1 -x 127.0.0.1:18121 status secret

    return '{radclient} -r {num_retries} -t {timeout} -x {host}:{port} status {secret}'.format(
        radclient=radclient,
        num_retries=retries,

            

Reported by Pylint.

collectors/tc.plugin/plugin_tc.c
19 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 215 Column: 9 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                  }

    if(unlikely(d->enabled == (char)-1)) {
        char var_name[CONFIG_MAX_NAME + 1];
        snprintfz(var_name, CONFIG_MAX_NAME, "qos for %s", d->id);

        d->enabled                    = (char)config_get_boolean_ondemand("plugin:tc", var_name, enable_new_interfaces);

        snprintfz(var_name, CONFIG_MAX_NAME, "traffic chart for %s", d->id);

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 436 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                      d->enabled_packets = CONFIG_BOOLEAN_YES;

        if(unlikely(!d->st_packets)) {
            char id[RRD_ID_LENGTH_MAX + 1];
            char name[RRD_ID_LENGTH_MAX + 1];
            snprintfz(id, RRD_ID_LENGTH_MAX, "%s_packets", d->id);
            snprintfz(name, RRD_ID_LENGTH_MAX, "%s_packets", d->name?d->name:d->id);

            d->st_packets = rrdset_create_localhost(

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 437 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              
        if(unlikely(!d->st_packets)) {
            char id[RRD_ID_LENGTH_MAX + 1];
            char name[RRD_ID_LENGTH_MAX + 1];
            snprintfz(id, RRD_ID_LENGTH_MAX, "%s_packets", d->id);
            snprintfz(name, RRD_ID_LENGTH_MAX, "%s_packets", d->name?d->name:d->id);

            d->st_packets = rrdset_create_localhost(
                    RRD_TYPE_TC

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 460 Column: 17 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                          rrdset_next(d->st_packets);

            if(unlikely(d->name_updated)) {
                char name[RRD_ID_LENGTH_MAX + 1];
                snprintfz(name, RRD_ID_LENGTH_MAX, "%s_packets", d->name?d->name:d->id);
                rrdset_set_name(d->st_packets, name);
            }

            // TODO

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 491 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                      d->enabled_dropped = CONFIG_BOOLEAN_YES;

        if(unlikely(!d->st_dropped)) {
            char id[RRD_ID_LENGTH_MAX + 1];
            char name[RRD_ID_LENGTH_MAX + 1];
            snprintfz(id, RRD_ID_LENGTH_MAX, "%s_dropped", d->id);
            snprintfz(name, RRD_ID_LENGTH_MAX, "%s_dropped", d->name?d->name:d->id);

            d->st_dropped = rrdset_create_localhost(

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 492 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              
        if(unlikely(!d->st_dropped)) {
            char id[RRD_ID_LENGTH_MAX + 1];
            char name[RRD_ID_LENGTH_MAX + 1];
            snprintfz(id, RRD_ID_LENGTH_MAX, "%s_dropped", d->id);
            snprintfz(name, RRD_ID_LENGTH_MAX, "%s_dropped", d->name?d->name:d->id);

            d->st_dropped = rrdset_create_localhost(
                    RRD_TYPE_TC

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 515 Column: 17 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                          rrdset_next(d->st_dropped);

            if(unlikely(d->name_updated)) {
                char name[RRD_ID_LENGTH_MAX + 1];
                snprintfz(name, RRD_ID_LENGTH_MAX, "%s_dropped", d->name?d->name:d->id);
                rrdset_set_name(d->st_dropped, name);
            }

            // TODO

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 546 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                      d->enabled_tokens = CONFIG_BOOLEAN_YES;

        if(unlikely(!d->st_tokens)) {
            char id[RRD_ID_LENGTH_MAX + 1];
            char name[RRD_ID_LENGTH_MAX + 1];
            snprintfz(id, RRD_ID_LENGTH_MAX, "%s_tokens", d->id);
            snprintfz(name, RRD_ID_LENGTH_MAX, "%s_tokens", d->name?d->name:d->id);

            d->st_tokens = rrdset_create_localhost(

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 547 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              
        if(unlikely(!d->st_tokens)) {
            char id[RRD_ID_LENGTH_MAX + 1];
            char name[RRD_ID_LENGTH_MAX + 1];
            snprintfz(id, RRD_ID_LENGTH_MAX, "%s_tokens", d->id);
            snprintfz(name, RRD_ID_LENGTH_MAX, "%s_tokens", d->name?d->name:d->id);

            d->st_tokens = rrdset_create_localhost(
                    RRD_TYPE_TC

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 570 Column: 17 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                          rrdset_next(d->st_tokens);

            if(unlikely(d->name_updated)) {
                char name[RRD_ID_LENGTH_MAX + 1];
                snprintfz(name, RRD_ID_LENGTH_MAX, "%s_tokens", d->name?d->name:d->id);
                rrdset_set_name(d->st_tokens, name);
            }

            // TODO

            

Reported by FlawFinder.