The following issues were found
collectors/python.d.plugin/hpssa/hpssa.chart.py
35 issues
Line: 10
Column: 1
import re
from copy import deepcopy
from bases.FrameworkServices.ExecutableService import ExecutableService
from bases.collection import find_binary
disabled_by_default = True
update_every = 5
Reported by Pylint.
Line: 11
Column: 1
from copy import deepcopy
from bases.FrameworkServices.ExecutableService import ExecutableService
from bases.collection import find_binary
disabled_by_default = True
update_every = 5
ORDER = [
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: hpssa netdata python.d module
# Author: Peter Gnodde (gnoddep)
# SPDX-License-Identifier: GPL-3.0-or-later
import os
import re
from copy import deepcopy
Reported by Pylint.
Line: 13
Column: 1
from bases.FrameworkServices.ExecutableService import ExecutableService
from bases.collection import find_binary
disabled_by_default = True
update_every = 5
ORDER = [
'ctrl_status',
'ctrl_temperature',
Reported by Pylint.
Line: 14
Column: 1
from bases.collection import find_binary
disabled_by_default = True
update_every = 5
ORDER = [
'ctrl_status',
'ctrl_temperature',
'ld_status',
Reported by Pylint.
Line: 111
Column: 1
error_match = re.compile(r'Error:')
class HPSSAException(Exception):
pass
class HPSSA(object):
def __init__(self, lines):
Reported by Pylint.
Line: 115
Column: 1
pass
class HPSSA(object):
def __init__(self, lines):
self.lines = [line.strip() for line in lines if line.strip()]
self.current_line = 0
self.adapters = []
self.parse()
Reported by Pylint.
Line: 115
Column: 1
pass
class HPSSA(object):
def __init__(self, lines):
self.lines = [line.strip() for line in lines if line.strip()]
self.current_line = 0
self.adapters = []
self.parse()
Reported by Pylint.
Line: 140
Column: 5
"""
return self.__next__()
def rewind(self):
self.current_line = max(self.current_line - 1, 0)
@staticmethod
def match_any(line, *regexes):
return any([regex.match(line) for regex in regexes])
Reported by Pylint.
Line: 144
Column: 5
self.current_line = max(self.current_line - 1, 0)
@staticmethod
def match_any(line, *regexes):
return any([regex.match(line) for regex in regexes])
def parse(self):
for line in self:
match = adapter_regex.match(line)
Reported by Pylint.
collectors/python.d.plugin/python_modules/bases/charts.py
34 issues
Line: 6
Column: 1
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later
from bases.collection import safe_print
CHART_PARAMS = ['type', 'id', 'name', 'title', 'units', 'family', 'context', 'chart_type', 'hidden']
DIMENSION_PARAMS = ['id', 'name', 'algorithm', 'multiplier', 'divisor', 'hidden']
VARIABLE_PARAMS = ['id', 'value']
Reported by Pylint.
Line: 47
Column: 26
self = args[0]
chart = RUNTIME_CHART_CREATE.format(
job_name=self.name,
update_every=self._runtime_counters.update_every,
module_name=self.module_name,
)
safe_print(chart)
ok = func(*args, **kwargs)
return ok
Reported by Pylint.
Line: 173
Column: 13
try:
return self.params[item]
except KeyError:
raise AttributeError("'{instance}' has no attribute '{attr}'".format(instance=repr(self),
attr=item))
def __repr__(self):
return 'Chart({0})'.format(self.id)
Reported by Pylint.
Line: 316
Column: 13
try:
return self.params[item]
except KeyError:
raise AttributeError("'{instance}' has no attribute '{attr}'".format(instance=repr(self),
attr=item))
def __repr__(self):
return 'Dimension({0})'.format(self.id)
Reported by Pylint.
Line: 373
Column: 13
try:
return self.params[item]
except KeyError:
raise AttributeError("'{instance}' has no attribute '{attr}'".format(instance=repr(self),
attr=item))
def __bool__(self):
return self.value is not None
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description:
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later
from bases.collection import safe_print
CHART_PARAMS = ['type', 'id', 'name', 'title', 'units', 'family', 'context', 'chart_type', 'hidden']
DIMENSION_PARAMS = ['id', 'name', 'algorithm', 'multiplier', 'divisor', 'hidden']
Reported by Pylint.
Line: 13
Column: 1
VARIABLE_PARAMS = ['id', 'value']
CHART_TYPES = ['line', 'area', 'stacked']
DIMENSION_ALGORITHMS = ['absolute', 'incremental', 'percentage-of-absolute-row', 'percentage-of-incremental-row']
CHART_BEGIN = 'BEGIN {type}.{id} {since_last}\n'
CHART_CREATE = "CHART {type}.{id} '{name}' '{title}' '{units}' '{family}' '{context}' " \
"{chart_type} {priority} {update_every} '{hidden}' 'python.d.plugin' '{module_name}'\n"
CHART_OBSOLETE = "CHART {type}.{id} '{name}' '{title}' '{units}' '{family}' '{context}' " \
Reported by Pylint.
Line: 17
Column: 1
CHART_BEGIN = 'BEGIN {type}.{id} {since_last}\n'
CHART_CREATE = "CHART {type}.{id} '{name}' '{title}' '{units}' '{family}' '{context}' " \
"{chart_type} {priority} {update_every} '{hidden}' 'python.d.plugin' '{module_name}'\n"
CHART_OBSOLETE = "CHART {type}.{id} '{name}' '{title}' '{units}' '{family}' '{context}' " \
"{chart_type} {priority} {update_every} '{hidden} obsolete'\n"
DIMENSION_CREATE = "DIMENSION '{id}' '{name}' {algorithm} {multiplier} {divisor} '{hidden} {obsolete}'\n"
DIMENSION_SET = "SET '{id}' = {value}\n"
Reported by Pylint.
Line: 21
Column: 1
CHART_OBSOLETE = "CHART {type}.{id} '{name}' '{title}' '{units}' '{family}' '{context}' " \
"{chart_type} {priority} {update_every} '{hidden} obsolete'\n"
DIMENSION_CREATE = "DIMENSION '{id}' '{name}' {algorithm} {multiplier} {divisor} '{hidden} {obsolete}'\n"
DIMENSION_SET = "SET '{id}' = {value}\n"
CHART_VARIABLE_SET = "VARIABLE CHART '{id}' = {value}\n"
RUNTIME_CHART_CREATE = "CHART netdata.runtime_{job_name} '' 'Execution time for {job_name}' 'ms' 'python.d' " \
Reported by Pylint.
Line: 26
Column: 1
CHART_VARIABLE_SET = "VARIABLE CHART '{id}' = {value}\n"
RUNTIME_CHART_CREATE = "CHART netdata.runtime_{job_name} '' 'Execution time for {job_name}' 'ms' 'python.d' " \
"netdata.pythond_runtime line 145000 {update_every} '' 'python.d.plugin' '{module_name}'\n" \
"DIMENSION run_time 'run time' absolute 1 1\n"
def create_runtime_chart(func):
Reported by Pylint.
collectors/python.d.plugin/python_modules/urllib3/contrib/socks.py
34 issues
Line: 31
Column: 5
import socks
except ImportError:
import warnings
from ..exceptions import DependencyWarning
warnings.warn((
'SOCKS support in urllib3 requires the installation of optional '
'dependencies: specifically, PySocks. For more information, see '
'https://urllib3.readthedocs.io/en/latest/contrib.html#socks-proxies'
Reported by Pylint.
Line: 44
Column: 1
from socket import error as SocketError, timeout as SocketTimeout
from ..connection import (
HTTPConnection, HTTPSConnection
)
from ..connectionpool import (
HTTPConnectionPool, HTTPSConnectionPool
)
Reported by Pylint.
Line: 47
Column: 1
from ..connection import (
HTTPConnection, HTTPSConnection
)
from ..connectionpool import (
HTTPConnectionPool, HTTPSConnectionPool
)
from ..exceptions import ConnectTimeoutError, NewConnectionError
from ..poolmanager import PoolManager
from ..util.url import parse_url
Reported by Pylint.
Line: 50
Column: 1
from ..connectionpool import (
HTTPConnectionPool, HTTPSConnectionPool
)
from ..exceptions import ConnectTimeoutError, NewConnectionError
from ..poolmanager import PoolManager
from ..util.url import parse_url
try:
import ssl
Reported by Pylint.
Line: 51
Column: 1
HTTPConnectionPool, HTTPSConnectionPool
)
from ..exceptions import ConnectTimeoutError, NewConnectionError
from ..poolmanager import PoolManager
from ..util.url import parse_url
try:
import ssl
except ImportError:
Reported by Pylint.
Line: 52
Column: 1
)
from ..exceptions import ConnectTimeoutError, NewConnectionError
from ..poolmanager import PoolManager
from ..util.url import parse_url
try:
import ssl
except ImportError:
ssl = None
Reported by Pylint.
Line: 80
Column: 20
extra_kw['socket_options'] = self.socket_options
try:
conn = socks.create_connection(
(self.host, self.port),
proxy_type=self._socks_options['socks_version'],
proxy_addr=self._socks_options['proxy_host'],
proxy_port=self._socks_options['proxy_port'],
proxy_username=self._socks_options['username'],
Reported by Pylint.
Line: 97
Column: 16
self, "Connection to %s timed out. (connect timeout=%s)" %
(self.host, self.timeout))
except socks.ProxyError as e:
# This is fragile as hell, but it seems to be the only way to raise
# useful errors here.
if e.socket_err:
error = e.socket_err
if isinstance(error, SocketTimeout):
Reported by Pylint.
Line: 157
Column: 29
parsed = parse_url(proxy_url)
if parsed.scheme == 'socks5':
socks_version = socks.PROXY_TYPE_SOCKS5
rdns = False
elif parsed.scheme == 'socks5h':
socks_version = socks.PROXY_TYPE_SOCKS5
rdns = True
elif parsed.scheme == 'socks4':
Reported by Pylint.
Line: 160
Column: 29
socks_version = socks.PROXY_TYPE_SOCKS5
rdns = False
elif parsed.scheme == 'socks5h':
socks_version = socks.PROXY_TYPE_SOCKS5
rdns = True
elif parsed.scheme == 'socks4':
socks_version = socks.PROXY_TYPE_SOCKS4
rdns = False
elif parsed.scheme == 'socks4a':
Reported by Pylint.
collectors/python.d.plugin/python_modules/bases/FrameworkServices/SimpleService.py
34 issues
Line: 10
Column: 1
from time import sleep, time
from third_party.monotonic import monotonic
from bases.charts import Charts, ChartError, create_runtime_chart
from bases.collection import safe_print
from bases.loggers import PythonDLimitedLogger
Reported by Pylint.
Line: 12
Column: 1
from third_party.monotonic import monotonic
from bases.charts import Charts, ChartError, create_runtime_chart
from bases.collection import safe_print
from bases.loggers import PythonDLimitedLogger
RUNTIME_CHART_UPDATE = 'BEGIN netdata.runtime_{job_name} {since_last}\n' \
'SET run_time = {elapsed}\n' \
Reported by Pylint.
Line: 13
Column: 1
from third_party.monotonic import monotonic
from bases.charts import Charts, ChartError, create_runtime_chart
from bases.collection import safe_print
from bases.loggers import PythonDLimitedLogger
RUNTIME_CHART_UPDATE = 'BEGIN netdata.runtime_{job_name} {since_last}\n' \
'SET run_time = {elapsed}\n' \
'END\n'
Reported by Pylint.
Line: 14
Column: 1
from bases.charts import Charts, ChartError, create_runtime_chart
from bases.collection import safe_print
from bases.loggers import PythonDLimitedLogger
RUNTIME_CHART_UPDATE = 'BEGIN netdata.runtime_{job_name} {since_last}\n' \
'SET run_time = {elapsed}\n' \
'END\n'
Reported by Pylint.
Line: 70
Column: 39
Implemented basic functionality to run jobs by `python.d.plugin`
"""
def __init__(self, configuration, name=''):
"""
:param configuration: <dict>
:param name: <str>
"""
PythonDLimitedLogger.__init__(self)
Reported by Pylint.
Line: 198
Column: 20
try:
updated = self.update(interval=since)
except Exception as error:
self.error('update() unhandled exception: {error}'.format(error=error))
updated = False
job.runs += 1
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description:
# Author: Pawel Krupa (paulfantom)
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later
from time import sleep, time
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description:
# Author: Pawel Krupa (paulfantom)
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later
from time import sleep, time
Reported by Pylint.
Line: 24
Column: 1
MAX_PENALTY = 10 * 60 # 10 minutes
class RuntimeCounters:
def __init__(self, configuration):
"""
:param configuration: <dict>
"""
self.update_every = int(configuration.pop('update_every'))
Reported by Pylint.
Line: 24
Column: 1
MAX_PENALTY = 10 * 60 # 10 minutes
class RuntimeCounters:
def __init__(self, configuration):
"""
:param configuration: <dict>
"""
self.update_every = int(configuration.pop('update_every'))
Reported by Pylint.
collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService.py
33 issues
Line: 23
Column: 1
except AttributeError:
PROTOCOL_TLS = ssl.PROTOCOL_SSLv23
from bases.FrameworkServices.SimpleService import SimpleService
DEFAULT_CONNECT_TIMEOUT = 2.0
DEFAULT_READ_TIMEOUT = 2.0
DEFAULT_WRITE_TIMEOUT = 2.0
Reported by Pylint.
Line: 195
Column: 53
self._sock.shutdown(2) # 0 - read, 1 - write, 2 - all
self._sock.close()
except Exception as error:
if not (hasattr(error, 'errno') and error.errno == errno.ENOTCONN):
self.error(error)
self._sock = None
def _send(self, request=None):
"""
Reported by Pylint.
Line: 92
Column: 30
self.debug('Using keyfile: {0}, certfile: {1}, cert_reqs: {2}, ssl_version: {3}'.format(
self.key, self.cert, ssl.CERT_NONE, PROTOCOL_TLS
))
self._sock = ssl.wrap_socket(self._sock,
keyfile=self.key,
certfile=self.cert,
server_side=False,
cert_reqs=ssl.CERT_NONE,
ssl_version=PROTOCOL_TLS,
Reported by Pylint.
Line: 179
Column: 16
if self._connect2socket(res):
break
except Exception as error:
self.error('unhandled exception during connect : {0}'.format(repr(error)))
self._sock = None
self.__socket_config = None
def _disconnect(self):
Reported by Pylint.
Line: 194
Column: 20
self.debug('closing socket')
self._sock.shutdown(2) # 0 - read, 1 - write, 2 - all
self._sock.close()
except Exception as error:
if not (hasattr(error, 'errno') and error.errno == errno.ENOTCONN):
self.error(error)
self._sock = None
def _send(self, request=None):
Reported by Pylint.
Line: 211
Column: 20
self._sock.settimeout(self.write_timeout)
self.debug('sending request: {0}'.format(request or self.request))
self._sock.send(request or self.request)
except Exception as error:
self._socket_error('error sending request: {0}'.format(error))
self._disconnect()
return False
return True
Reported by Pylint.
Line: 232
Column: 20
self.debug('set socket read timeout to: {0}'.format(self._sock.gettimeout()))
self._sock.settimeout(self.read_timeout)
buf = self._sock.recv(4096)
except Exception as error:
self._socket_error('failed to receive response: {0}'.format(error))
self._disconnect()
break
if buf is None or len(buf) == 0: # handle server disconnect
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description:
# Author: Pawel Krupa (paulfantom)
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later
import errno
import socket
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description:
# Author: Pawel Krupa (paulfantom)
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later
import errno
import socket
Reported by Pylint.
Line: 23
Column: 1
except AttributeError:
PROTOCOL_TLS = ssl.PROTOCOL_SSLv23
from bases.FrameworkServices.SimpleService import SimpleService
DEFAULT_CONNECT_TIMEOUT = 2.0
DEFAULT_READ_TIMEOUT = 2.0
DEFAULT_WRITE_TIMEOUT = 2.0
Reported by Pylint.
build_external/scenarios/aclk-testing/paho-inspection.py
33 issues
Line: 2
Column: 1
import ssl
import paho.mqtt.client as mqtt
def on_connect(mqttc, obj, flags, rc):
print("connected rc: "+str(rc), flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
Reported by Pylint.
Line: 4
Column: 16
import ssl
import paho.mqtt.client as mqtt
def on_connect(mqttc, obj, flags, rc):
print("connected rc: "+str(rc), flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
Reported by Pylint.
Line: 4
Column: 28
import ssl
import paho.mqtt.client as mqtt
def on_connect(mqttc, obj, flags, rc):
print("connected rc: "+str(rc), flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
Reported by Pylint.
Line: 4
Column: 23
import ssl
import paho.mqtt.client as mqtt
def on_connect(mqttc, obj, flags, rc):
print("connected rc: "+str(rc), flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
Reported by Pylint.
Line: 7
Column: 19
def on_connect(mqttc, obj, flags, rc):
print("connected rc: "+str(rc), flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(msg.topic+" "+str(msg.qos)+" "+str(msg.payload), flush=True)
def on_publish(mqttc, obj, mid):
print("mid: "+str(mid), flush=True)
Reported by Pylint.
Line: 7
Column: 19
def on_connect(mqttc, obj, flags, rc):
print("connected rc: "+str(rc), flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(msg.topic+" "+str(msg.qos)+" "+str(msg.payload), flush=True)
def on_publish(mqttc, obj, mid):
print("mid: "+str(mid), flush=True)
Reported by Pylint.
Line: 7
Column: 26
def on_connect(mqttc, obj, flags, rc):
print("connected rc: "+str(rc), flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(msg.topic+" "+str(msg.qos)+" "+str(msg.payload), flush=True)
def on_publish(mqttc, obj, mid):
print("mid: "+str(mid), flush=True)
Reported by Pylint.
Line: 7
Column: 31
def on_connect(mqttc, obj, flags, rc):
print("connected rc: "+str(rc), flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(msg.topic+" "+str(msg.qos)+" "+str(msg.payload), flush=True)
def on_publish(mqttc, obj, mid):
print("mid: "+str(mid), flush=True)
Reported by Pylint.
Line: 9
Column: 16
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(msg.topic+" "+str(msg.qos)+" "+str(msg.payload), flush=True)
def on_publish(mqttc, obj, mid):
print("mid: "+str(mid), flush=True)
def on_subscribe(mqttc, obj, mid, granted_qos):
print("Subscribed: "+str(mid)+" "+str(granted_qos), flush=True)
Reported by Pylint.
Line: 9
Column: 16
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(msg.topic+" "+str(msg.qos)+" "+str(msg.payload), flush=True)
def on_publish(mqttc, obj, mid):
print("mid: "+str(mid), flush=True)
def on_subscribe(mqttc, obj, mid, granted_qos):
print("Subscribed: "+str(mid)+" "+str(granted_qos), flush=True)
Reported by Pylint.
collectors/python.d.plugin/isc_dhcpd/isc_dhcpd.chart.py
33 issues
Line: 20
Column: 1
from collections import defaultdict
from copy import deepcopy
from bases.FrameworkServices.SimpleService import SimpleService
ORDER = [
'pools_utilization',
'pools_active_leases',
'leases_total',
Reported by Pylint.
Line: 193
Column: 3
self.data = dict()
# Will work only with 'default' db-time-format (weekday year/month/day hour:minute:second)
# TODO: update algorithm to parse correctly 'local' db-time-format
def check(self):
if not HAVE_IP_ADDRESS:
self.error("'python-ipaddress' package is needed")
return False
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: isc dhcpd lease netdata python.d module
# Author: ilyam8
# SPDX-License-Identifier: GPL-3.0-or-later
import os
import re
import time
Reported by Pylint.
Line: 30
Column: 1
CHARTS = {
'pools_utilization': {
'options': [None, 'Pools Utilization', 'percentage', 'utilization', 'isc_dhcpd.utilization', 'line'],
'lines': []
},
'pools_active_leases': {
'options': [None, 'Active Leases Per Pool', 'leases', 'active leases', 'isc_dhcpd.active_leases', 'line'],
'lines': []
Reported by Pylint.
Line: 34
Column: 1
'lines': []
},
'pools_active_leases': {
'options': [None, 'Active Leases Per Pool', 'leases', 'active leases', 'isc_dhcpd.active_leases', 'line'],
'lines': []
},
'leases_total': {
'options': [None, 'All Active Leases', 'leases', 'active leases', 'isc_dhcpd.leases_total', 'line'],
'lines': [
Reported by Pylint.
Line: 38
Column: 1
'lines': []
},
'leases_total': {
'options': [None, 'All Active Leases', 'leases', 'active leases', 'isc_dhcpd.leases_total', 'line'],
'lines': [
['leases_total', 'leases', 'absolute']
],
'variables': [
['leases_size']
Reported by Pylint.
Line: 52
Column: 1
POOL_IP_RANGE = "IP_RANGE"
POOL_UNKNOWN = "UNKNOWN"
def detect_ip_type(ip):
ip_type = ip.split("-")
if len(ip_type) == 1:
return POOL_CIDR
elif len(ip_type) == 2:
return POOL_IP_RANGE
Reported by Pylint.
Line: 52
Column: 1
POOL_IP_RANGE = "IP_RANGE"
POOL_UNKNOWN = "UNKNOWN"
def detect_ip_type(ip):
ip_type = ip.split("-")
if len(ip_type) == 1:
return POOL_CIDR
elif len(ip_type) == 2:
return POOL_IP_RANGE
Reported by Pylint.
Line: 54
Column: 5
def detect_ip_type(ip):
ip_type = ip.split("-")
if len(ip_type) == 1:
return POOL_CIDR
elif len(ip_type) == 2:
return POOL_IP_RANGE
else:
return POOL_UNKNOWN
Reported by Pylint.
Line: 62
Column: 1
return POOL_UNKNOWN
class DhcpdLeasesFile:
def __init__(self, path):
self.path = path
self.mod_time = 0
self.size = 0
Reported by Pylint.
collectors/proc.plugin/proc_diskstats.c
33 issues
Line: 393
Column: 31
CWE codes:
362
20
Suggestion:
Reconsider approach
if(de->d_type == DT_LNK) {
snprintfz(filename, FILENAME_MAX, "%s/%s", path, de->d_name);
ssize_t len = readlink(filename, result, result_size - 1);
if(len <= 0) {
error("DEVICE-MAPPER ('%s', %lu:%lu): Cannot read link '%s'.", disk, major, minor, filename);
continue;
}
Reported by FlawFinder.
Line: 617
Column: 15
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
// find if it is a physical disk
// by checking if /sys/block/DISK is readable.
snprintfz(buffer, FILENAME_MAX, path_to_sys_block_device, disk);
if(likely(access(buffer, R_OK) == 0)) {
// assign it here, but it will be overwritten if it is not a physical disk
d->type = DISK_TYPE_PHYSICAL;
}
// find if it is a partition
Reported by FlawFinder.
Line: 625
Column: 15
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
// find if it is a partition
// by checking if /sys/dev/block/MAJOR:MINOR/partition is readable.
snprintfz(buffer, FILENAME_MAX, path_to_sys_dev_block_major_minor_string, major, minor, "partition");
if(likely(access(buffer, R_OK) == 0)) {
d->type = DISK_TYPE_PARTITION;
}
else {
// find if it is a virtual disk
// by checking if /sys/devices/virtual/block/DISK is readable.
Reported by FlawFinder.
Line: 632
Column: 19
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
// find if it is a virtual disk
// by checking if /sys/devices/virtual/block/DISK is readable.
snprintfz(buffer, FILENAME_MAX, path_to_sys_devices_virtual_block_device, disk);
if(likely(access(buffer, R_OK) == 0)) {
d->type = DISK_TYPE_VIRTUAL;
}
else {
// find if it is a virtual device
// by checking if /sys/dev/block/MAJOR:MINOR/slaves has entries
Reported by FlawFinder.
Line: 727
Column: 12
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
char buffer2[FILENAME_MAX + 1];
snprintfz(buffer2, FILENAME_MAX, "%s/cache/congested", buffer);
if(access(buffer2, R_OK) == 0)
d->bcache_filename_cache_congested = strdupz(buffer2);
else
error("bcache file '%s' cannot be read.", buffer2);
snprintfz(buffer2, FILENAME_MAX, "%s/readahead", buffer);
Reported by FlawFinder.
Line: 733
Column: 12
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
error("bcache file '%s' cannot be read.", buffer2);
snprintfz(buffer2, FILENAME_MAX, "%s/readahead", buffer);
if(access(buffer2, R_OK) == 0)
d->bcache_filename_stats_total_cache_readaheads = strdupz(buffer2);
else
error("bcache file '%s' cannot be read.", buffer2);
snprintfz(buffer2, FILENAME_MAX, "%s/cache/cache0/priority_stats", buffer); // only one cache is supported by bcache
Reported by FlawFinder.
Line: 739
Column: 12
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
error("bcache file '%s' cannot be read.", buffer2);
snprintfz(buffer2, FILENAME_MAX, "%s/cache/cache0/priority_stats", buffer); // only one cache is supported by bcache
if(access(buffer2, R_OK) == 0)
d->bcache_filename_priority_stats = strdupz(buffer2);
else
error("bcache file '%s' cannot be read.", buffer2);
snprintfz(buffer2, FILENAME_MAX, "%s/cache/internal/cache_read_races", buffer);
Reported by FlawFinder.
Line: 745
Column: 12
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
error("bcache file '%s' cannot be read.", buffer2);
snprintfz(buffer2, FILENAME_MAX, "%s/cache/internal/cache_read_races", buffer);
if(access(buffer2, R_OK) == 0)
d->bcache_filename_cache_read_races = strdupz(buffer2);
else
error("bcache file '%s' cannot be read.", buffer2);
snprintfz(buffer2, FILENAME_MAX, "%s/cache/cache0/io_errors", buffer);
Reported by FlawFinder.
Line: 751
Column: 12
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
error("bcache file '%s' cannot be read.", buffer2);
snprintfz(buffer2, FILENAME_MAX, "%s/cache/cache0/io_errors", buffer);
if(access(buffer2, R_OK) == 0)
d->bcache_filename_cache_io_errors = strdupz(buffer2);
else
error("bcache file '%s' cannot be read.", buffer2);
snprintfz(buffer2, FILENAME_MAX, "%s/dirty_data", buffer);
Reported by FlawFinder.
Line: 757
Column: 12
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
error("bcache file '%s' cannot be read.", buffer2);
snprintfz(buffer2, FILENAME_MAX, "%s/dirty_data", buffer);
if(access(buffer2, R_OK) == 0)
d->bcache_filename_dirty_data = strdupz(buffer2);
else
error("bcache file '%s' cannot be read.", buffer2);
snprintfz(buffer2, FILENAME_MAX, "%s/writeback_rate", buffer);
Reported by FlawFinder.
collectors/python.d.plugin/python_modules/third_party/filelock.py
32 issues
Line: 58
Column: 5
try:
TimeoutError
except NameError:
TimeoutError = OSError
# Data
# ------------------------------------------------
__all__ = [
Reported by Pylint.
Line: 78
Column: 5
_logger = None
def logger():
"""Returns the logger instance used in this module."""
global _logger
_logger = _logger or logging.getLogger(__name__)
return _logger
# Exceptions
Reported by Pylint.
Line: 91
Column: 5
seconds.
"""
def __init__(self, lock_file):
"""
"""
#: The path of the file lock.
self.lock_file = lock_file
return None
Reported by Pylint.
Line: 75
Column: 1
__version__ = "3.0.12"
_logger = None
def logger():
"""Returns the logger instance used in this module."""
global _logger
_logger = _logger or logging.getLogger(__name__)
return _logger
Reported by Pylint.
Line: 78
Column: 5
_logger = None
def logger():
"""Returns the logger instance used in this module."""
global _logger
_logger = _logger or logging.getLogger(__name__)
return _logger
# Exceptions
Reported by Pylint.
Line: 91
Column: 5
seconds.
"""
def __init__(self, lock_file):
"""
"""
#: The path of the file lock.
self.lock_file = lock_file
return None
Reported by Pylint.
Line: 115
Column: 1
# automatically.
#
# :seealso: issue #37 (memory leak)
class _Acquire_ReturnProxy(object):
def __init__(self, lock):
self.lock = lock
return None
Reported by Pylint.
Line: 115
Column: 1
# automatically.
#
# :seealso: issue #37 (memory leak)
class _Acquire_ReturnProxy(object):
def __init__(self, lock):
self.lock = lock
return None
Reported by Pylint.
Line: 117
Column: 5
# :seealso: issue #37 (memory leak)
class _Acquire_ReturnProxy(object):
def __init__(self, lock):
self.lock = lock
return None
def __enter__(self):
return self.lock
Reported by Pylint.
Line: 124
Column: 5
def __enter__(self):
return self.lock
def __exit__(self, exc_type, exc_value, traceback):
self.lock.release()
return None
class BaseFileLock(object):
Reported by Pylint.
collectors/python.d.plugin/python_modules/bases/loggers.py
32 issues
Line: 16
Column: 1
except ImportError:
from time import time
from bases.collection import on_try_except_finally, unicode_str
LOGGING_LEVELS = {'CRITICAL': 50,
'ERROR': 40,
'WARNING': 30,
Reported by Pylint.
Line: 37
Column: 28
def on_decorator(func):
def on_call(*args):
current_time = args[0]._runtime_counters.start_mono
lc = args[0]._logger_counters
if lc.logged and lc.logged % log_max_count == 0:
if current_time - lc.time_to_compare <= allowed_in_seconds:
lc.dropped += 1
Reported by Pylint.
Line: 38
Column: 18
def on_call(*args):
current_time = args[0]._runtime_counters.start_mono
lc = args[0]._logger_counters
if lc.logged and lc.logged % log_max_count == 0:
if current_time - lc.time_to_compare <= allowed_in_seconds:
lc.dropped += 1
return
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description:
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later
import logging
import traceback
from sys import exc_info
Reported by Pylint.
Line: 29
Column: 1
DEFAULT_LOG_LINE_FORMAT = '%(asctime)s: %(name)s %(levelname)s : %(message)s'
DEFAULT_LOG_TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
PYTHON_D_LOG_LINE_FORMAT = '%(asctime)s: %(name)s %(levelname)s: %(module_name)s[%(job_name)s] : %(message)s'
PYTHON_D_LOG_NAME = 'python.d'
def limiter(log_max_count=30, allowed_in_seconds=60):
def on_decorator(func):
Reported by Pylint.
Line: 33
Column: 1
PYTHON_D_LOG_NAME = 'python.d'
def limiter(log_max_count=30, allowed_in_seconds=60):
def on_decorator(func):
def on_call(*args):
current_time = args[0]._runtime_counters.start_mono
lc = args[0]._logger_counters
Reported by Pylint.
Line: 38
Column: 13
def on_call(*args):
current_time = args[0]._runtime_counters.start_mono
lc = args[0]._logger_counters
if lc.logged and lc.logged % log_max_count == 0:
if current_time - lc.time_to_compare <= allowed_in_seconds:
lc.dropped += 1
return
Reported by Pylint.
Line: 53
Column: 1
return on_decorator
def add_traceback(func):
def on_call(*args):
self = args[0]
if not self.log_traceback:
func(*args)
Reported by Pylint.
Line: 69
Column: 1
return on_call
class LoggerCounters:
def __init__(self):
self.logged = 0
self.dropped = 0
self.time_to_compare = time()
Reported by Pylint.
Line: 69
Column: 1
return on_call
class LoggerCounters:
def __init__(self):
self.logged = 0
self.dropped = 0
self.time_to_compare = time()
Reported by Pylint.