The following issues were found
collectors/ebpf.plugin/ebpf_socket.c
41 issues
Line: 945
Column: 12
CWE codes:
134
Suggestion:
Use a constant for the format specification
static inline int build_outbound_dimension_name(char *dimname, char *hostname, char *service_name,
char *proto, int family)
{
return snprintf(dimname, CONFIG_MAX_NAME - 7, (family == AF_INET)?"%s:%s:%s_":"%s:%s:[%s]_",
service_name, proto,
hostname);
}
/**
Reported by FlawFinder.
Line: 2819
Column: 25
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
}
}
char *port_string = getenv("NETDATA_LISTEN_PORT");
if (port_string) {
// if variable has an invalid value, we assume netdata is using 19999
int default_port = str2i(port_string);
if (default_port > 0 && default_port < 65536)
link_dimension_name(port_string, simple_hash(port_string), "Netdata");
Reported by FlawFinder.
Line: 14
Column: 8
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 *socket_dimension_names[NETDATA_MAX_SOCKET_VECTOR] = { "sent", "received", "close", "sent",
"received", "retransmitted" };
static char *socket_id_names[NETDATA_MAX_SOCKET_VECTOR] = { "tcp_sendmsg", "tcp_cleanup_rbuf", "tcp_close",
"udp_sendmsg", "udp_recvmsg", "tcp_retransmit_skb" };
static ebpf_local_maps_t socket_maps[] = {{.name = "tbl_bandwidth",
Reported by FlawFinder.
Line: 16
Column: 8
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 *socket_dimension_names[NETDATA_MAX_SOCKET_VECTOR] = { "sent", "received", "close", "sent",
"received", "retransmitted" };
static char *socket_id_names[NETDATA_MAX_SOCKET_VECTOR] = { "tcp_sendmsg", "tcp_cleanup_rbuf", "tcp_close",
"udp_sendmsg", "udp_recvmsg", "tcp_retransmit_skb" };
static ebpf_local_maps_t socket_maps[] = {{.name = "tbl_bandwidth",
.internal_input = NETDATA_COMPILED_CONNECTIONS_ALLOWED,
.user_input = NETDATA_MAXIMUM_CONNECTIONS_ALLOWED},
Reported by FlawFinder.
Line: 987
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
else {
length = NETDATA_MAX_NETWORK_COMBINED_LENGTH;
ptr->resolved_name = mallocz( NETDATA_MAX_NETWORK_COMBINED_LENGTH + 1);
memcpy(ptr->resolved_name, hostname, length);
ptr->resolved_name[length] = '\0';
}
char dimname[CONFIG_MAX_NAME];
int size;
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
ptr->resolved_name[length] = '\0';
}
char dimname[CONFIG_MAX_NAME];
int size;
char *protocol;
if (ptr->sock.protocol == IPPROTO_UDP) {
protocol = "UDP";
} else if (ptr->sock.protocol == IPPROTO_TCP) {
Reported by FlawFinder.
Line: 1008
Column: 9
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
size = build_inbound_dimension_name(dimname,service_name, protocol);
if (size > 0) {
strcpy(&dimname[size], "sent");
dimname[size + 4] = '\0';
ptr->dimension_sent = strdupz(dimname);
strcpy(&dimname[size], "recv");
ptr->dimension_recv = strdupz(dimname);
Reported by FlawFinder.
Line: 1012
Column: 9
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
dimname[size + 4] = '\0';
ptr->dimension_sent = strdupz(dimname);
strcpy(&dimname[size], "recv");
ptr->dimension_recv = strdupz(dimname);
dimname[size - 1] = '\0';
ptr->dimension_retransmit = strdupz(dimname);
}
Reported by FlawFinder.
Line: 1032
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 fill_names(netdata_socket_plot_t *ptr, int is_outbound)
{
char hostname[NI_MAXHOST], service_name[NI_MAXSERV];
if (ptr->resolved)
return 1;
int ret;
static int resolve_name = -1;
Reported by FlawFinder.
Line: 1085
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
myaddr6.sin6_family = AF_INET6;
if (is_outbound) {
myaddr6.sin6_port = idx->dport;
memcpy(myaddr6.sin6_addr.s6_addr, idx->daddr.addr8, sizeof(union netdata_ip_t));
} else {
myaddr6.sin6_port = idx->sport;
memcpy(myaddr6.sin6_addr.s6_addr, idx->saddr.addr8, sizeof(union netdata_ip_t));
}
Reported by FlawFinder.
collectors/python.d.plugin/python_modules/urllib3/contrib/appengine.py
41 issues
Line: 46
Column: 1
import logging
import os
import warnings
from ..packages.six.moves.urllib.parse import urljoin
from ..exceptions import (
HTTPError,
HTTPWarning,
MaxRetryError,
Reported by Pylint.
Line: 48
Column: 1
import warnings
from ..packages.six.moves.urllib.parse import urljoin
from ..exceptions import (
HTTPError,
HTTPWarning,
MaxRetryError,
ProtocolError,
TimeoutError,
Reported by Pylint.
Line: 57
Column: 1
SSLError
)
from ..packages.six import BytesIO
from ..request import RequestMethods
from ..response import HTTPResponse
from ..util.timeout import Timeout
from ..util.retry import Retry
Reported by Pylint.
Line: 58
Column: 1
)
from ..packages.six import BytesIO
from ..request import RequestMethods
from ..response import HTTPResponse
from ..util.timeout import Timeout
from ..util.retry import Retry
try:
Reported by Pylint.
Line: 59
Column: 1
from ..packages.six import BytesIO
from ..request import RequestMethods
from ..response import HTTPResponse
from ..util.timeout import Timeout
from ..util.retry import Retry
try:
from google.appengine.api import urlfetch
Reported by Pylint.
Line: 60
Column: 1
from ..packages.six import BytesIO
from ..request import RequestMethods
from ..response import HTTPResponse
from ..util.timeout import Timeout
from ..util.retry import Retry
try:
from google.appengine.api import urlfetch
except ImportError:
Reported by Pylint.
Line: 61
Column: 1
from ..request import RequestMethods
from ..response import HTTPResponse
from ..util.timeout import Timeout
from ..util.retry import Retry
try:
from google.appengine.api import urlfetch
except ImportError:
urlfetch = None
Reported by Pylint.
Line: 48
Column: 1
import warnings
from ..packages.six.moves.urllib.parse import urljoin
from ..exceptions import (
HTTPError,
HTTPWarning,
MaxRetryError,
ProtocolError,
TimeoutError,
Reported by Pylint.
Line: 153
Column: 13
validate_certificate=self.validate_certificate,
)
except urlfetch.DeadlineExceededError as e:
raise TimeoutError(self, e)
except urlfetch.InvalidURLError as e:
if 'too large' in str(e):
raise AppEnginePlatformError(
"URLFetch request too large, URLFetch only "
Reported by Pylint.
Line: 157
Column: 17
except urlfetch.InvalidURLError as e:
if 'too large' in str(e):
raise AppEnginePlatformError(
"URLFetch request too large, URLFetch only "
"supports requests up to 10mb in size.", e)
raise ProtocolError(e)
except urlfetch.DownloadError as e:
Reported by Pylint.
collectors/python.d.plugin/python_modules/pyyaml3/events.py
40 issues
Line: 17
Column: 5
return '%s(%s)' % (self.__class__.__name__, arguments)
class NodeEvent(Event):
def __init__(self, anchor, start_mark=None, end_mark=None):
self.anchor = anchor
self.start_mark = start_mark
self.end_mark = end_mark
class CollectionStartEvent(NodeEvent):
Reported by Pylint.
Line: 23
Column: 5
self.end_mark = end_mark
class CollectionStartEvent(NodeEvent):
def __init__(self, anchor, tag, implicit, start_mark=None, end_mark=None,
flow_style=None):
self.anchor = anchor
self.tag = tag
self.implicit = implicit
self.start_mark = start_mark
Reported by Pylint.
Line: 38
Column: 5
# Implementations.
class StreamStartEvent(Event):
def __init__(self, start_mark=None, end_mark=None, encoding=None):
self.start_mark = start_mark
self.end_mark = end_mark
self.encoding = encoding
class StreamEndEvent(Event):
Reported by Pylint.
Line: 47
Column: 5
pass
class DocumentStartEvent(Event):
def __init__(self, start_mark=None, end_mark=None,
explicit=None, version=None, tags=None):
self.start_mark = start_mark
self.end_mark = end_mark
self.explicit = explicit
self.version = version
Reported by Pylint.
Line: 56
Column: 5
self.tags = tags
class DocumentEndEvent(Event):
def __init__(self, start_mark=None, end_mark=None,
explicit=None):
self.start_mark = start_mark
self.end_mark = end_mark
self.explicit = explicit
Reported by Pylint.
Line: 66
Column: 5
pass
class ScalarEvent(NodeEvent):
def __init__(self, anchor, tag, implicit, value,
start_mark=None, end_mark=None, style=None):
self.anchor = anchor
self.tag = tag
self.implicit = implicit
self.value = value
Reported by Pylint.
Line: 1
Column: 1
# SPDX-License-Identifier: MIT
# Abstract classes.
class Event(object):
def __init__(self, start_mark=None, end_mark=None):
self.start_mark = start_mark
self.end_mark = end_mark
def __repr__(self):
Reported by Pylint.
Line: 5
Column: 1
# Abstract classes.
class Event(object):
def __init__(self, start_mark=None, end_mark=None):
self.start_mark = start_mark
self.end_mark = end_mark
def __repr__(self):
attributes = [key for key in ['anchor', 'tag', 'implicit', 'value']
Reported by Pylint.
Line: 5
Column: 1
# Abstract classes.
class Event(object):
def __init__(self, start_mark=None, end_mark=None):
self.start_mark = start_mark
self.end_mark = end_mark
def __repr__(self):
attributes = [key for key in ['anchor', 'tag', 'implicit', 'value']
Reported by Pylint.
Line: 5
Column: 1
# Abstract classes.
class Event(object):
def __init__(self, start_mark=None, end_mark=None):
self.start_mark = start_mark
self.end_mark = end_mark
def __repr__(self):
attributes = [key for key in ['anchor', 'tag', 'implicit', 'value']
Reported by Pylint.
collectors/python.d.plugin/python_modules/pyyaml2/events.py
40 issues
Line: 17
Column: 5
return '%s(%s)' % (self.__class__.__name__, arguments)
class NodeEvent(Event):
def __init__(self, anchor, start_mark=None, end_mark=None):
self.anchor = anchor
self.start_mark = start_mark
self.end_mark = end_mark
class CollectionStartEvent(NodeEvent):
Reported by Pylint.
Line: 23
Column: 5
self.end_mark = end_mark
class CollectionStartEvent(NodeEvent):
def __init__(self, anchor, tag, implicit, start_mark=None, end_mark=None,
flow_style=None):
self.anchor = anchor
self.tag = tag
self.implicit = implicit
self.start_mark = start_mark
Reported by Pylint.
Line: 38
Column: 5
# Implementations.
class StreamStartEvent(Event):
def __init__(self, start_mark=None, end_mark=None, encoding=None):
self.start_mark = start_mark
self.end_mark = end_mark
self.encoding = encoding
class StreamEndEvent(Event):
Reported by Pylint.
Line: 47
Column: 5
pass
class DocumentStartEvent(Event):
def __init__(self, start_mark=None, end_mark=None,
explicit=None, version=None, tags=None):
self.start_mark = start_mark
self.end_mark = end_mark
self.explicit = explicit
self.version = version
Reported by Pylint.
Line: 56
Column: 5
self.tags = tags
class DocumentEndEvent(Event):
def __init__(self, start_mark=None, end_mark=None,
explicit=None):
self.start_mark = start_mark
self.end_mark = end_mark
self.explicit = explicit
Reported by Pylint.
Line: 66
Column: 5
pass
class ScalarEvent(NodeEvent):
def __init__(self, anchor, tag, implicit, value,
start_mark=None, end_mark=None, style=None):
self.anchor = anchor
self.tag = tag
self.implicit = implicit
self.value = value
Reported by Pylint.
Line: 1
Column: 1
# SPDX-License-Identifier: MIT
# Abstract classes.
class Event(object):
def __init__(self, start_mark=None, end_mark=None):
self.start_mark = start_mark
self.end_mark = end_mark
def __repr__(self):
Reported by Pylint.
Line: 5
Column: 1
# Abstract classes.
class Event(object):
def __init__(self, start_mark=None, end_mark=None):
self.start_mark = start_mark
self.end_mark = end_mark
def __repr__(self):
attributes = [key for key in ['anchor', 'tag', 'implicit', 'value']
Reported by Pylint.
Line: 5
Column: 1
# Abstract classes.
class Event(object):
def __init__(self, start_mark=None, end_mark=None):
self.start_mark = start_mark
self.end_mark = end_mark
def __repr__(self):
attributes = [key for key in ['anchor', 'tag', 'implicit', 'value']
Reported by Pylint.
Line: 5
Column: 1
# Abstract classes.
class Event(object):
def __init__(self, start_mark=None, end_mark=None):
self.start_mark = start_mark
self.end_mark = end_mark
def __repr__(self):
attributes = [key for key in ['anchor', 'tag', 'implicit', 'value']
Reported by Pylint.
aclk/legacy/tests/paho-inspection.py
39 issues
Line: 2
Column: 1
import ssl
import paho.mqtt.client as mqtt
import json
import time
import sys
def on_connect(mqttc, obj, flags, rc):
if rc==0:
print("Successful connection", flush=True)
Reported by Pylint.
Line: 7
Column: 16
import time
import sys
def on_connect(mqttc, obj, flags, rc):
if rc==0:
print("Successful connection", flush=True)
else :
print(f"Connection error rc={rc}", flush=True)
mqttc.subscribe("/agent/#",0)
Reported by Pylint.
Line: 7
Column: 28
import time
import sys
def on_connect(mqttc, obj, flags, rc):
if rc==0:
print("Successful connection", flush=True)
else :
print(f"Connection error rc={rc}", flush=True)
mqttc.subscribe("/agent/#",0)
Reported by Pylint.
Line: 7
Column: 23
import time
import sys
def on_connect(mqttc, obj, flags, rc):
if rc==0:
print("Successful connection", flush=True)
else :
print(f"Connection error rc={rc}", flush=True)
mqttc.subscribe("/agent/#",0)
Reported by Pylint.
Line: 14
Column: 31
print(f"Connection error rc={rc}", flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(f"{msg.topic} {len(msg.payload)}-bytes qos={msg.qos}", flush=True)
try:
Reported by Pylint.
Line: 14
Column: 26
print(f"Connection error rc={rc}", flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(f"{msg.topic} {len(msg.payload)}-bytes qos={msg.qos}", flush=True)
try:
Reported by Pylint.
Line: 14
Column: 19
print(f"Connection error rc={rc}", flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(f"{msg.topic} {len(msg.payload)}-bytes qos={msg.qos}", flush=True)
try:
Reported by Pylint.
Line: 14
Column: 19
print(f"Connection error rc={rc}", flush=True)
mqttc.subscribe("/agent/#",0)
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(f"{msg.topic} {len(msg.payload)}-bytes qos={msg.qos}", flush=True)
try:
Reported by Pylint.
Line: 17
Column: 23
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(f"{msg.topic} {len(msg.payload)}-bytes qos={msg.qos}", flush=True)
try:
print(f"Trying decode of {msg.payload[:60]}",flush=True)
api_msg = json.loads(msg.payload)
except Exception as e:
Reported by Pylint.
Line: 17
Column: 16
def on_disconnect(mqttc, obj, flags, rc):
print("disconnected rc: "+str(rc), flush=True)
def on_message(mqttc, obj, msg):
print(f"{msg.topic} {len(msg.payload)}-bytes qos={msg.qos}", flush=True)
try:
print(f"Trying decode of {msg.payload[:60]}",flush=True)
api_msg = json.loads(msg.payload)
except Exception as e:
Reported by Pylint.
collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py
38 issues
Line: 13
Column: 1
except ImportError:
HAS_RETHINKDB = False
from bases.FrameworkServices.SimpleService import SimpleService
ORDER = [
'cluster_connected_servers',
'cluster_clients_active',
'cluster_queries',
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: rethinkdb netdata python.d module
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later
try:
import rethinkdb as rdb
HAS_RETHINKDB = True
Reported by Pylint.
Line: 23
Column: 1
]
def cluster_charts():
return {
'cluster_connected_servers': {
'options': [None, 'Connected Servers', 'servers', 'cluster', 'rethinkdb.cluster_connected_servers',
'stacked'],
'lines': [
Reported by Pylint.
Line: 26
Column: 1
def cluster_charts():
return {
'cluster_connected_servers': {
'options': [None, 'Connected Servers', 'servers', 'cluster', 'rethinkdb.cluster_connected_servers',
'stacked'],
'lines': [
['cluster_servers_connected', 'connected'],
['cluster_servers_missing', 'missing'],
]
Reported by Pylint.
Line: 34
Column: 1
]
},
'cluster_clients_active': {
'options': [None, 'Active Clients', 'clients', 'cluster', 'rethinkdb.cluster_clients_active',
'line'],
'lines': [
['cluster_clients_active', 'active'],
]
},
Reported by Pylint.
Line: 41
Column: 1
]
},
'cluster_queries': {
'options': [None, 'Queries', 'queries/s', 'cluster', 'rethinkdb.cluster_queries', 'line'],
'lines': [
['cluster_queries_per_sec', 'queries'],
]
},
'cluster_documents': {
Reported by Pylint.
Line: 47
Column: 1
]
},
'cluster_documents': {
'options': [None, 'Documents', 'documents/s', 'cluster', 'rethinkdb.cluster_documents', 'line'],
'lines': [
['cluster_read_docs_per_sec', 'reads'],
['cluster_written_docs_per_sec', 'writes'],
]
},
Reported by Pylint.
Line: 56
Column: 1
}
def server_charts(n):
o = [
'{0}_client_connections'.format(n),
'{0}_clients_active'.format(n),
'{0}_queries'.format(n),
'{0}_documents'.format(n),
Reported by Pylint.
Line: 56
Column: 1
}
def server_charts(n):
o = [
'{0}_client_connections'.format(n),
'{0}_clients_active'.format(n),
'{0}_queries'.format(n),
'{0}_documents'.format(n),
Reported by Pylint.
Line: 57
Column: 5
def server_charts(n):
o = [
'{0}_client_connections'.format(n),
'{0}_clients_active'.format(n),
'{0}_queries'.format(n),
'{0}_documents'.format(n),
]
Reported by Pylint.
daemon/main.c
36 issues
Line: 637
Column: 5
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
int get_system_info(struct rrdhost_system_info *system_info) {
char *script;
script = mallocz(sizeof(char) * (strlen(netdata_configured_primary_plugins_dir) + strlen("system-info.sh") + 2));
sprintf(script, "%s/%s", netdata_configured_primary_plugins_dir, "system-info.sh");
if (unlikely(access(script, R_OK) != 0)) {
info("System info script %s not found.",script);
freez(script);
return 1;
}
Reported by FlawFinder.
Line: 638
Column: 18
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
char *script;
script = mallocz(sizeof(char) * (strlen(netdata_configured_primary_plugins_dir) + strlen("system-info.sh") + 2));
sprintf(script, "%s/%s", netdata_configured_primary_plugins_dir, "system-info.sh");
if (unlikely(access(script, R_OK) != 0)) {
info("System info script %s not found.",script);
freez(script);
return 1;
}
Reported by FlawFinder.
Line: 1318
Column: 53
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
error("This agent doesn't have ACLK.");
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/.aclk_report_sent", netdata_configured_varlib_dir);
if (netdata_anonymous_statistics_enabled > 0 && access(filename, F_OK)) { // -1 -> not initialized
send_statistics("ACLK_DISABLED", "-", "-");
#ifdef ACLK_NO_LWS
send_statistics("BUILD_FAIL_LWS", "-", "-");
#endif
#ifdef ACLK_NO_LIBMOSQ
Reported by FlawFinder.
Line: 532
Column: 20
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
netdata_configured_web_dir = config_get(CONFIG_SECTION_GLOBAL, "web files directory", netdata_configured_web_dir);
netdata_configured_cache_dir = config_get(CONFIG_SECTION_GLOBAL, "cache directory", netdata_configured_cache_dir);
netdata_configured_varlib_dir = config_get(CONFIG_SECTION_GLOBAL, "lib directory", netdata_configured_varlib_dir);
char *env_home=getenv("HOME");
netdata_configured_home_dir = config_get(CONFIG_SECTION_GLOBAL, "home directory", env_home?env_home:netdata_configured_home_dir);
netdata_configured_lock_dir = initialize_lock_directory_path(netdata_configured_varlib_dir);
{
Reported by FlawFinder.
Line: 751
Column: 23
CWE codes:
120
20
Suggestion:
Check implementation on installation, or limit the size of all string inputs
optstring[(num_opts *2)] ='\0';
int opt;
while( (opt = getopt(argc, argv, optstring)) != -1 ) {
switch(opt) {
case 'c':
if(load_netdata_conf(optarg, 1) != 1) {
error("Cannot load configuration file %s.", optarg);
return 1;
Reported by FlawFinder.
Line: 33
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
send_statistics("EXIT", ret?"ERROR":"OK","-");
analytics_free_data();
char agent_crash_file[FILENAME_MAX + 1];
char agent_incomplete_shutdown_file[FILENAME_MAX + 1];
snprintfz(agent_crash_file, FILENAME_MAX, "%s/.agent_crash", netdata_configured_varlib_dir);
snprintfz(agent_incomplete_shutdown_file, FILENAME_MAX, "%s/.agent_incomplete_shutdown", netdata_configured_varlib_dir);
(void) rename(agent_crash_file, agent_incomplete_shutdown_file);
Reported by FlawFinder.
Line: 34
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
analytics_free_data();
char agent_crash_file[FILENAME_MAX + 1];
char agent_incomplete_shutdown_file[FILENAME_MAX + 1];
snprintfz(agent_crash_file, FILENAME_MAX, "%s/.agent_crash", netdata_configured_varlib_dir);
snprintfz(agent_incomplete_shutdown_file, FILENAME_MAX, "%s/.agent_incomplete_shutdown", netdata_configured_varlib_dir);
(void) rename(agent_crash_file, agent_incomplete_shutdown_file);
// cleanup/save the database and exit
Reported by FlawFinder.
Line: 394
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 ENABLE_HTTPS
static void security_init(){
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/ssl/key.pem",netdata_configured_user_config_dir);
security_key = config_get(CONFIG_SECTION_WEB, "ssl key", filename);
snprintfz(filename, FILENAME_MAX, "%s/ssl/cert.pem",netdata_configured_user_config_dir);
security_cert = config_get(CONFIG_SECTION_WEB, "ssl certificate", filename);
Reported by FlawFinder.
Line: 409
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
#endif
static void log_init(void) {
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/debug.log", netdata_configured_log_dir);
stdout_filename = config_get(CONFIG_SECTION_GLOBAL, "debug log", filename);
snprintfz(filename, FILENAME_MAX, "%s/error.log", netdata_configured_log_dir);
stderr_filename = config_get(CONFIG_SECTION_GLOBAL, "error log", filename);
Reported by FlawFinder.
Line: 419
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
snprintfz(filename, FILENAME_MAX, "%s/access.log", netdata_configured_log_dir);
stdaccess_filename = config_get(CONFIG_SECTION_GLOBAL, "access log", filename);
char deffacility[8];
snprintfz(deffacility,7,"%s","daemon");
facility_log = config_get(CONFIG_SECTION_GLOBAL, "facility log", deffacility);
error_log_throttle_period = config_get_number(CONFIG_SECTION_GLOBAL, "errors flood protection period", error_log_throttle_period);
error_log_errors_per_period = (unsigned long)config_get_number(CONFIG_SECTION_GLOBAL, "errors to trigger flood protection", (long long int)error_log_errors_per_period);
Reported by FlawFinder.
collectors/python.d.plugin/python_modules/urllib3/exceptions.py
36 issues
Line: 3
Column: 1
# SPDX-License-Identifier: MIT
from __future__ import absolute_import
from .packages.six.moves.http_client import (
IncompleteRead as httplib_IncompleteRead
)
# Base Exceptions
class HTTPError(Exception):
Reported by Pylint.
Line: 11
Column: 5
class HTTPError(Exception):
"Base exception used by this module."
pass
class HTTPWarning(Warning):
"Base warning used by this module."
pass
Reported by Pylint.
Line: 16
Column: 5
class HTTPWarning(Warning):
"Base warning used by this module."
pass
class PoolError(HTTPError):
"Base exception for errors caused within a pool."
def __init__(self, pool, message):
Reported by Pylint.
Line: 43
Column: 5
class SSLError(HTTPError):
"Raised when SSL certificate fails in an HTTPS connection."
pass
class ProxyError(HTTPError):
"Raised when the connection to a proxy fails."
pass
Reported by Pylint.
Line: 48
Column: 5
class ProxyError(HTTPError):
"Raised when the connection to a proxy fails."
pass
class DecodeError(HTTPError):
"Raised when automatic decoding based on Content-Type fails."
pass
Reported by Pylint.
Line: 53
Column: 5
class DecodeError(HTTPError):
"Raised when automatic decoding based on Content-Type fails."
pass
class ProtocolError(HTTPError):
"Raised when something unexpected happens mid-request/response."
pass
Reported by Pylint.
Line: 58
Column: 5
class ProtocolError(HTTPError):
"Raised when something unexpected happens mid-request/response."
pass
#: Renamed to ProtocolError but aliased for backwards compatibility.
ConnectionError = ProtocolError
Reported by Pylint.
Line: 62
Column: 1
#: Renamed to ProtocolError but aliased for backwards compatibility.
ConnectionError = ProtocolError
# Leaf Exceptions
class MaxRetryError(RequestError):
Reported by Pylint.
Line: 97
Column: 5
class TimeoutStateError(HTTPError):
""" Raised when passing an invalid state to a timeout """
pass
class TimeoutError(HTTPError):
""" Raised when a socket timeout error occurs.
Reported by Pylint.
Line: 100
Column: 1
pass
class TimeoutError(HTTPError):
""" Raised when a socket timeout error occurs.
Catching this error will catch both :exc:`ReadTimeoutErrors
<ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`.
"""
Reported by Pylint.
collectors/cgroups.plugin/sys_fs_cgroup.c
36 issues
Line: 578
Column: 24
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
char *filename;
unsigned long long user;
unsigned long long system;
};
// https://www.kernel.org/doc/Documentation/cgroup-v1/cpuacct.txt
struct cpuacct_usage {
int updated;
Reported by FlawFinder.
Line: 770
Column: 38
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
cp->updated = 1;
if(unlikely(cp->enabled == CONFIG_BOOLEAN_AUTO &&
(cp->user || cp->system || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES)))
cp->enabled = CONFIG_BOOLEAN_YES;
}
}
static inline void cgroup2_read_cpuacct_stat(struct cpuacct_stat *cp) {
Reported by FlawFinder.
Line: 807
Column: 38
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
cp->updated = 1;
if(unlikely(cp->enabled == CONFIG_BOOLEAN_AUTO &&
(cp->user || cp->system || netdata_zero_metrics_enabled == CONFIG_BOOLEAN_YES)))
cp->enabled = CONFIG_BOOLEAN_YES;
}
}
static inline void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) {
Reported by FlawFinder.
Line: 1712
Column: 17
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
if(enabled) {
char *s = mallocz(dirlen + strlen(de->d_name) + 2);
strcpy(s, this);
strcat(s, "/");
strcat(s, de->d_name);
int ret2 = find_dir_in_subdirs(base, s, callback);
if(ret2 > 0) ret += ret2;
freez(s);
Reported by FlawFinder.
Line: 1714
Column: 17
CWE codes:
120
Suggestion:
Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused)
char *s = mallocz(dirlen + strlen(de->d_name) + 2);
strcpy(s, this);
strcat(s, "/");
strcat(s, de->d_name);
int ret2 = find_dir_in_subdirs(base, s, callback);
if(ret2 > 0) ret += ret2;
freez(s);
}
}
Reported by FlawFinder.
Line: 2730
Column: 96
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
}
}
rrddim_set_by_pointer(st_cpu, cg->rd_cpu, cg->cpuacct_stat.user + cg->cpuacct_stat.system);
}
if(likely(do_mem_usage && cg->memory.updated_usage_in_bytes)) {
if(unlikely(!cg->rd_mem_usage))
cg->rd_mem_usage = rrddim_add(st_mem_usage, cg->chart_id, cg->chart_title, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE);
Reported by FlawFinder.
Line: 3163
Column: 63
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
rrdset_next(cg->st_cpu);
rrddim_set(cg->st_cpu, "user", cg->cpuacct_stat.user);
rrddim_set(cg->st_cpu, "system", cg->cpuacct_stat.system);
rrdset_done(cg->st_cpu);
if(likely(cg->filename_cpuset_cpus || cg->filename_cpu_cfs_period || cg->filename_cpu_cfs_quota)) {
if(!(cg->options & CGROUP_OPTIONS_IS_UNIFIED)) {
update_cpu_limits(&cg->filename_cpuset_cpus, &cg->cpuset_cpus, cg);
Reported by FlawFinder.
Line: 3232
Column: 98
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
rrdset_next(cg->st_cpu_limit);
calculated_number cpu_usage = 0;
cpu_usage = (calculated_number)(cg->cpuacct_stat.user + cg->cpuacct_stat.system) * 100;
calculated_number cpu_used = 100 * (cpu_usage - cg->prev_cpu_usage) / (value * update_every);
rrdset_isnot_obsolete(cg->st_cpu_limit);
rrddim_set(cg->st_cpu_limit, "used", (cpu_used > 0)?cpu_used:0);
Reported by FlawFinder.
Line: 106
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
{
pid_t command_pid;
enum cgroups_systemd_setting retval = SYSTEMD_CGROUP_ERR;
char buf[MAXSIZE_PROC_CMDLINE];
char *begin, *end;
FILE *f = mypopen(exec, &command_pid);
if (!f)
Reported by FlawFinder.
Line: 141
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 enum cgroups_type cgroups_try_detect_version()
{
pid_t command_pid;
char buf[MAXSIZE_PROC_CMDLINE];
enum cgroups_systemd_setting systemd_setting;
int cgroups2_available = 0;
// 1. check if cgroups2 available on system at all
FILE *f = mypopen("grep cgroup /proc/filesystems", &command_pid);
Reported by FlawFinder.
collectors/python.d.plugin/elasticsearch/elasticsearch.chart.py
35 issues
Line: 17
Column: 1
except ImportError:
from Queue import Queue
from bases.FrameworkServices.UrlService import UrlService
# default module values (can be overridden per job in `config`)
update_every = 5
METHODS = namedtuple('METHODS', ['get_data', 'url', 'run'])
Reported by Pylint.
Line: 537
Column: 16
def w(*args):
try:
method(*args)
except Exception as error:
self, queue, url = args[0], args[1], args[2]
self.error("error during '{0}' : {1}".format(url, error))
queue.put(dict())
return w
Reported by Pylint.
Line: 1
Column: 1
# -*- coding: utf-8 -*-
# Description: elastic search node stats netdata python.d module
# Author: ilyam8
# SPDX-License-Identifier: GPL-3.0-or-later
import json
import threading
from collections import namedtuple
Reported by Pylint.
Line: 20
Column: 1
from bases.FrameworkServices.UrlService import UrlService
# default module values (can be overridden per job in `config`)
update_every = 5
METHODS = namedtuple('METHODS', ['get_data', 'url', 'run'])
NODE_STATS = [
'indices.search.fetch_current',
Reported by Pylint.
Line: 203
Column: 1
]
},
'search_latency': {
'options': [None, 'Query And Fetch Latency', 'milliseconds', 'search performance', 'elastic.search_latency',
'stacked'],
'lines': [
['query_latency', 'query', 'absolute', 1, 1000],
['fetch_latency', 'fetch', 'absolute', 1, 1000]
]
Reported by Pylint.
Line: 227
Column: 1
]
},
'index_performance_time': {
'options': [None, 'Time Spent On Indexing, Refreshing, Flushing', 'seconds', 'indexing performance',
'elastic.index_performance_time', 'stacked'],
'lines': [
['indices_indexing_index_time_in_millis', 'indexing', 'incremental', 1, 1000],
['indices_refresh_total_time_in_millis', 'refreshing', 'incremental', 1, 1000],
['indices_flush_total_time_in_millis', 'flushing', 'incremental', 1, 1000]
Reported by Pylint.
Line: 278
Column: 1
'elastic.index_segments_memory', 'stacked'],
'lines': [
['indices_segments_terms_memory_in_bytes', 'terms', 'absolute', 1, 1048567],
['indices_segments_stored_fields_memory_in_bytes', 'stored fields', 'absolute', 1, 1048567],
['indices_segments_term_vectors_memory_in_bytes', 'term vectors', 'absolute', 1, 1048567],
['indices_segments_norms_memory_in_bytes', 'norms', 'absolute', 1, 1048567],
['indices_segments_points_memory_in_bytes', 'points', 'absolute', 1, 1048567],
['indices_segments_doc_values_memory_in_bytes', 'doc values', 'absolute', 1, 1048567],
['indices_segments_version_map_memory_in_bytes', 'version map', 'absolute', 1, 1048567],
Reported by Pylint.
Line: 279
Column: 1
'lines': [
['indices_segments_terms_memory_in_bytes', 'terms', 'absolute', 1, 1048567],
['indices_segments_stored_fields_memory_in_bytes', 'stored fields', 'absolute', 1, 1048567],
['indices_segments_term_vectors_memory_in_bytes', 'term vectors', 'absolute', 1, 1048567],
['indices_segments_norms_memory_in_bytes', 'norms', 'absolute', 1, 1048567],
['indices_segments_points_memory_in_bytes', 'points', 'absolute', 1, 1048567],
['indices_segments_doc_values_memory_in_bytes', 'doc values', 'absolute', 1, 1048567],
['indices_segments_version_map_memory_in_bytes', 'version map', 'absolute', 1, 1048567],
['indices_segments_fixed_bit_set_memory_in_bytes', 'fixed bit set', 'absolute', 1, 1048567]
Reported by Pylint.
Line: 284
Column: 1
['indices_segments_points_memory_in_bytes', 'points', 'absolute', 1, 1048567],
['indices_segments_doc_values_memory_in_bytes', 'doc values', 'absolute', 1, 1048567],
['indices_segments_version_map_memory_in_bytes', 'version map', 'absolute', 1, 1048567],
['indices_segments_fixed_bit_set_memory_in_bytes', 'fixed bit set', 'absolute', 1, 1048567]
]
},
'jvm_mem_heap': {
'options': [None, 'JVM Heap Percentage Currently in Use', 'percentage', 'memory usage and gc',
'elastic.jvm_heap', 'area'],
Reported by Pylint.
Line: 288
Column: 1
]
},
'jvm_mem_heap': {
'options': [None, 'JVM Heap Percentage Currently in Use', 'percentage', 'memory usage and gc',
'elastic.jvm_heap', 'area'],
'lines': [
['jvm_mem_heap_used_percent', 'inuse', 'absolute']
]
},
Reported by Pylint.