The following issues were found
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.
daemon/unit_test.c
32 issues
Line: 22
Column: 23
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
{ .n = 0, .correct = NULL },
};
char netdata[50], system[50];
int i, failed = 0;
for(i = 0; values[i].correct ; i++) {
print_calculated_number(netdata, values[i].n);
snprintfz(system, 49, "%0.12" LONG_DOUBLE_MODIFIER, (LONG_DOUBLE)values[i].n);
Reported by FlawFinder.
Line: 26
Column: 19
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
int i, failed = 0;
for(i = 0; values[i].correct ; i++) {
print_calculated_number(netdata, values[i].n);
snprintfz(system, 49, "%0.12" LONG_DOUBLE_MODIFIER, (LONG_DOUBLE)values[i].n);
int ok = 1;
if(strcmp(netdata, values[i].correct) != 0) {
ok = 0;
failed++;
Reported by FlawFinder.
Line: 34
Column: 74
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
failed++;
}
fprintf(stderr, "'%s' (system) printed as '%s' (netdata): %s\n", system, netdata, ok?"OK":"FAILED");
}
if(failed) return 1;
return 0;
}
Reported by FlawFinder.
Line: 122
Column: 9
CWE codes:
134
Suggestion:
Use a constant for the format specification
if(pcdiff < 0) pcdiff = -pcdiff;
if(debug) {
fprintf(stderr,
CALCULATED_NUMBER_FORMAT " original\n"
CALCULATED_NUMBER_FORMAT " packed and unpacked, (stored as 0x%08X, diff " CALCULATED_NUMBER_FORMAT ", " CALCULATED_NUMBER_FORMAT "%%)\n"
"%s printed after unpacked (%zu bytes)\n"
CALCULATED_NUMBER_FORMAT " re-parsed from printed (diff " CALCULATED_NUMBER_FORMAT ", " CALCULATED_NUMBER_FORMAT "%%)\n\n",
n,
Reported by FlawFinder.
Line: 164
Column: 30
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
int i, j;
calculated_number n, d;
storage_number s;
unsigned long long user, system, total, mine, their;
calculated_number storage_number_positive_min = unpack_storage_number(STORAGE_NUMBER_POSITIVE_MIN_RAW);
calculated_number storage_number_positive_max = unpack_storage_number(STORAGE_NUMBER_POSITIVE_MAX_RAW);
char buffer[100];
Reported by FlawFinder.
Line: 217
Column: 21
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
getrusage(RUSAGE_SELF, &now);
user = now.ru_utime.tv_sec * 1000000ULL + now.ru_utime.tv_usec - last.ru_utime.tv_sec * 1000000ULL + last.ru_utime.tv_usec;
system = now.ru_stime.tv_sec * 1000000ULL + now.ru_stime.tv_usec - last.ru_stime.tv_sec * 1000000ULL + last.ru_stime.tv_usec;
total = user + system;
mine = total;
fprintf(stderr, "user %0.5" LONG_DOUBLE_MODIFIER", system %0.5" LONG_DOUBLE_MODIFIER ", total %0.5" LONG_DOUBLE_MODIFIER "\n", (LONG_DOUBLE)(user / 1000000.0), (LONG_DOUBLE)(system / 1000000.0), (LONG_DOUBLE)(total / 1000000.0));
// ------------------------------------------------------------------------
Reported by FlawFinder.
Line: 220
Column: 179
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
total = user + system;
mine = total;
fprintf(stderr, "user %0.5" LONG_DOUBLE_MODIFIER", system %0.5" LONG_DOUBLE_MODIFIER ", total %0.5" LONG_DOUBLE_MODIFIER "\n", (LONG_DOUBLE)(user / 1000000.0), (LONG_DOUBLE)(system / 1000000.0), (LONG_DOUBLE)(total / 1000000.0));
// ------------------------------------------------------------------------
fprintf(stderr, "SYSTEM LONG DOUBLE PRINTING: ");
getrusage(RUSAGE_SELF, &last);
Reported by FlawFinder.
Line: 241
Column: 21
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
getrusage(RUSAGE_SELF, &now);
user = now.ru_utime.tv_sec * 1000000ULL + now.ru_utime.tv_usec - last.ru_utime.tv_sec * 1000000ULL + last.ru_utime.tv_usec;
system = now.ru_stime.tv_sec * 1000000ULL + now.ru_stime.tv_usec - last.ru_stime.tv_sec * 1000000ULL + last.ru_stime.tv_usec;
total = user + system;
their = total;
fprintf(stderr, "user %0.5" LONG_DOUBLE_MODIFIER ", system %0.5" LONG_DOUBLE_MODIFIER ", total %0.5" LONG_DOUBLE_MODIFIER "\n", (LONG_DOUBLE)(user / 1000000.0), (LONG_DOUBLE)(system / 1000000.0), (LONG_DOUBLE)(total / 1000000.0));
if(mine > total) {
Reported by FlawFinder.
Line: 244
Column: 180
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
total = user + system;
their = total;
fprintf(stderr, "user %0.5" LONG_DOUBLE_MODIFIER ", system %0.5" LONG_DOUBLE_MODIFIER ", total %0.5" LONG_DOUBLE_MODIFIER "\n", (LONG_DOUBLE)(user / 1000000.0), (LONG_DOUBLE)(system / 1000000.0), (LONG_DOUBLE)(total / 1000000.0));
if(mine > total) {
fprintf(stderr, "NETDATA CODE IS SLOWER %0.2" LONG_DOUBLE_MODIFIER " %%\n", (LONG_DOUBLE)(mine * 100.0 / their - 100.0));
}
else {
Reported by FlawFinder.
Line: 275
Column: 21
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
getrusage(RUSAGE_SELF, &now);
user = now.ru_utime.tv_sec * 1000000ULL + now.ru_utime.tv_usec - last.ru_utime.tv_sec * 1000000ULL + last.ru_utime.tv_usec;
system = now.ru_stime.tv_sec * 1000000ULL + now.ru_stime.tv_usec - last.ru_stime.tv_sec * 1000000ULL + last.ru_stime.tv_usec;
total = user + system;
mine = total;
fprintf(stderr, "user %0.5" LONG_DOUBLE_MODIFIER ", system %0.5" LONG_DOUBLE_MODIFIER ", total %0.5" LONG_DOUBLE_MODIFIER "\n", (LONG_DOUBLE)(user / 1000000.0), (LONG_DOUBLE)(system / 1000000.0), (LONG_DOUBLE)(total / 1000000.0));
if(mine > their) {
Reported by FlawFinder.
collectors/python.d.plugin/varnish/varnish.chart.py
31 issues
Line: 8
Column: 1
import re
from bases.FrameworkServices.ExecutableService import ExecutableService
from bases.collection import find_binary
ORDER = [
'session_connections',
'client_requests',
Reported by Pylint.
Line: 9
Column: 1
import re
from bases.FrameworkServices.ExecutableService import ExecutableService
from bases.collection import find_binary
ORDER = [
'session_connections',
'client_requests',
'all_time_hit_rate',
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: varnish netdata python.d module
# Author: ilyam8
# SPDX-License-Identifier: GPL-3.0-or-later
import re
from bases.FrameworkServices.ExecutableService import ExecutableService
from bases.collection import find_binary
Reported by Pylint.
Line: 118
Column: 1
]
},
'esi_statistics': {
'options': [None, 'ESI Statistics', 'problems/s', 'esi related metrics', 'varnish.esi_statistics', 'line'],
'lines': [
['esi_errors', 'errors', 'incremental'],
['esi_warnings', 'warnings', 'incremental']
]
},
Reported by Pylint.
Line: 139
Column: 1
}
def backend_charts_template(name):
order = [
'{0}_response_statistics'.format(name),
]
charts = {
Reported by Pylint.
Line: 146
Column: 1
charts = {
order[0]: {
'options': [None, 'Backend "{0}"'.format(name), 'kilobits/s', 'backend response statistics',
'varnish.backend', 'area'],
'lines': [
['{0}_beresp_hdrbytes'.format(name), 'header', 'incremental', 8, 1000],
['{0}_beresp_bodybytes'.format(name), 'body', 'incremental', -8, 1000]
]
Reported by Pylint.
Line: 158
Column: 1
return order, charts
def storage_charts_template(name):
order = [
'storage_{0}_usage'.format(name),
'storage_{0}_alloc_objs'.format(name)
]
Reported by Pylint.
Line: 166
Column: 1
charts = {
order[0]: {
'options': [None, 'Storage "{0}" Usage'.format(name), 'KiB', 'storage usage', 'varnish.storage_usage', 'stacked'],
'lines': [
['{0}.g_space'.format(name), 'free', 'absolute', 1, 1 << 10],
['{0}.g_bytes'.format(name), 'allocated', 'absolute', 1, 1 << 10]
]
},
Reported by Pylint.
Line: 173
Column: 1
]
},
order[1]: {
'options': [None, 'Storage "{0}" Allocated Objects'.format(name), 'objects', 'storage usage', 'varnish.storage_alloc_objs', 'line'],
'lines': [
['{0}.g_alloc'.format(name), 'allocated', 'absolute']
]
}
}
Reported by Pylint.
Line: 188
Column: 1
re_version = re.compile(r'varnish-(?:plus-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)')
class VarnishVersion:
def __init__(self, major, minor, patch):
self.major = major
self.minor = minor
self.patch = patch
Reported by Pylint.
collectors/python.d.plugin/ceph/ceph.chart.py
31 issues
Line: 16
Column: 1
import json
import os
from bases.FrameworkServices.SimpleService import SimpleService
# default module values (can be overridden per job in `config`)
update_every = 10
ORDER = [
Reported by Pylint.
Line: 156
Column: 13
self.error('Ceph plugin does not read {0}, define read permission.'.format(self.keyring_file))
return False
try:
self.cluster = rados.Rados(conffile=self.config_file,
conf=dict(keyring=self.keyring_file),
rados_id=self.rados_id)
self.cluster.connect()
except rados.Error as error:
self.error(error)
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: ceph netdata python.d module
# Author: Luis Eduardo (lets00)
# SPDX-License-Identifier: GPL-3.0-or-later
try:
import rados
CEPH = True
Reported by Pylint.
Line: 19
Column: 1
from bases.FrameworkServices.SimpleService import SimpleService
# default module values (can be overridden per job in `config`)
update_every = 10
ORDER = [
'general_usage',
'general_objects',
'general_bytes',
Reported by Pylint.
Line: 48
Column: 1
]
},
'general_objects': {
'options': [None, 'Ceph General Objects', 'objects', 'general', 'ceph.general_objects', 'area'],
'lines': [
['general_objects', 'cluster', 'absolute']
]
},
'general_bytes': {
Reported by Pylint.
Line: 54
Column: 1
]
},
'general_bytes': {
'options': [None, 'Ceph General Read/Write Data/s', 'KiB/s', 'general', 'ceph.general_bytes',
'area'],
'lines': [
['general_read_bytes', 'read', 'absolute', 1, 1024],
['general_write_bytes', 'write', 'absolute', -1, 1024]
]
Reported by Pylint.
Line: 62
Column: 1
]
},
'general_operations': {
'options': [None, 'Ceph General Read/Write Operations/s', 'operations', 'general', 'ceph.general_operations',
'area'],
'lines': [
['general_read_operations', 'read', 'absolute', 1],
['general_write_operations', 'write', 'absolute', -1]
]
Reported by Pylint.
Line: 70
Column: 1
]
},
'general_latency': {
'options': [None, 'Ceph General Apply/Commit latency', 'milliseconds', 'general', 'ceph.general_latency',
'area'],
'lines': [
['general_apply_latency', 'apply', 'absolute'],
['general_commit_latency', 'commit', 'absolute']
]
Reported by Pylint.
Line: 90
Column: 1
'lines': []
},
'pool_write_bytes': {
'options': [None, 'Ceph Write Pool Data/s', 'KiB/s', 'pool', 'ceph.pool_write_bytes', 'area'],
'lines': []
},
'pool_read_operations': {
'options': [None, 'Ceph Read Pool Operations/s', 'operations', 'pool', 'ceph.pool_read_operations', 'area'],
'lines': []
Reported by Pylint.
Line: 94
Column: 1
'lines': []
},
'pool_read_operations': {
'options': [None, 'Ceph Read Pool Operations/s', 'operations', 'pool', 'ceph.pool_read_operations', 'area'],
'lines': []
},
'pool_write_operations': {
'options': [None, 'Ceph Write Pool Operations/s', 'operations', 'pool', 'ceph.pool_write_operations', 'area'],
'lines': []
Reported by Pylint.
libnetdata/socket/socket.c
30 issues
Line: 142
Column: 8
CWE codes:
362
Suggestion:
Use fchmod( ) instead
// we have to chmod this to 0777 so that the client will be able
// to read from and write to this socket.
if(chmod(path, 0777) == -1)
error("LISTENER: failed to chmod() socket file '%s'.", path);
if(listen(sock, listen_backlog) < 0) {
close(sock);
error("LISTENER: UNIX listen() on path '%s' failed.", path);
Reported by FlawFinder.
Line: 355
Column: 5
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
struct addrinfo *result = NULL, *rp = NULL;
char buffer[strlen(definition) + 1];
strcpy(buffer, definition);
char buffer2[10 + 1];
snprintfz(buffer2, 10, "%d", default_port);
char *ip = buffer, *port = buffer2, *interface = "", *portconfig;;
Reported by FlawFinder.
Line: 759
Column: 5
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
int connect_to_this(const char *definition, int default_port, struct timeval *timeout) {
char buffer[strlen(definition) + 1];
strcpy(buffer, definition);
char default_service[10 + 1];
snprintfz(default_service, 10, "%d", default_port);
char *host = buffer, *service = default_service, *interface = "";
Reported by FlawFinder.
Line: 88
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
// --------------------------------------------------------------------------------------------------------------------
char *strdup_client_description(int family, const char *protocol, const char *ip, uint16_t port) {
char buffer[100 + 1];
switch(family) {
case AF_INET:
snprintfz(buffer, 100, "%s:%s:%d", protocol, ip, port);
break;
Reported by FlawFinder.
Line: 354
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
struct addrinfo hints;
struct addrinfo *result = NULL, *rp = NULL;
char buffer[strlen(definition) + 1];
strcpy(buffer, definition);
char buffer2[10 + 1];
snprintfz(buffer2, 10, "%d", default_port);
Reported by FlawFinder.
Line: 357
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
char buffer[strlen(definition) + 1];
strcpy(buffer, definition);
char buffer2[10 + 1];
snprintfz(buffer2, 10, "%d", default_port);
char *ip = buffer, *port = buffer2, *interface = "", *portconfig;;
int protocol = IPPROTO_TCP, socktype = SOCK_STREAM;
Reported by FlawFinder.
Line: 477
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
int fd = -1;
int family;
char rip[INET_ADDRSTRLEN + INET6_ADDRSTRLEN] = "INVALID";
uint16_t rport = default_port;
family = rp->ai_addr->sa_family;
switch (family) {
case AF_INET: {
Reported by FlawFinder.
Line: 548
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
// is there anything?
if(!*s || s == e) break;
char buf[e - s + 1];
strncpyz(buf, s, e - s);
bind_to_this(sockets, buf, sockets->default_port, sockets->backlog);
s = e;
}
Reported by FlawFinder.
Line: 635
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
}
}
char hostBfr[NI_MAXHOST + 1];
char servBfr[NI_MAXSERV + 1];
getnameinfo(ai->ai_addr,
ai->ai_addrlen,
hostBfr,
Reported by FlawFinder.
Line: 636
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
}
char hostBfr[NI_MAXHOST + 1];
char servBfr[NI_MAXSERV + 1];
getnameinfo(ai->ai_addr,
ai->ai_addrlen,
hostBfr,
sizeof(hostBfr),
Reported by FlawFinder.
collectors/python.d.plugin/proxysql/proxysql.chart.py
29 issues
Line: 6
Column: 1
# Author: Ali Borhani (alibo)
# SPDX-License-Identifier: GPL-3.0+
from bases.FrameworkServices.MySQLService import MySQLService
def query(table, *params):
return 'SELECT {params} FROM {table}'.format(table=table, params=', '.join(params))
Reported by Pylint.
Line: 10
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b608_hardcoded_sql_expressions.html
def query(table, *params):
return 'SELECT {params} FROM {table}'.format(table=table, params=', '.join(params))
# https://github.com/sysown/proxysql/blob/master/doc/admin_tables.md#stats_mysql_global
QUERY_GLOBAL = query(
"stats_mysql_global",
Reported by Bandit.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: Proxysql netdata python.d module
# Author: Ali Borhani (alibo)
# SPDX-License-Identifier: GPL-3.0+
from bases.FrameworkServices.MySQLService import MySQLService
def query(table, *params):
Reported by Pylint.
Line: 9
Column: 1
from bases.FrameworkServices.MySQLService import MySQLService
def query(table, *params):
return 'SELECT {params} FROM {table}'.format(table=table, params=', '.join(params))
# https://github.com/sysown/proxysql/blob/master/doc/admin_tables.md#stats_mysql_global
QUERY_GLOBAL = query(
Reported by Pylint.
Line: 120
Column: 1
CHARTS = {
'pool_status': {
'options': [None, 'ProxySQL Backend Status', 'status', 'status', 'proxysql.pool_status', 'line'],
'lines': []
},
'pool_net': {
'options': [None, 'ProxySQL Backend Bandwidth', 'kilobits/s', 'bandwidth', 'proxysql.pool_net', 'area'],
'lines': []
Reported by Pylint.
Line: 124
Column: 1
'lines': []
},
'pool_net': {
'options': [None, 'ProxySQL Backend Bandwidth', 'kilobits/s', 'bandwidth', 'proxysql.pool_net', 'area'],
'lines': []
},
'pool_overall_net': {
'options': [None, 'ProxySQL Backend Overall Bandwidth', 'kilobits/s', 'overall_bandwidth',
'proxysql.pool_overall_net', 'area'],
Reported by Pylint.
Line: 136
Column: 1
]
},
'questions': {
'options': [None, 'ProxySQL Frontend Questions', 'questions/s', 'questions', 'proxysql.questions', 'line'],
'lines': [
['questions', 'questions', 'incremental'],
['slow_queries', 'slow_queries', 'incremental']
]
},
Reported by Pylint.
Line: 143
Column: 1
]
},
'pool_queries': {
'options': [None, 'ProxySQL Backend Queries', 'queries/s', 'queries', 'proxysql.queries', 'line'],
'lines': []
},
'active_transactions': {
'options': [None, 'ProxySQL Frontend Active Transactions', 'transactions/s', 'active_transactions',
'proxysql.active_transactions', 'line'],
Reported by Pylint.
Line: 147
Column: 1
'lines': []
},
'active_transactions': {
'options': [None, 'ProxySQL Frontend Active Transactions', 'transactions/s', 'active_transactions',
'proxysql.active_transactions', 'line'],
'lines': [
['active_transactions', 'active_transactions', 'absolute']
]
},
Reported by Pylint.
Line: 154
Column: 1
]
},
'pool_latency': {
'options': [None, 'ProxySQL Backend Latency', 'milliseconds', 'latency', 'proxysql.latency', 'line'],
'lines': []
},
'connections': {
'options': [None, 'ProxySQL Frontend Connections', 'connections/s', 'connections', 'proxysql.connections',
'line'],
Reported by Pylint.
collectors/python.d.plugin/oracledb/oracledb.chart.py
28 issues
Line: 8
Column: 1
from copy import deepcopy
from bases.FrameworkServices.SimpleService import SimpleService
try:
import cx_Oracle
HAS_ORACLE = True
Reported by Pylint.
Line: 425
Column: 3
return None
else:
for name, offline, size, used, used_in_percent in rv:
# TODO: skip offline?
if not (not offline and self.charts):
continue
# TODO: remove inactive?
if name not in self.active_tablespaces:
self.active_tablespaces.add(name)
Reported by Pylint.
Line: 428
Column: 3
# TODO: skip offline?
if not (not offline and self.charts):
continue
# TODO: remove inactive?
if name not in self.active_tablespaces:
self.active_tablespaces.add(name)
self.add_tablespace_to_charts(name)
data['{0}_tablespace_size'.format(name)] = int(size * 1000)
data['{0}_tablespace_used'.format(name)] = int(used * 1000)
Reported by Pylint.
Line: 445
Column: 3
return None
else:
for name, offline, size, used, used_in_percent in rv:
# TODO: skip offline?
if not (not offline and self.charts):
continue
# TODO: remove inactive?
if name not in self.active_tablespaces:
self.active_tablespaces.add(name)
Reported by Pylint.
Line: 448
Column: 3
# TODO: skip offline?
if not (not offline and self.charts):
continue
# TODO: remove inactive?
if name not in self.active_tablespaces:
self.active_tablespaces.add(name)
self.add_tablespace_to_charts(name)
data['{0}_allocated_size'.format(name)] = int(size * 1000)
data['{0}_allocated_used'.format(name)] = int(used * 1000)
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: oracledb netdata python.d module
# Author: ilyam8 (Ilya Mashchenko)
# SPDX-License-Identifier: GPL-3.0-or-later
from copy import deepcopy
from bases.FrameworkServices.SimpleService import SimpleService
Reported by Pylint.
Line: 44
Column: 1
CHARTS = {
'session_count': {
'options': [None, 'Session Count', 'sessions', 'session activity', 'oracledb.session_count', 'line'],
'lines': [
['session_count', 'total', 'absolute', 1, 1000],
['average_active_sessions', 'active', 'absolute', 1, 1000],
]
},
Reported by Pylint.
Line: 51
Column: 1
]
},
'session_limit_usage': {
'options': [None, 'Session Limit Usage', '%', 'session activity', 'oracledb.session_limit_usage', 'area'],
'lines': [
['session_limit_percent', 'usage', 'absolute', 1, 1000],
]
},
'logons': {
Reported by Pylint.
Line: 71
Column: 1
]
},
'sorts_on_disk': {
'options': [None, 'Sorts On Disk', 'events/s', 'disk activity', 'oracledb.sorts_on_disks', 'line'],
'lines': [
['disk_sort_per_sec', 'sorts', 'absolute', 1, 1000],
]
},
'full_table_scans': {
Reported by Pylint.
Line: 77
Column: 1
]
},
'full_table_scans': {
'options': [None, 'Full Table Scans', 'events/s', 'disk activity', 'oracledb.full_table_scans', 'line'],
'lines': [
['long_table_scans_per_sec', 'full table scans', 'absolute', 1, 1000],
]
},
'database_wait_time_ratio': {
Reported by Pylint.
collectors/python.d.plugin/python_modules/urllib3/util/ssl_.py
27 issues
Line: 10
Column: 1
from binascii import hexlify, unhexlify
from hashlib import md5, sha1, sha256
from ..exceptions import SSLError, InsecurePlatformWarning, SNIMissingWarning
SSLContext = None
HAS_SNI = False
IS_PYOPENSSL = False
Reported by Pylint.
Line: 92
Column: 5
except ImportError:
import sys
class SSLContext(object): # Platform-specific: Python 2 & 3.1
supports_set_ciphers = ((2, 7) <= sys.version_info < (3,) or
(3, 2) <= sys.version_info)
def __init__(self, protocol_version):
self.protocol = protocol_version
Reported by Pylint.
Line: 126
Column: 39
)
self.ciphers = cipher_suite
def wrap_socket(self, socket, server_hostname=None, server_side=False):
warnings.warn(
'A true SSLContext object is not available. This prevents '
'urllib3 from configuring SSL appropriately and may cause '
'certain SSL connections to fail. You can upgrade to a newer '
'version of Python to solve this. For more information, see '
Reported by Pylint.
Line: 145
Column: 24
'server_side': server_side,
}
if self.supports_set_ciphers: # Platform-specific: Python 2.7+
return wrap_socket(socket, ciphers=self.ciphers, **kwargs)
else: # Platform-specific: Python 2.6
return wrap_socket(socket, **kwargs)
def assert_fingerprint(cert, fingerprint):
Reported by Pylint.
Line: 147
Column: 24
if self.supports_set_ciphers: # Platform-specific: Python 2.7+
return wrap_socket(socket, ciphers=self.ciphers, **kwargs)
else: # Platform-specific: Python 2.6
return wrap_socket(socket, **kwargs)
def assert_fingerprint(cert, fingerprint):
"""
Checks if given fingerprint matches the supplied certificate.
Reported by Pylint.
Line: 312
Column: 13
try:
context.load_verify_locations(ca_certs, ca_cert_dir)
except IOError as e: # Platform-specific: Python 2.6, 2.7, 3.2
raise SSLError(e)
# Py33 raises FileNotFoundError which subclasses OSError
# These are not equivalent unless we check the errno attribute
except OSError as e: # Platform-specific: Python 3.3 and beyond
if e.errno == errno.ENOENT:
raise SSLError(e)
Reported by Pylint.
Line: 315
Column: 16
raise SSLError(e)
# Py33 raises FileNotFoundError which subclasses OSError
# These are not equivalent unless we check the errno attribute
except OSError as e: # Platform-specific: Python 3.3 and beyond
if e.errno == errno.ENOENT:
raise SSLError(e)
raise
elif getattr(context, 'load_default_certs', None) is not None:
# try to load OS default certs; works well on Windows (require Python3.4+)
Reported by Pylint.
Line: 317
Column: 17
# These are not equivalent unless we check the errno attribute
except OSError as e: # Platform-specific: Python 3.3 and beyond
if e.errno == errno.ENOENT:
raise SSLError(e)
raise
elif getattr(context, 'load_default_certs', None) is not None:
# try to load OS default certs; works well on Windows (require Python3.4+)
context.load_default_certs()
Reported by Pylint.
Line: 1
Column: 1
# SPDX-License-Identifier: MIT
from __future__ import absolute_import
import errno
import warnings
import hmac
from binascii import hexlify, unhexlify
from hashlib import md5, sha1, sha256
Reported by Pylint.
Line: 13
Column: 1
from ..exceptions import SSLError, InsecurePlatformWarning, SNIMissingWarning
SSLContext = None
HAS_SNI = False
IS_PYOPENSSL = False
IS_SECURETRANSPORT = False
# Maps the length of a digest to a possible hash function producing this digest
Reported by Pylint.
collectors/python.d.plugin/riakkv/riakkv.chart.py
27 issues
Line: 9
Column: 1
from json import loads
from bases.FrameworkServices.UrlService import UrlService
# Riak updates the metrics at the /stats endpoint every 1 second.
# If we use `update_every = 1` here, that means we might get weird jitter in the graph,
# so the default is set to 2 seconds to prevent it.
update_every = 2
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: riak netdata python.d module
#
# See also:
# https://docs.riak.com/riak/kv/latest/using/reference/statistics-monitoring/index.html
from json import loads
from bases.FrameworkServices.UrlService import UrlService
Reported by Pylint.
Line: 14
Column: 1
# Riak updates the metrics at the /stats endpoint every 1 second.
# If we use `update_every = 1` here, that means we might get weird jitter in the graph,
# so the default is set to 2 seconds to prevent it.
update_every = 2
# charts order (can be overridden if you want less charts, or different order)
ORDER = [
# Throughput metrics
# https://docs.riak.com/riak/kv/latest/using/reference/statistics-monitoring/index.html#throughput-metrics
Reported by Pylint.
Line: 70
Column: 1
CHARTS = {
# Throughput metrics
"kv.node_operations": {
"options": [None, "Reads & writes coordinated by this node", "operations/s", "throughput", "riak.kv.throughput",
"line"],
"lines": [
["node_gets_total", "gets", "incremental"],
["node_puts_total", "puts", "incremental"]
]
Reported by Pylint.
Line: 78
Column: 1
]
},
"dt.vnode_updates": {
"options": [None, "Update operations coordinated by local vnodes by data type", "operations/s", "throughput",
"riak.dt.vnode_updates", "line"],
"lines": [
["vnode_counter_update_total", "counters", "incremental"],
["vnode_set_update_total", "sets", "incremental"],
["vnode_map_update_total", "maps", "incremental"],
Reported by Pylint.
Line: 87
Column: 1
]
},
"search.queries": {
"options": [None, "Search queries on the node", "queries/s", "throughput", "riak.search", "line"],
"lines": [
["search_query_throughput_count", "queries", "incremental"]
]
},
"search.documents": {
Reported by Pylint.
Line: 93
Column: 1
]
},
"search.documents": {
"options": [None, "Documents indexed by search", "documents/s", "throughput", "riak.search.documents", "line"],
"lines": [
["search_index_throughput_count", "indexed", "incremental"]
]
},
"consistent.operations": {
Reported by Pylint.
Line: 99
Column: 1
]
},
"consistent.operations": {
"options": [None, "Consistent node operations", "operations/s", "throughput", "riak.consistent.operations",
"line"],
"lines": [
["consistent_gets_total", "gets", "incremental"],
["consistent_puts_total", "puts", "incremental"],
]
Reported by Pylint.
Line: 109
Column: 1
# Latency metrics
"kv.latency.get": {
"options": [None, "Time between reception of a client GET request and subsequent response to client", "ms",
"latency", "riak.kv.latency.get", "line"],
"lines": [
["node_get_fsm_time_mean", "mean", "absolute", 1, 1000],
["node_get_fsm_time_median", "median", "absolute", 1, 1000],
["node_get_fsm_time_95", "95", "absolute", 1, 1000],
Reported by Pylint.
Line: 120
Column: 1
]
},
"kv.latency.put": {
"options": [None, "Time between reception of a client PUT request and subsequent response to client", "ms",
"latency", "riak.kv.latency.put", "line"],
"lines": [
["node_put_fsm_time_mean", "mean", "absolute", 1, 1000],
["node_put_fsm_time_median", "median", "absolute", 1, 1000],
["node_put_fsm_time_95", "95", "absolute", 1, 1000],
Reported by Pylint.
libnetdata/ebpf/ebpf.c
27 issues
Line: 182
Column: 24
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
version_string_len = strlen(version_string);
// Open a file with a list of rejected kernels
char *config_dir = getenv("NETDATA_USER_CONFIG_DIR");
if (config_dir == NULL) {
config_dir = CONFIG_DIR;
}
char filename[FILENAME_MAX + 1];
Reported by FlawFinder.
Line: 197
Column: 26
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
kernel_reject_list = fopen(filename, "r");
if (!kernel_reject_list) {
config_dir = getenv("NETDATA_STOCK_CONFIG_DIR");
if (config_dir == NULL) {
config_dir = LIBCONFIG_DIR;
}
snprintfz(filename, FILENAME_MAX, "%s/ebpf.d/%s", config_dir, EBPF_KERNEL_REJECT_LIST_FILE);
Reported by FlawFinder.
Line: 69
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
int get_kernel_version(char *out, int size)
{
char major[16], minor[16], patch[16];
char ver[VERSION_STRING_LEN];
char *version = ver;
out[0] = '\0';
int fd = open("/proc/sys/kernel/osrelease", O_RDONLY);
Reported by FlawFinder.
Line: 70
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
int get_kernel_version(char *out, int size)
{
char major[16], minor[16], patch[16];
char ver[VERSION_STRING_LEN];
char *version = ver;
out[0] = '\0';
int fd = open("/proc/sys/kernel/osrelease", O_RDONLY);
if (fd < 0)
Reported by FlawFinder.
Line: 74
Column: 14
CWE codes:
362
char *version = ver;
out[0] = '\0';
int fd = open("/proc/sys/kernel/osrelease", O_RDONLY);
if (fd < 0)
return -1;
ssize_t len = read(fd, ver, sizeof(ver));
if (len < 0) {
Reported by FlawFinder.
Line: 116
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
int get_redhat_release()
{
char buffer[VERSION_STRING_LEN + 1];
int major, minor;
FILE *fp = fopen("/etc/redhat-release", "r");
if (fp) {
major = 0;
Reported by FlawFinder.
Line: 118
Column: 16
CWE codes:
362
{
char buffer[VERSION_STRING_LEN + 1];
int major, minor;
FILE *fp = fopen("/etc/redhat-release", "r");
if (fp) {
major = 0;
minor = -1;
size_t length = fread(buffer, sizeof(char), VERSION_STRING_LEN, fp);
Reported by FlawFinder.
Line: 163
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
static int kernel_is_rejected()
{
// Get kernel version from system
char version_string[VERSION_STRING_LEN + 1];
int version_string_len = 0;
if (read_file("/proc/version_signature", version_string, VERSION_STRING_LEN)) {
if (read_file("/proc/version", version_string, VERSION_STRING_LEN)) {
struct utsname uname_buf;
Reported by FlawFinder.
Line: 187
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
config_dir = CONFIG_DIR;
}
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/ebpf.d/%s", config_dir, EBPF_KERNEL_REJECT_LIST_FILE);
FILE *kernel_reject_list = fopen(filename, "r");
if (!kernel_reject_list) {
// Keep this to have compatibility with old versions
Reported by FlawFinder.
Line: 189
Column: 32
CWE codes:
362
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/ebpf.d/%s", config_dir, EBPF_KERNEL_REJECT_LIST_FILE);
FILE *kernel_reject_list = fopen(filename, "r");
if (!kernel_reject_list) {
// Keep this to have compatibility with old versions
snprintfz(filename, FILENAME_MAX, "%s/%s", config_dir, EBPF_KERNEL_REJECT_LIST_FILE);
kernel_reject_list = fopen(filename, "r");
Reported by FlawFinder.