The following issues were found
database/sqlite/sqlite_functions.c
14 issues
Line: 800
Column: 9
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
while (sqlite3_step(res_chart) == SQLITE_ROW) {
char id[512];
sprintf(id, "%s.%s", sqlite3_column_text(res_chart, 3), sqlite3_column_text(res_chart, 1));
RRDSET *st = rrdset_find(host, id);
if (st && !rrdset_flag_check(st, RRDSET_FLAG_ARCHIVED))
continue;
if (c)
Reported by FlawFinder.
Line: 1255
Column: 9
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
while (sqlite3_step(res) == SQLITE_ROW) {
char id[512];
sprintf(id, "%s.%s", sqlite3_column_text(res, 3), sqlite3_column_text(res, 1));
if (!st || uuid_compare(*(uuid_t *)sqlite3_column_blob(res, 7), chart_id)) {
if (unlikely(st && !st->counter)) {
freez(st->context);
freez((char *) st->name);
Reported by FlawFinder.
Line: 165
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 sql_init_database(void)
{
char *err_msg = NULL;
char sqlite_database[FILENAME_MAX + 1];
int rc;
fatal_assert(0 == uv_mutex_init(&sqlite_transaction_lock));
snprintfz(sqlite_database, FILENAME_MAX, "%s/netdata-meta.db", netdata_configured_cache_dir);
Reported by FlawFinder.
Line: 308
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 rc;
#ifdef NETDATA_INTERNAL_CHECKS
char uuid_str[GUID_LEN + 1];
uuid_unparse_lower(*dimension_uuid, uuid_str);
debug(D_METADATALOG,"Deleting dimension uuid %s", uuid_str);
#endif
if (unlikely(!res)) {
Reported by FlawFinder.
Line: 384
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
error_report("Failed to reset statement when searching for a chart UUID, rc = %d", rc);
#ifdef NETDATA_INTERNAL_CHECKS
char uuid_str[GUID_LEN + 1];
if (likely(uuid)) {
uuid_unparse_lower(*uuid, uuid_str);
debug(D_METADATALOG, "Found UUID %s for chart %s.%s", uuid_str, type, name ? name : id);
}
else
Reported by FlawFinder.
Line: 425
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
uuid_generate(*uuid);
#ifdef NETDATA_INTERNAL_CHECKS
char uuid_str[GUID_LEN + 1];
uuid_unparse_lower(*uuid, uuid_str);
debug(D_METADATALOG,"Generating uuid [%s] for chart %s under host %s", uuid_str, st->id, st->rrdhost->hostname);
#endif
rc = update_chart_metadata(uuid, st, id, name);
Reported by FlawFinder.
Line: 799
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
size_t dimensions = 0;
while (sqlite3_step(res_chart) == SQLITE_ROW) {
char id[512];
sprintf(id, "%s.%s", sqlite3_column_text(res_chart, 3), sqlite3_column_text(res_chart, 1));
RRDSET *st = rrdset_find(host, id);
if (st && !rrdset_flag_check(st, RRDSET_FLAG_ARCHIVED))
continue;
Reported by FlawFinder.
Line: 954
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
goto failed;
}
char uuid_str[GUID_LEN + 1];
uuid_unparse_lower(*((uuid_t *) sqlite3_column_blob(res, 0)), uuid_str);
host = callocz(1, sizeof(RRDHOST));
set_host_properties(host, sqlite3_column_int(res, 2), RRD_MEMORY_MODE_DBENGINE, hostname,
Reported by FlawFinder.
Line: 1248
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
}
RRDSET *st = NULL;
char machine_guid[GUID_LEN + 1];
uuid_unparse_lower(host->host_uuid, machine_guid);
uuid_t rrdeng_uuid;
uuid_t chart_id;
while (sqlite3_step(res) == SQLITE_ROW) {
Reported by FlawFinder.
Line: 1254
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
uuid_t chart_id;
while (sqlite3_step(res) == SQLITE_ROW) {
char id[512];
sprintf(id, "%s.%s", sqlite3_column_text(res, 3), sqlite3_column_text(res, 1));
if (!st || uuid_compare(*(uuid_t *)sqlite3_column_blob(res, 7), chart_id)) {
if (unlikely(st && !st->counter)) {
freez(st->context);
Reported by FlawFinder.
collectors/python.d.plugin/gearman/gearman.chart.py
13 issues
Line: 9
Column: 1
from copy import deepcopy
from bases.FrameworkServices.SocketService import SocketService
CHARTS = {
'total_workers': {
'options': [None, 'Total Jobs', 'Jobs', 'Total Jobs', 'gearman.total_jobs', 'line'],
'lines': [
Reported by Pylint.
Line: 135
Column: 13
try:
raw = self._get_raw_data()
except (ValueError, AttributeError):
raise GearmanReadException()
if raw is None:
self.debug("Gearman returned no data")
raise GearmanReadException()
Reported by Pylint.
Line: 1
Column: 1
# Description: dovecot netdata python.d module
# Author: Kyle Agronick (agronick)
# SPDX-License-Identifier: GPL-3.0+
# Gearman Netdata Plugin
from copy import deepcopy
from bases.FrameworkServices.SocketService import SocketService
Reported by Pylint.
Line: 22
Column: 1
}
def job_chart_template(job_name):
return {
'options': [None, job_name, 'Jobs', 'Activity by Job', 'gearman.single_job', 'stacked'],
'lines': [
['{0}_pending'.format(job_name), 'Pending', 'absolute'],
['{0}_idle'.format(job_name), 'Idle', 'absolute'],
Reported by Pylint.
Line: 51
Column: 1
}
def parse_worker_data(job):
job_name = job[0]
job_metrics = job[1:]
return {
'job_name': job_name,
Reported by Pylint.
Line: 61
Column: 1
}
class GearmanReadException(BaseException):
pass
class Service(SocketService):
def __init__(self, configuration=None, name=None):
Reported by Pylint.
Line: 65
Column: 1
pass
class Service(SocketService):
def __init__(self, configuration=None, name=None):
super(Service, self).__init__(configuration=configuration, name=name)
self.request = "status\n"
self._keep_alive = True
Reported by Pylint.
Line: 65
Column: 1
pass
class Service(SocketService):
def __init__(self, configuration=None, name=None):
super(Service, self).__init__(configuration=configuration, name=name)
self.request = "status\n"
self._keep_alive = True
Reported by Pylint.
Line: 67
Column: 9
class Service(SocketService):
def __init__(self, configuration=None, name=None):
super(Service, self).__init__(configuration=configuration, name=name)
self.request = "status\n"
self._keep_alive = True
self.host = self.configuration.get('host', 'localhost')
self.port = self.configuration.get('port', 4730)
Reported by Pylint.
Line: 97
Column: 5
self.remove_stale_jobs(found_jobs)
return job_data
def get_active_jobs(self):
active_jobs = []
for job in self.get_worker_data():
parsed_job = parse_worker_data(job)
Reported by Pylint.
collectors/python.d.plugin/dnsdist/dnsdist.chart.py
13 issues
Line: 6
Column: 1
from json import loads
from bases.FrameworkServices.UrlService import UrlService
ORDER = [
'queries',
'queries_dropped',
'packets_dropped',
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: GPL-3.0-or-later
from json import loads
from bases.FrameworkServices.UrlService import UrlService
ORDER = [
'queries',
Reported by Pylint.
Line: 25
Column: 1
CHARTS = {
'queries': {
'options': [None, 'Client queries received', 'queries/s', 'queries', 'dnsdist.queries', 'line'],
'lines': [
['queries', 'all', 'incremental'],
['rdqueries', 'recursive', 'incremental'],
['empty-queries', 'empty', 'incremental']
]
Reported by Pylint.
Line: 33
Column: 1
]
},
'queries_dropped': {
'options': [None, 'Client queries dropped', 'queries/s', 'queries', 'dnsdist.queries_dropped', 'line'],
'lines': [
['rule-drop', 'rule drop', 'incremental'],
['dyn-blocked', 'dynamic block', 'incremental'],
['no-policy', 'no policy', 'incremental'],
['noncompliant-queries', 'non compliant', 'incremental']
Reported by Pylint.
Line: 42
Column: 1
]
},
'packets_dropped': {
'options': [None, 'Packets dropped', 'packets/s', 'packets', 'dnsdist.packets_dropped', 'line'],
'lines': [
['acl-drops', 'acl', 'incremental']
]
},
'answers': {
Reported by Pylint.
Line: 57
Column: 1
]
},
'backend_responses': {
'options': [None, 'Backend responses', 'responses/s', 'backends', 'dnsdist.backend_responses', 'line'],
'lines': [
['responses', 'responses', 'incremental']
]
},
'backend_commerrors': {
Reported by Pylint.
Line: 63
Column: 1
]
},
'backend_commerrors': {
'options': [None, 'Backend Communication Errors', 'errors/s', 'backends', 'dnsdist.backend_commerrors', 'line'],
'lines': [
['downstream-send-errors', 'send errors', 'incremental']
]
},
'backend_errors': {
Reported by Pylint.
Line: 69
Column: 1
]
},
'backend_errors': {
'options': [None, 'Backend error responses', 'responses/s', 'backends', 'dnsdist.backend_errors', 'line'],
'lines': [
['downstream-timeouts', 'timeout', 'incremental'],
['servfail-responses', 'servfail', 'incremental'],
['noncompliant-responses', 'non compliant', 'incremental']
]
Reported by Pylint.
Line: 84
Column: 1
]
},
'servercpu': {
'options': [None, 'DNSDIST server CPU utilization', 'ms/s', 'server', 'dnsdist.servercpu', 'stacked'],
'lines': [
['cpu-sys-msec', 'system state', 'incremental'],
['cpu-user-msec', 'user state', 'incremental']
]
},
Reported by Pylint.
Line: 91
Column: 1
]
},
'servermem': {
'options': [None, 'DNSDIST server memory utilization', 'MiB', 'server', 'dnsdist.servermem', 'area'],
'lines': [
['real-memory-usage', 'memory usage', 'absolute', 1, 1 << 20]
]
},
'query_latency': {
Reported by Pylint.
collectors/python.d.plugin/springboot/springboot.chart.py
13 issues
Line: 8
Column: 1
import json
from bases.FrameworkServices.UrlService import UrlService
DEFAULT_ORDER = [
'response_code',
'threads',
'gc_time',
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: tomcat netdata python.d module
# Author: Wing924
# SPDX-License-Identifier: GPL-3.0-or-later
import json
from bases.FrameworkServices.UrlService import UrlService
Reported by Pylint.
Line: 20
Column: 1
DEFAULT_CHARTS = {
'response_code': {
'options': [None, "Response Codes", "requests/s", "response", "springboot.response_code", "stacked"],
'lines': [
["resp_other", 'Other', 'incremental'],
["resp_1xx", '1xx', 'incremental'],
["resp_2xx", '2xx', 'incremental'],
["resp_3xx", '3xx', 'incremental'],
Reported by Pylint.
Line: 38
Column: 1
]
},
'gc_time': {
'options': [None, "GC Time", "milliseconds", "garbage collection", "springboot.gc_time", "stacked"],
'lines': [
["gc_copy_time", 'Copy', 'incremental'],
["gc_marksweepcompact_time", 'MarkSweepCompact', 'incremental'],
["gc_parnew_time", 'ParNew', 'incremental'],
["gc_concurrentmarksweep_time", 'ConcurrentMarkSweep', 'incremental'],
Reported by Pylint.
Line: 51
Column: 1
]
},
'gc_ope': {
'options': [None, "GC Operations", "operations/s", "garbage collection", "springboot.gc_ope", "stacked"],
'lines': [
["gc_copy_count", 'Copy', 'incremental'],
["gc_marksweepcompact_count", 'MarkSweepCompact', 'incremental'],
["gc_parnew_count", 'ParNew', 'incremental'],
["gc_concurrentmarksweep_count", 'ConcurrentMarkSweep', 'incremental'],
Reported by Pylint.
Line: 73
Column: 1
}
class ExtraChartError(ValueError):
pass
class Service(UrlService):
def __init__(self, configuration=None, name=None):
Reported by Pylint.
Line: 77
Column: 1
pass
class Service(UrlService):
def __init__(self, configuration=None, name=None):
UrlService.__init__(self, configuration=configuration, name=name)
self.url = self.configuration.get('url', "http://localhost:8080/metrics")
self._setup_charts()
Reported by Pylint.
Line: 77
Column: 1
pass
class Service(UrlService):
def __init__(self, configuration=None, name=None):
UrlService.__init__(self, configuration=configuration, name=name)
self.url = self.configuration.get('url', "http://localhost:8080/metrics")
self._setup_charts()
Reported by Pylint.
Line: 132
Column: 5
self._add_extra_chart(extra)
self.order.append(extra['id'])
def _add_extra_chart(self, chart):
chart_id = chart.get('id', None) or self.die('id is not defined in extra chart')
options = chart.get('options', None) or self.die('option is not defined in extra chart: %s' % chart_id)
lines = chart.get('lines', None) or self.die('lines is not defined in extra chart: %s' % chart_id)
title = options.get('title', None) or self.die('title is missing: %s' % chart_id)
Reported by Pylint.
Line: 134
Column: 1
def _add_extra_chart(self, chart):
chart_id = chart.get('id', None) or self.die('id is not defined in extra chart')
options = chart.get('options', None) or self.die('option is not defined in extra chart: %s' % chart_id)
lines = chart.get('lines', None) or self.die('lines is not defined in extra chart: %s' % chart_id)
title = options.get('title', None) or self.die('title is missing: %s' % chart_id)
units = options.get('units', None) or self.die('units is missing: %s' % chart_id)
family = options.get('family', title)
Reported by Pylint.
collectors/python.d.plugin/python_modules/bases/FrameworkServices/ExecutableService.py
13 issues
Line: 11
Column: 1
from subprocess import Popen, PIPE
from bases.FrameworkServices.SimpleService import SimpleService
from bases.collection import find_binary
class ExecutableService(SimpleService):
def __init__(self, configuration=None, name=None):
Reported by Pylint.
Line: 12
Column: 1
from subprocess import Popen, PIPE
from bases.FrameworkServices.SimpleService import SimpleService
from bases.collection import find_binary
class ExecutableService(SimpleService):
def __init__(self, configuration=None, name=None):
SimpleService.__init__(self, configuration=configuration, name=name)
Reported by Pylint.
Line: 29
Column: 16
self.debug("Executing command '{0}'".format(' '.join(command)))
try:
p = Popen(command, stdout=PIPE, stderr=PIPE)
except Exception as error:
self.error('Executing command {0} resulted in error: {1}'.format(command, error))
return None
data = list()
std = p.stderr if stderr else p.stdout
Reported by Pylint.
Line: 83
Column: 16
try:
data = self._get_data()
except Exception as error:
self.error('_get_data() failed. Command: {command}. Error: {error}'.format(command=self.command,
error=error))
return False
if isinstance(data, dict) and data:
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 os
from subprocess import Popen, PIPE
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 os
from subprocess import Popen, PIPE
Reported by Pylint.
Line: 9
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import os
from subprocess import Popen, PIPE
from bases.FrameworkServices.SimpleService import SimpleService
from bases.collection import find_binary
Reported by Bandit.
Line: 15
Column: 1
from bases.collection import find_binary
class ExecutableService(SimpleService):
def __init__(self, configuration=None, name=None):
SimpleService.__init__(self, configuration=configuration, name=name)
self.command = None
def _get_raw_data(self, stderr=False, command=None):
Reported by Pylint.
Line: 15
Column: 1
from bases.collection import find_binary
class ExecutableService(SimpleService):
def __init__(self, configuration=None, name=None):
SimpleService.__init__(self, configuration=configuration, name=name)
self.command = None
def _get_raw_data(self, stderr=False, command=None):
Reported by Pylint.
Line: 28
Column: 13
command = command or self.command
self.debug("Executing command '{0}'".format(' '.join(command)))
try:
p = Popen(command, stdout=PIPE, stderr=PIPE)
except Exception as error:
self.error('Executing command {0} resulted in error: {1}'.format(command, error))
return None
data = list()
Reported by Pylint.
collectors/python.d.plugin/hddtemp/hddtemp.chart.py
12 issues
Line: 11
Column: 1
import re
from copy import deepcopy
from bases.FrameworkServices.SocketService import SocketService
ORDER = [
'temperatures',
]
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: hddtemp netdata python.d module
# Author: Pawel Krupa (paulfantom)
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later
import re
from copy import deepcopy
Reported by Pylint.
Line: 19
Column: 1
CHARTS = {
'temperatures': {
'options': ['disks_temp', 'Disks Temperatures', 'Celsius', 'temperatures', 'hddtemp.temperatures', 'line'],
'lines': [
# lines are created dynamically in `check()` method
]}}
RE = re.compile(r'\/dev\/([^|]+)\|([^|]+)\|([0-9]+|SLP|UNK)\|')
Reported by Pylint.
Line: 27
Column: 1
RE = re.compile(r'\/dev\/([^|]+)\|([^|]+)\|([0-9]+|SLP|UNK)\|')
class Disk:
def __init__(self, id_, name, temp):
self.id = id_.split('/')[-1]
self.name = name.replace(' ', '_')
self.temp = temp if temp.isdigit() else None
Reported by Pylint.
Line: 27
Column: 1
RE = re.compile(r'\/dev\/([^|]+)\|([^|]+)\|([0-9]+|SLP|UNK)\|')
class Disk:
def __init__(self, id_, name, temp):
self.id = id_.split('/')[-1]
self.name = name.replace(' ', '_')
self.temp = temp if temp.isdigit() else None
Reported by Pylint.
Line: 29
Column: 9
class Disk:
def __init__(self, id_, name, temp):
self.id = id_.split('/')[-1]
self.name = name.replace(' ', '_')
self.temp = temp if temp.isdigit() else None
def __repr__(self):
return self.id
Reported by Pylint.
Line: 37
Column: 1
return self.id
class Service(SocketService):
def __init__(self, configuration=None, name=None):
SocketService.__init__(self, configuration=configuration, name=name)
self.order = ORDER
self.definitions = deepcopy(CHARTS)
self.do_only = self.configuration.get('devices')
Reported by Pylint.
Line: 48
Column: 5
self.host = "127.0.0.1"
self.port = 7634
def get_disks(self):
r = self._get_raw_data()
if not r:
return None
Reported by Pylint.
Line: 49
Column: 9
self.port = 7634
def get_disks(self):
r = self._get_raw_data()
if not r:
return None
m = RE.findall(r)
Reported by Pylint.
Line: 54
Column: 9
if not r:
return None
m = RE.findall(r)
if not m:
self.error("received data doesn't have needed records")
return None
Reported by Pylint.
database/engine/datafile.c
12 issues
Line: 54
Column: 12
CWE codes:
134
Suggestion:
Use a constant for the format specification
void generate_datafilepath(struct rrdengine_datafile *datafile, char *str, size_t maxlen)
{
(void) snprintf(str, maxlen, "%s/" DATAFILE_PREFIX RRDENG_FILE_NUMBER_PRINT_TMPL DATAFILE_EXTENSION,
datafile->ctx->dbfiles_path, datafile->tier, datafile->fileno);
}
int close_data_file(struct rrdengine_datafile *datafile)
{
Reported by FlawFinder.
Line: 307
Column: 15
CWE codes:
120
20
Suggestion:
Specify a limit to %s, or use a different input function
datafiles = callocz(MIN(ret, MAX_DATAFILES), sizeof(*datafiles));
for (matched_files = 0 ; UV_EOF != uv_fs_scandir_next(&req, &dent) && matched_files < MAX_DATAFILES ; ) {
info("Scanning file \"%s/%s\"", ctx->dbfiles_path, dent.name);
ret = sscanf(dent.name, DATAFILE_PREFIX RRDENG_FILE_NUMBER_SCAN_TMPL DATAFILE_EXTENSION, &tier, &no);
if (2 == ret) {
info("Matched file \"%s/%s\"", ctx->dbfiles_path, dent.name);
datafile = mallocz(sizeof(*datafile));
datafile_init(datafile, ctx, tier, no);
datafiles[matched_files++] = datafile;
Reported by FlawFinder.
Line: 63
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 rrdengine_instance *ctx = datafile->ctx;
uv_fs_t req;
int ret;
char path[RRDENG_PATH_MAX];
generate_datafilepath(datafile, path, sizeof(path));
ret = uv_fs_close(NULL, &req, datafile->file, NULL);
if (ret < 0) {
Reported by FlawFinder.
Line: 83
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 rrdengine_instance *ctx = datafile->ctx;
uv_fs_t req;
int ret;
char path[RRDENG_PATH_MAX];
generate_datafilepath(datafile, path, sizeof(path));
ret = uv_fs_unlink(NULL, &req, path, NULL);
if (ret < 0) {
Reported by FlawFinder.
Line: 105
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 rrdengine_instance *ctx = datafile->ctx;
uv_fs_t req;
int ret;
char path[RRDENG_PATH_MAX];
generate_datafilepath(datafile, path, sizeof(path));
ret = uv_fs_ftruncate(NULL, &req, datafile->file, 0, NULL);
if (ret < 0) {
Reported by FlawFinder.
Line: 146
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 ret, fd;
struct rrdeng_df_sb *superblock;
uv_buf_t iov;
char path[RRDENG_PATH_MAX];
generate_datafilepath(datafile, path, sizeof(path));
fd = open_file_direct_io(path, O_CREAT | O_RDWR | O_TRUNC, &file);
if (fd < 0) {
++ctx->stats.fs_errors;
Reported by FlawFinder.
Line: 231
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
uv_file file;
int ret, fd, error;
uint64_t file_size;
char path[RRDENG_PATH_MAX];
generate_datafilepath(datafile, path, sizeof(path));
fd = open_file_direct_io(path, O_RDWR, &file);
if (fd < 0) {
++ctx->stats.fs_errors;
Reported by FlawFinder.
Line: 274
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 scan_data_files_cmp(const void *a, const void *b)
{
struct rrdengine_datafile *file1, *file2;
char path1[RRDENG_PATH_MAX], path2[RRDENG_PATH_MAX];
file1 = *(struct rrdengine_datafile **)a;
file2 = *(struct rrdengine_datafile **)b;
generate_datafilepath(file1, path1, sizeof(path1));
generate_datafilepath(file2, path2, sizeof(path2));
Reported by FlawFinder.
Line: 346
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
must_delete_pair = 1;
}
if (must_delete_pair) {
char path[RRDENG_PATH_MAX];
error("Deleting invalid data and journal file pair.");
ret = unlink_journal_file(journalfile);
if (!ret) {
generate_journalfilepath(datafile, path, sizeof(path));
Reported by FlawFinder.
Line: 380
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 rrdengine_datafile *datafile;
struct rrdengine_journalfile *journalfile;
int ret;
char path[RRDENG_PATH_MAX];
info("Creating new data and journal files in path %s", ctx->dbfiles_path);
datafile = mallocz(sizeof(*datafile));
datafile_init(datafile, ctx, tier, fileno);
ret = create_data_file(datafile);
Reported by FlawFinder.
collectors/python.d.plugin/squid/squid.chart.py
12 issues
Line: 6
Column: 1
# Author: Pawel Krupa (paulfantom)
# SPDX-License-Identifier: GPL-3.0-or-later
from bases.FrameworkServices.SocketService import SocketService
ORDER = [
'clients_net',
'clients_requests',
'servers_net',
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: squid netdata python.d module
# Author: Pawel Krupa (paulfantom)
# SPDX-License-Identifier: GPL-3.0-or-later
from bases.FrameworkServices.SocketService import SocketService
ORDER = [
'clients_net',
Reported by Pylint.
Line: 17
Column: 1
CHARTS = {
'clients_net': {
'options': [None, 'Squid Client Bandwidth', 'kilobits/s', 'clients', 'squid.clients_net', 'area'],
'lines': [
['client_http_kbytes_in', 'in', 'incremental', 8, 1],
['client_http_kbytes_out', 'out', 'incremental', -8, 1],
['client_http_hit_kbytes_out', 'hits', 'incremental', -8, 1]
]
Reported by Pylint.
Line: 25
Column: 1
]
},
'clients_requests': {
'options': [None, 'Squid Client Requests', 'requests/s', 'clients', 'squid.clients_requests', 'line'],
'lines': [
['client_http_requests', 'requests', 'incremental'],
['client_http_hits', 'hits', 'incremental'],
['client_http_errors', 'errors', 'incremental', -1, 1]
]
Reported by Pylint.
Line: 33
Column: 1
]
},
'servers_net': {
'options': [None, 'Squid Server Bandwidth', 'kilobits/s', 'servers', 'squid.servers_net', 'area'],
'lines': [
['server_all_kbytes_in', 'in', 'incremental', 8, 1],
['server_all_kbytes_out', 'out', 'incremental', -8, 1]
]
},
Reported by Pylint.
Line: 40
Column: 1
]
},
'servers_requests': {
'options': [None, 'Squid Server Requests', 'requests/s', 'servers', 'squid.servers_requests', 'line'],
'lines': [
['server_all_requests', 'requests', 'incremental'],
['server_all_errors', 'errors', 'incremental', -1, 1]
]
}
Reported by Pylint.
Line: 49
Column: 1
}
class Service(SocketService):
def __init__(self, configuration=None, name=None):
SocketService.__init__(self, configuration=configuration, name=name)
self._keep_alive = True
self.request = ''
self.host = 'localhost'
Reported by Pylint.
Line: 49
Column: 1
}
class Service(SocketService):
def __init__(self, configuration=None, name=None):
SocketService.__init__(self, configuration=configuration, name=name)
self._keep_alive = True
self.request = ''
self.host = 'localhost'
Reported by Pylint.
Line: 100
Column: 1
else:
self._keep_alive = False
if data[-7:] == '\r\n0\r\n\r\n' and 'transfer-encoding: chunked' in header: # HTTP/1.1 response
self.debug('received full response from squid')
return True
self.debug('waiting more data from squid')
return False
Reported by Pylint.
Line: 109
Column: 1
def check(self):
"""
Parse essential configuration, autodetect squid configuration (if needed), and check if data is available
:return: boolean
"""
self._parse_config()
# format request
req = self.request.decode()
Reported by Pylint.
collectors/python.d.plugin/python_modules/urllib3/util/connection.py
12 issues
Line: 4
Column: 1
# SPDX-License-Identifier: MIT
from __future__ import absolute_import
import socket
from .wait import wait_for_read
from .selectors import HAS_SELECT, SelectorError
def is_connection_dropped(conn): # Platform-specific
"""
Reported by Pylint.
Line: 5
Column: 1
from __future__ import absolute_import
import socket
from .wait import wait_for_read
from .selectors import HAS_SELECT, SelectorError
def is_connection_dropped(conn): # Platform-specific
"""
Returns True if the connection is dropped and should be closed.
Reported by Pylint.
Line: 37
Column: 40
# library test suite. Added to its signature is only `socket_options`.
# One additional modification is that we avoid binding to IPv6 servers
# discovered in DNS if the system doesn't have IPv6 functionality.
def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None, socket_options=None):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the optional
Reported by Pylint.
Line: 62
Column: 30
family = allowed_gai_family()
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
sock = None
try:
sock = socket.socket(af, socktype, proto)
# If provided, set socket level options before connecting.
Reported by Pylint.
Line: 70
Column: 31
# If provided, set socket level options before connecting.
_set_socket_options(sock, socket_options)
if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:
sock.settimeout(timeout)
if source_address:
sock.bind(source_address)
sock.connect(sa)
return sock
Reported by Pylint.
Line: 123
Column: 16
sock = socket.socket(socket.AF_INET6)
sock.bind((host, 0))
has_ipv6 = True
except Exception:
pass
if sock:
sock.close()
return has_ipv6
Reported by Pylint.
Line: 1
Column: 1
# SPDX-License-Identifier: MIT
from __future__ import absolute_import
import socket
from .wait import wait_for_read
from .selectors import HAS_SELECT, SelectorError
def is_connection_dropped(conn): # Platform-specific
"""
Reported by Pylint.
Line: 37
Column: 1
# library test suite. Added to its signature is only `socket_options`.
# One additional modification is that we avoid binding to IPv6 servers
# discovered in DNS if the system doesn't have IPv6 functionality.
def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None, socket_options=None):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the optional
Reported by Pylint.
Line: 62
Column: 9
family = allowed_gai_family()
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
sock = None
try:
sock = socket.socket(af, socktype, proto)
# If provided, set socket level options before connecting.
Reported by Pylint.
Line: 62
Column: 41
family = allowed_gai_family()
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
sock = None
try:
sock = socket.socket(af, socktype, proto)
# If provided, set socket level options before connecting.
Reported by Pylint.
collectors/python.d.plugin/spigotmc/spigotmc.chart.py
12 issues
Line: 10
Column: 1
import re
import socket
from bases.FrameworkServices.SimpleService import SimpleService
from third_party import mcrcon
# Update only every 5 seconds because collection takes in excess of
# 100ms sometimes, and most people won't care about second-by-second data.
update_every = 5
Reported by Pylint.
Line: 11
Column: 1
import socket
from bases.FrameworkServices.SimpleService import SimpleService
from third_party import mcrcon
# Update only every 5 seconds because collection takes in excess of
# 100ms sometimes, and most people won't care about second-by-second data.
update_every = 5
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: spigotmc netdata python.d module
# Author: Austin S. Hemmelgarn (Ferroin)
# SPDX-License-Identifier: GPL-3.0-or-later
import platform
import re
import socket
Reported by Pylint.
Line: 15
Column: 1
# Update only every 5 seconds because collection takes in excess of
# 100ms sometimes, and most people won't care about second-by-second data.
update_every = 5
PRECISION = 100
COMMAND_TPS = 'tps'
COMMAND_LIST = 'list'
Reported by Pylint.
Line: 64
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.host = self.configuration.get('host', 'localhost')
Reported by Pylint.
Line: 75
Column: 5
self.console = mcrcon.MCRcon()
self.alive = True
def check(self):
if platform.system() != 'Linux':
self.error('Only supported on Linux.')
return False
try:
self.connect()
Reported by Pylint.
Line: 88
Column: 5
return self._get_data()
def connect(self):
self.console.connect(self.host, self.port, self.password)
def reconnect(self):
self.error('try reconnect.')
try:
Reported by Pylint.
Line: 91
Column: 5
def connect(self):
self.console.connect(self.host, self.port, self.password)
def reconnect(self):
self.error('try reconnect.')
try:
try:
self.console.disconnect()
except mcrcon.MCRconException:
Reported by Pylint.
Line: 106
Column: 5
return False
return True
def is_alive(self):
if any(
[
not self.alive,
self.console.socket.getsockopt(socket.IPPROTO_TCP, socket.TCP_INFO, 0) != 1
]
Reported by Pylint.
Line: 116
Column: 5
return self.reconnect()
return True
def _get_data(self):
if not self.is_alive():
return None
data = {}
Reported by Pylint.