The following issues were found
web/api/web_api_v1.c
11 issues
Line: 97
Column: 2
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);
// unparse (to string)
char uuid_str[37];
uuid_unparse_lower(uuid, uuid_str);
}
char *get_mgmt_api_key(void) {
char filename[FILENAME_MAX + 1];
Reported by FlawFinder.
Line: 102
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 *get_mgmt_api_key(void) {
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/netdata.api.key", netdata_configured_varlib_dir);
char *api_key_filename=config_get(CONFIG_SECTION_REGISTRY, "netdata management api key file", filename);
static char guid[GUID_LEN + 1] = "";
if(likely(guid[0]))
Reported by FlawFinder.
Line: 105
Column: 12
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 filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/netdata.api.key", netdata_configured_varlib_dir);
char *api_key_filename=config_get(CONFIG_SECTION_REGISTRY, "netdata management api key file", filename);
static char guid[GUID_LEN + 1] = "";
if(likely(guid[0]))
return guid;
// read it from disk
Reported by FlawFinder.
Line: 111
Column: 14
CWE codes:
362
return guid;
// read it from disk
int fd = open(api_key_filename, O_RDONLY);
if(fd != -1) {
char buf[GUID_LEN + 1];
if(read(fd, buf, GUID_LEN) != GUID_LEN)
error("Failed to read management API key from '%s'", api_key_filename);
else {
Reported by FlawFinder.
Line: 113
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
// read it from disk
int fd = open(api_key_filename, O_RDONLY);
if(fd != -1) {
char buf[GUID_LEN + 1];
if(read(fd, buf, GUID_LEN) != GUID_LEN)
error("Failed to read management API key from '%s'", api_key_filename);
else {
buf[GUID_LEN] = '\0';
if(regenerate_guid(buf, guid) == -1) {
Reported by FlawFinder.
Line: 137
Column: 14
CWE codes:
362
guid[GUID_LEN] = '\0';
// save it
fd = open(api_key_filename, O_WRONLY|O_CREAT|O_TRUNC, 444);
if(fd == -1)
fatal("Cannot create unique management API key file '%s'. Please fix this.", api_key_filename);
if(write(fd, guid, GUID_LEN) != GUID_LEN)
fatal("Cannot write the unique management API key file '%s'. Please fix this.", api_key_filename);
Reported by FlawFinder.
Line: 665
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 person_guid[GUID_LEN + 1] = "";
debug(D_WEB_CLIENT, "%llu: API v1 registry with URL '%s'", w->id, url);
// TODO
// The browser may send multiple cookies with our id
Reported by FlawFinder.
Line: 889
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
}
inline void host_labels2json(RRDHOST *host, BUFFER *wb, size_t indentation) {
char tabs[11];
if (indentation > 10)
indentation = 10;
tabs[0] = '\0';
Reported by FlawFinder.
Line: 907
Column: 9
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
if(count > 0) buffer_strcat(wb, ",\n");
buffer_strcat(wb, tabs);
char value[CONFIG_MAX_VALUE * 2 + 1];
sanitize_json_string(value, label->value, CONFIG_MAX_VALUE * 2);
buffer_sprintf(wb, "\"%s\": \"%s\"", label->key, value);
count++;
}
Reported by FlawFinder.
Line: 114
Column: 12
CWE codes:
120
20
int fd = open(api_key_filename, O_RDONLY);
if(fd != -1) {
char buf[GUID_LEN + 1];
if(read(fd, buf, GUID_LEN) != GUID_LEN)
error("Failed to read management API key from '%s'", api_key_filename);
else {
buf[GUID_LEN] = '\0';
if(regenerate_guid(buf, guid) == -1) {
error("Failed to validate management API key '%s' from '%s'.",
Reported by FlawFinder.
collectors/python.d.plugin/apache/apache.chart.py
11 issues
Line: 6
Column: 1
# Author: Pawel Krupa (paulfantom)
# SPDX-License-Identifier: GPL-3.0-or-later
from bases.FrameworkServices.UrlService import UrlService
ORDER = [
'requests',
'connections',
'conns_async',
Reported by Pylint.
Line: 108
Column: 31
if not data:
return None
if LIGHTTPD_MARKER in data:
self.turn_into_lighttpd()
return True
def _get_data(self):
Reported by Pylint.
Line: 101
Column: 9
self.url = self.configuration.get('url', 'http://localhost/server-status?auto')
def check(self):
self._manager = self._build_manager()
data = self._get_data()
if not data:
return None
Reported by Pylint.
Line: 134
Column: 9
return data or None
def turn_into_lighttpd(self):
self.module_name = 'lighttpd'
for chart in self.definitions:
if chart == 'workers':
lines = self.definitions[chart]['lines']
lines[0] = ['idle_servers', 'idle']
lines[1] = ['busy_servers', 'busy']
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: apache netdata python.d module
# Author: Pawel Krupa (paulfantom)
# SPDX-License-Identifier: GPL-3.0-or-later
from bases.FrameworkServices.UrlService import UrlService
ORDER = [
'requests',
Reported by Pylint.
Line: 55
Column: 1
['sent', None, 'incremental', 8, 1]
]},
'connections': {
'options': [None, 'Connections', 'connections', 'connections', 'apache.connections', 'line'],
'lines': [
['connections']
]},
'conns_async': {
'options': [None, 'Async Connections', 'connections', 'connections', 'apache.conns_async', 'stacked'],
Reported by Pylint.
Line: 60
Column: 1
['connections']
]},
'conns_async': {
'options': [None, 'Async Connections', 'connections', 'connections', 'apache.conns_async', 'stacked'],
'lines': [
['keepalive'],
['closing'],
['writing']
]}
Reported by Pylint.
Line: 93
Column: 1
LIGHTTPD_MARKER = 'idle_servers'
class Service(UrlService):
def __init__(self, configuration=None, name=None):
UrlService.__init__(self, configuration=configuration, name=name)
self.order = ORDER
self.definitions = CHARTS
self.url = self.configuration.get('url', 'http://localhost/server-status?auto')
Reported by Pylint.
Line: 100
Column: 5
self.definitions = CHARTS
self.url = self.configuration.get('url', 'http://localhost/server-status?auto')
def check(self):
self._manager = self._build_manager()
data = self._get_data()
if not data:
Reported by Pylint.
Line: 133
Column: 5
return data or None
def turn_into_lighttpd(self):
self.module_name = 'lighttpd'
for chart in self.definitions:
if chart == 'workers':
lines = self.definitions[chart]['lines']
lines[0] = ['idle_servers', 'idle']
Reported by Pylint.
exporting/opentsdb/opentsdb.c
11 issues
Line: 161
Column: 9
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
if (!should_send_label(instance, label))
continue;
char value[CONFIG_MAX_VALUE + 1];
sanitize_opentsdb_label_value(value, label->value, CONFIG_MAX_VALUE);
if (*value)
buffer_sprintf(instance->labels, " %s=%s", label->key, value);
}
Reported by FlawFinder.
Line: 184
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 = rd->rrdset;
RRDHOST *host = st->rrdhost;
char chart_name[RRD_ID_LENGTH_MAX + 1];
exporting_name_copy(
chart_name,
(instance->config.options & EXPORTING_OPTION_SEND_NAMES && st->name) ? st->name : st->id,
RRD_ID_LENGTH_MAX);
Reported by FlawFinder.
Line: 190
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
(instance->config.options & EXPORTING_OPTION_SEND_NAMES && st->name) ? st->name : st->id,
RRD_ID_LENGTH_MAX);
char dimension_name[RRD_ID_LENGTH_MAX + 1];
exporting_name_copy(
dimension_name,
(instance->config.options & EXPORTING_OPTION_SEND_NAMES && rd->name) ? rd->name : rd->id,
RRD_ID_LENGTH_MAX);
Reported by FlawFinder.
Line: 224
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 = rd->rrdset;
RRDHOST *host = st->rrdhost;
char chart_name[RRD_ID_LENGTH_MAX + 1];
exporting_name_copy(
chart_name,
(instance->config.options & EXPORTING_OPTION_SEND_NAMES && st->name) ? st->name : st->id,
RRD_ID_LENGTH_MAX);
Reported by FlawFinder.
Line: 230
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
(instance->config.options & EXPORTING_OPTION_SEND_NAMES && st->name) ? st->name : st->id,
RRD_ID_LENGTH_MAX);
char dimension_name[RRD_ID_LENGTH_MAX + 1];
exporting_name_copy(
dimension_name,
(instance->config.options & EXPORTING_OPTION_SEND_NAMES && rd->name) ? rd->name : rd->id,
RRD_ID_LENGTH_MAX);
Reported by FlawFinder.
Line: 304
Column: 9
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
if (!should_send_label(instance, label))
continue;
char escaped_value[CONFIG_MAX_VALUE * 2 + 1];
sanitize_json_string(escaped_value, label->value, CONFIG_MAX_VALUE);
char value[CONFIG_MAX_VALUE + 1];
sanitize_opentsdb_label_value(value, escaped_value, CONFIG_MAX_VALUE);
Reported by FlawFinder.
Line: 307
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 escaped_value[CONFIG_MAX_VALUE * 2 + 1];
sanitize_json_string(escaped_value, label->value, CONFIG_MAX_VALUE);
char value[CONFIG_MAX_VALUE + 1];
sanitize_opentsdb_label_value(value, escaped_value, CONFIG_MAX_VALUE);
if (*value) {
buffer_strcat(instance->labels, ",");
buffer_sprintf(instance->labels, "\"%s\":\"%s\"", label->key, value);
Reported by FlawFinder.
Line: 332
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 = rd->rrdset;
RRDHOST *host = st->rrdhost;
char chart_name[RRD_ID_LENGTH_MAX + 1];
exporting_name_copy(
chart_name,
(instance->config.options & EXPORTING_OPTION_SEND_NAMES && st->name) ? st->name : st->id,
RRD_ID_LENGTH_MAX);
Reported by FlawFinder.
Line: 338
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
(instance->config.options & EXPORTING_OPTION_SEND_NAMES && st->name) ? st->name : st->id,
RRD_ID_LENGTH_MAX);
char dimension_name[RRD_ID_LENGTH_MAX + 1];
exporting_name_copy(
dimension_name,
(instance->config.options & EXPORTING_OPTION_SEND_NAMES && rd->name) ? rd->name : rd->id,
RRD_ID_LENGTH_MAX);
Reported by FlawFinder.
Line: 382
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 = rd->rrdset;
RRDHOST *host = st->rrdhost;
char chart_name[RRD_ID_LENGTH_MAX + 1];
exporting_name_copy(
chart_name,
(instance->config.options & EXPORTING_OPTION_SEND_NAMES && st->name) ? st->name : st->id,
RRD_ID_LENGTH_MAX);
Reported by FlawFinder.
collectors/python.d.plugin/python_modules/urllib3/__init__.py
11 issues
Line: 9
Column: 1
from __future__ import absolute_import
import warnings
from .connectionpool import (
HTTPConnectionPool,
HTTPSConnectionPool,
connection_from_url
)
Reported by Pylint.
Line: 16
Column: 1
)
from . import exceptions
from .filepost import encode_multipart_formdata
from .poolmanager import PoolManager, ProxyManager, proxy_from_url
from .response import HTTPResponse
from .util.request import make_headers
from .util.url import get_host
from .util.timeout import Timeout
Reported by Pylint.
Line: 17
Column: 1
from . import exceptions
from .filepost import encode_multipart_formdata
from .poolmanager import PoolManager, ProxyManager, proxy_from_url
from .response import HTTPResponse
from .util.request import make_headers
from .util.url import get_host
from .util.timeout import Timeout
from .util.retry import Retry
Reported by Pylint.
Line: 18
Column: 1
from . import exceptions
from .filepost import encode_multipart_formdata
from .poolmanager import PoolManager, ProxyManager, proxy_from_url
from .response import HTTPResponse
from .util.request import make_headers
from .util.url import get_host
from .util.timeout import Timeout
from .util.retry import Retry
Reported by Pylint.
Line: 19
Column: 1
from .filepost import encode_multipart_formdata
from .poolmanager import PoolManager, ProxyManager, proxy_from_url
from .response import HTTPResponse
from .util.request import make_headers
from .util.url import get_host
from .util.timeout import Timeout
from .util.retry import Retry
Reported by Pylint.
Line: 20
Column: 1
from .poolmanager import PoolManager, ProxyManager, proxy_from_url
from .response import HTTPResponse
from .util.request import make_headers
from .util.url import get_host
from .util.timeout import Timeout
from .util.retry import Retry
# Set default logging handler to avoid "No handler found" warnings.
Reported by Pylint.
Line: 21
Column: 1
from .response import HTTPResponse
from .util.request import make_headers
from .util.url import get_host
from .util.timeout import Timeout
from .util.retry import Retry
# Set default logging handler to avoid "No handler found" warnings.
import logging
Reported by Pylint.
Line: 22
Column: 1
from .util.request import make_headers
from .util.url import get_host
from .util.timeout import Timeout
from .util.retry import Retry
# Set default logging handler to avoid "No handler found" warnings.
import logging
try: # Python 2.7+
Reported by Pylint.
Line: 15
Column: 1
connection_from_url
)
from . import exceptions
from .filepost import encode_multipart_formdata
from .poolmanager import PoolManager, ProxyManager, proxy_from_url
from .response import HTTPResponse
from .util.request import make_headers
from .util.url import get_host
Reported by Pylint.
Line: 26
Column: 1
# Set default logging handler to avoid "No handler found" warnings.
import logging
try: # Python 2.7+
from logging import NullHandler
except ImportError:
class NullHandler(logging.Handler):
def emit(self, record):
Reported by Pylint.
collectors/python.d.plugin/python_modules/pyyaml2/error.py
11 issues
Line: 51
Column: 5
class MarkedYAMLError(YAMLError):
def __init__(self, context=None, context_mark=None,
problem=None, problem_mark=None, note=None):
self.context = context
self.context_mark = context_mark
self.problem = problem
self.problem_mark = problem_mark
Reported by Pylint.
Line: 1
Column: 1
# SPDX-License-Identifier: MIT
__all__ = ['Mark', 'YAMLError', 'MarkedYAMLError']
class Mark(object):
def __init__(self, name, index, line, column, buffer, pointer):
self.name = name
self.index = index
Reported by Pylint.
Line: 5
Column: 1
__all__ = ['Mark', 'YAMLError', 'MarkedYAMLError']
class Mark(object):
def __init__(self, name, index, line, column, buffer, pointer):
self.name = name
self.index = index
self.line = line
Reported by Pylint.
Line: 5
Column: 1
__all__ = ['Mark', 'YAMLError', 'MarkedYAMLError']
class Mark(object):
def __init__(self, name, index, line, column, buffer, pointer):
self.name = name
self.index = index
self.line = line
Reported by Pylint.
Line: 7
Column: 5
class Mark(object):
def __init__(self, name, index, line, column, buffer, pointer):
self.name = name
self.index = index
self.line = line
self.column = column
self.buffer = buffer
Reported by Pylint.
Line: 15
Column: 5
self.buffer = buffer
self.pointer = pointer
def get_snippet(self, indent=4, max_length=75):
if self.buffer is None:
return None
head = ''
start = self.pointer
while start > 0 and self.buffer[start-1] not in u'\0\r\n\x85\u2028\u2029':
Reported by Pylint.
Line: 46
Column: 1
where += ":\n"+snippet
return where
class YAMLError(Exception):
pass
class MarkedYAMLError(YAMLError):
def __init__(self, context=None, context_mark=None,
Reported by Pylint.
Line: 49
Column: 1
class YAMLError(Exception):
pass
class MarkedYAMLError(YAMLError):
def __init__(self, context=None, context_mark=None,
problem=None, problem_mark=None, note=None):
self.context = context
self.context_mark = context_mark
Reported by Pylint.
Line: 51
Column: 5
class MarkedYAMLError(YAMLError):
def __init__(self, context=None, context_mark=None,
problem=None, problem_mark=None, note=None):
self.context = context
self.context_mark = context_mark
self.problem = problem
self.problem_mark = problem_mark
Reported by Pylint.
Line: 63
Column: 12
lines = []
if self.context is not None:
lines.append(self.context)
if self.context_mark is not None \
and (self.problem is None or self.problem_mark is None
or self.context_mark.name != self.problem_mark.name
or self.context_mark.line != self.problem_mark.line
or self.context_mark.column != self.problem_mark.column):
lines.append(str(self.context_mark))
Reported by Pylint.
collectors/ebpf.plugin/ebpf_apps.c
11 issues
Line: 272
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 ebpf_read_apps_groups_conf(struct target **agdt, struct target **agrt, const char *path, const char *file)
{
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/apps_%s.conf", path, file);
// ----------------------------------------
Reported by FlawFinder.
Line: 552
Column: 12
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 inline int read_proc_pid_cmdline(struct pid_stat *p)
{
static char cmdline[MAX_CMDLINE + 1];
if (unlikely(!p->cmdline_filename)) {
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/proc/%d/cmdline", netdata_configured_host_prefix, p->pid);
p->cmdline_filename = strdupz(filename);
Reported by FlawFinder.
Line: 555
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
static char cmdline[MAX_CMDLINE + 1];
if (unlikely(!p->cmdline_filename)) {
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/proc/%d/cmdline", netdata_configured_host_prefix, p->pid);
p->cmdline_filename = strdupz(filename);
}
int fd = open(p->cmdline_filename, procfile_open_flags, 0666);
Reported by FlawFinder.
Line: 560
Column: 14
CWE codes:
362
p->cmdline_filename = strdupz(filename);
}
int fd = open(p->cmdline_filename, procfile_open_flags, 0666);
if (unlikely(fd == -1))
goto cleanup;
ssize_t i, bytes = read(fd, cmdline, MAX_CMDLINE);
close(fd);
Reported by FlawFinder.
Line: 606
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
static procfile *ff = NULL;
if (unlikely(!p->stat_filename)) {
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/proc/%d/stat", netdata_configured_host_prefix, p->pid);
p->stat_filename = strdupz(filename);
}
int set_quotes = (!ff) ? 1 : 0;
Reported by FlawFinder.
Line: 991
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 inline void read_proc_filesystem()
{
char dirname[FILENAME_MAX + 1];
snprintfz(dirname, FILENAME_MAX, "%s/proc", netdata_configured_host_prefix);
DIR *dir = opendir(dirname);
if (!dir)
return;
Reported by FlawFinder.
Line: 230
Column: 18
CWE codes:
126
strncpyz(w->name, nid, MAX_NAME);
strncpyz(w->compare, nid, MAX_COMPARE_NAME);
size_t len = strlen(w->compare);
if (w->compare[len - 1] == '*') {
w->compare[len - 1] = '\0';
w->starts_with = 1;
}
w->ends_with = ends_with;
Reported by FlawFinder.
Line: 241
Column: 21
CWE codes:
126
proc_pid_cmdline_is_needed = 1;
w->comparehash = simple_hash(w->compare);
w->comparelen = strlen(w->compare);
w->hidden = thidden;
#ifdef NETDATA_INTERNAL_CHECKS
w->debug_enabled = tdebug;
#else
Reported by FlawFinder.
Line: 510
Column: 20
CWE codes:
126
targets_assignment_counter++;
uint32_t hash = simple_hash(p->comm);
size_t pclen = strlen(p->comm);
struct target *w;
for (w = apps_groups_root_target; w; w = w->next) {
// if(debug_enabled || (p->target && p->target->debug_enabled)) debug_log_int("\t\tcomparing '%s' with '%s'", w->compare, p->comm);
Reported by FlawFinder.
collectors/python.d.plugin/ovpn_status_log/ovpn_status_log.chart.py
11 issues
Line: 8
Column: 1
import re
from bases.FrameworkServices.SimpleService import SimpleService
update_every = 10
ORDER = [
'users',
Reported by Pylint.
Line: 65
Column: 17
found = None
for row in data:
if 'ROUTING' in row:
self.get_data = self.get_data_tls
found = True
break
elif 'STATISTICS' in row:
self.get_data = self.get_data_static_key
found = True
Reported by Pylint.
Line: 69
Column: 17
found = True
break
elif 'STATISTICS' in row:
self.get_data = self.get_data_static_key
found = True
break
if found:
return True
self.error('Failed to parse openvpn log file')
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: openvpn status log netdata python.d module
# Author: ilyam8
# SPDX-License-Identifier: GPL-3.0-or-later
import re
from bases.FrameworkServices.SimpleService import SimpleService
Reported by Pylint.
Line: 10
Column: 1
from bases.FrameworkServices.SimpleService import SimpleService
update_every = 10
ORDER = [
'users',
'traffic',
]
Reported by Pylint.
Line: 19
Column: 1
CHARTS = {
'users': {
'options': [None, 'OpenVPN Active Users', 'active users', 'users', 'openvpn_status.users', 'line'],
'lines': [
['users', None, 'absolute'],
]
},
'traffic': {
Reported by Pylint.
Line: 34
Column: 1
}
TLS_REGEX = re.compile(
r'(?:[0-9a-f]+:[0-9a-f:]+|(?:\d{1,3}(?:\.\d{1,3}){3}(?::\d+)?)) (?P<bytes_in>\d+) (?P<bytes_out>\d+)'
)
STATIC_KEY_REGEX = re.compile(
r'TCP/[A-Z]+ (?P<direction>(?:read|write)) bytes,(?P<bytes>\d+)'
)
Reported by Pylint.
Line: 41
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.log_path = self.configuration.get('log_path')
Reported by Pylint.
Line: 52
Column: 5
'static_key': STATIC_KEY_REGEX
}
def check(self):
if not (self.log_path and isinstance(self.log_path, str)):
self.error("'log_path' is not defined")
return False
data = self._get_raw_data()
Reported by Pylint.
Line: 59
Column: 1
data = self._get_raw_data()
if not data:
self.error('Make sure that the openvpn status log file exists and netdata has permission to read it')
return None
found = None
for row in data:
if 'ROUTING' in row:
Reported by Pylint.
collectors/python.d.plugin/python_modules/bases/collection.py
11 issues
Line: 115
Column: 16
return unicode(arg, errors='ignore')
# https://github.com/netdata/netdata/issues/7642
except TypeError:
return unicode(arg)
except NameError:
return str(arg)
Reported by Pylint.
Line: 42
Column: 20
def wrapper(*args, **kwargs):
try:
func(*args, **kwargs)
except Exception:
if except_func:
except_func(*on_except[1:])
finally:
if finally_func:
finally_func(*on_finally[1:])
Reported by Pylint.
Line: 107
Column: 3
:param arg:
:return: <str>
"""
# TODO: fix
try:
# https://github.com/netdata/netdata/issues/7613
if isinstance(arg, unicode):
return arg
return unicode(arg, errors='ignore')
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description:
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later
import os
from threading import Lock
Reported by Pylint.
Line: 20
Column: 1
print_lock = Lock()
def setdefault_values(config, base_dict):
for key, value in base_dict.items():
config.setdefault(key, value)
return config
Reported by Pylint.
Line: 26
Column: 1
return config
def run_and_exit(func):
def wrapper(*args, **kwargs):
func(*args, **kwargs)
exit(1)
return wrapper
Reported by Pylint.
Line: 29
Column: 9
def run_and_exit(func):
def wrapper(*args, **kwargs):
func(*args, **kwargs)
exit(1)
return wrapper
def on_try_except_finally(on_except=(None,), on_finally=(None,)):
Reported by Pylint.
Line: 34
Column: 1
return wrapper
def on_try_except_finally(on_except=(None,), on_finally=(None,)):
except_func = on_except[0]
finally_func = on_finally[0]
def decorator(func):
def wrapper(*args, **kwargs):
Reported by Pylint.
Line: 54
Column: 1
return decorator
def static_vars(**kwargs):
def decorate(func):
for k in kwargs:
setattr(func, k, kwargs[k])
return func
Reported by Pylint.
Line: 86
Column: 1
return None
def read_last_line(f):
with open(f, 'rb') as opened:
opened.seek(-2, 2)
while opened.read(1) != b'\n':
opened.seek(-2, 1)
if opened.tell() == 0:
Reported by Pylint.
aclk/aclk.c
11 issues
Line: 205
Column: 5
CWE codes:
134
Suggestion:
Use a constant for the format specification
#define FN_MAX_LEN 512
char filename[FN_MAX_LEN];
int logfd;
snprintf(filename, FN_MAX_LEN, ACLK_LOG_CONVERSATION_DIR "/%010d-rx.json", ACLK_GET_CONV_LOG_NEXT());
logfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR );
if(logfd < 0)
error("Error opening ACLK Conversation logfile \"%s\" for RX message.", filename);
write(logfd, msg, msglen);
close(logfd);
Reported by FlawFinder.
Line: 254
Column: 5
CWE codes:
134
Suggestion:
Use a constant for the format specification
#define FN_MAX_LEN 512
char filename[FN_MAX_LEN];
int logfd;
snprintf(filename, FN_MAX_LEN, ACLK_LOG_CONVERSATION_DIR "/%010d-rx-%s.bin", ACLK_GET_CONV_LOG_NEXT(), msgtype);
logfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR );
if(logfd < 0)
error("Error opening ACLK Conversation logfile \"%s\" for RX message.", filename);
write(logfd, msg, msglen);
close(logfd);
Reported by FlawFinder.
Line: 53
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
if (aclk_private_key != NULL)
RSA_free(aclk_private_key);
aclk_private_key = NULL;
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/cloud.d/private.pem", netdata_configured_varlib_dir);
long bytes_read;
char *private_key = read_by_filename(filename, &bytes_read);
if (!private_key) {
Reported by FlawFinder.
Line: 77
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
freez(private_key);
return 0;
}
char err[512];
ERR_error_string_n(ERR_get_error(), err, sizeof(err));
error("Claimed agent cannot establish ACLK - cannot create private key: %s", err);
biofailed:
freez(private_key);
Reported by FlawFinder.
Line: 185
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
#define RX_MSGLEN_MAX 4096
static void msg_callback(const char *topic, const void *msg, size_t msglen, int qos)
{
char cmsg[RX_MSGLEN_MAX];
size_t len = (msglen < RX_MSGLEN_MAX - 1) ? msglen : (RX_MSGLEN_MAX - 1);
const char *cmd_topic = aclk_get_topic(ACLK_TOPICID_COMMAND);
if (!cmd_topic) {
error("Error retrieving command topic");
return;
Reported by FlawFinder.
Line: 196
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (msglen > RX_MSGLEN_MAX - 1)
error("Incoming ACLK message was bigger than MAX of %d and got truncated.", RX_MSGLEN_MAX);
memcpy(cmsg,
msg,
len);
cmsg[len] = 0;
#ifdef ACLK_LOG_CONVERSATION_DIR
Reported by FlawFinder.
Line: 203
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
#ifdef ACLK_LOG_CONVERSATION_DIR
#define FN_MAX_LEN 512
char filename[FN_MAX_LEN];
int logfd;
snprintf(filename, FN_MAX_LEN, ACLK_LOG_CONVERSATION_DIR "/%010d-rx.json", ACLK_GET_CONV_LOG_NEXT());
logfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR );
if(logfd < 0)
error("Error opening ACLK Conversation logfile \"%s\" for RX message.", filename);
Reported by FlawFinder.
Line: 206
Column: 13
CWE codes:
362
char filename[FN_MAX_LEN];
int logfd;
snprintf(filename, FN_MAX_LEN, ACLK_LOG_CONVERSATION_DIR "/%010d-rx.json", ACLK_GET_CONV_LOG_NEXT());
logfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR );
if(logfd < 0)
error("Error opening ACLK Conversation logfile \"%s\" for RX message.", filename);
write(logfd, msg, msglen);
close(logfd);
#endif
Reported by FlawFinder.
Line: 252
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
#ifdef ACLK_LOG_CONVERSATION_DIR
#define FN_MAX_LEN 512
char filename[FN_MAX_LEN];
int logfd;
snprintf(filename, FN_MAX_LEN, ACLK_LOG_CONVERSATION_DIR "/%010d-rx-%s.bin", ACLK_GET_CONV_LOG_NEXT(), msgtype);
logfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR );
if(logfd < 0)
error("Error opening ACLK Conversation logfile \"%s\" for RX message.", filename);
Reported by FlawFinder.
Line: 255
Column: 13
CWE codes:
362
char filename[FN_MAX_LEN];
int logfd;
snprintf(filename, FN_MAX_LEN, ACLK_LOG_CONVERSATION_DIR "/%010d-rx-%s.bin", ACLK_GET_CONV_LOG_NEXT(), msgtype);
logfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR );
if(logfd < 0)
error("Error opening ACLK Conversation logfile \"%s\" for RX message.", filename);
write(logfd, msg, msglen);
close(logfd);
#endif
Reported by FlawFinder.
collectors/python.d.plugin/samba/samba.chart.py
11 issues
Line: 22
Column: 1
import re
import os
from bases.FrameworkServices.ExecutableService import ExecutableService
from bases.collection import find_binary
disabled_by_default = True
update_every = 5
Reported by Pylint.
Line: 23
Column: 1
import os
from bases.FrameworkServices.ExecutableService import ExecutableService
from bases.collection import find_binary
disabled_by_default = True
update_every = 5
Reported by Pylint.
Line: 117
Column: 13
return False
if os.getuid() == 0:
self.command = ' '.join([smbstatus_binary, '-P'])
return ExecutableService.check(self)
sudo_binary = find_binary(SUDO)
if not sudo_binary:
self.error("can't locate '{0}' binary".format(SUDO))
Reported by Pylint.
Line: 130
Column: 9
if not (allowed and allowed[0].strip() == smbstatus):
self.error("not allowed to run sudo for command '{0}'".format(smbstatus))
return False
self.command = ' '.join([sudo_binary, '-n', smbstatus_binary, '-P'])
return ExecutableService.check(self)
def _get_data(self):
"""
Format data received from shell command
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: samba netdata python.d module
# Author: Christopher Cox <chris_cox@endlessnow.com>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# The netdata user needs to be able to be able to sudo the smbstatus program
# without password:
# netdata ALL=(ALL) NOPASSWD: /usr/bin/smbstatus -P
#
Reported by Pylint.
Line: 25
Column: 1
from bases.FrameworkServices.ExecutableService import ExecutableService
from bases.collection import find_binary
disabled_by_default = True
update_every = 5
ORDER = [
'syscall_rw',
Reported by Pylint.
Line: 27
Column: 1
disabled_by_default = True
update_every = 5
ORDER = [
'syscall_rw',
'smb2_rw',
'smb2_create_close',
Reported by Pylint.
Line: 103
Column: 1
SMBSTATUS = 'smbstatus'
class Service(ExecutableService):
def __init__(self, configuration=None, name=None):
ExecutableService.__init__(self, configuration=configuration, name=name)
self.order = ORDER
self.definitions = CHARTS
self.rgx_smb2 = re.compile(r'(smb2_[^:]+|syscall_.*file_bytes):\s+(\d+)')
Reported by Pylint.
Line: 103
Column: 1
SMBSTATUS = 'smbstatus'
class Service(ExecutableService):
def __init__(self, configuration=None, name=None):
ExecutableService.__init__(self, configuration=configuration, name=name)
self.order = ORDER
self.definitions = CHARTS
self.rgx_smb2 = re.compile(r'(smb2_[^:]+|syscall_.*file_bytes):\s+(\d+)')
Reported by Pylint.
Line: 110
Column: 5
self.definitions = CHARTS
self.rgx_smb2 = re.compile(r'(smb2_[^:]+|syscall_.*file_bytes):\s+(\d+)')
def check(self):
smbstatus_binary = find_binary(SMBSTATUS)
if not smbstatus_binary:
self.error("can't locate '{0}' binary".format(SMBSTATUS))
return False
Reported by Pylint.