The following issues were found

collectors/python.d.plugin/httpcheck/httpcheck.chart.py
10 issues
Unable to import 'bases.FrameworkServices.UrlService'
Error

Line: 15 Column: 1

              except ImportError:
    from time import time

from bases.FrameworkServices.UrlService import UrlService

# default module values (can be overridden per job in `config`)
update_every = 3
priority = 60000


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # -*- coding: utf-8 -*-
# Description: http check netdata python.d module
# Original Author: ccremer (github.com/ccremer)
# SPDX-License-Identifier: GPL-3.0-or-later

import re

import urllib3


            

Reported by Pylint.

Constant name "update_every" doesn't conform to UPPER_CASE naming style
Error

Line: 18 Column: 1

              from bases.FrameworkServices.UrlService import UrlService

# default module values (can be overridden per job in `config`)
update_every = 3
priority = 60000

# Response
HTTP_RESPONSE_TIME = 'time'
HTTP_RESPONSE_LENGTH = 'length'

            

Reported by Pylint.

Constant name "priority" doesn't conform to UPPER_CASE naming style
Error

Line: 19 Column: 1

              
# default module values (can be overridden per job in `config`)
update_every = 3
priority = 60000

# Response
HTTP_RESPONSE_TIME = 'time'
HTTP_RESPONSE_LENGTH = 'length'


            

Reported by Pylint.

Line too long (110/100)
Error

Line: 40 Column: 1

              
CHARTS = {
    'response_time': {
        'options': [None, 'HTTP response time', 'milliseconds', 'response', 'httpcheck.responsetime', 'line'],
        'lines': [
            [HTTP_RESPONSE_TIME, 'time', 'absolute', 100, 1000]
        ]
    },
    'response_length': {

            

Reported by Pylint.

Line too long (117/100)
Error

Line: 46 Column: 1

                      ]
    },
    'response_length': {
        'options': [None, 'HTTP response body length', 'characters', 'response', 'httpcheck.responselength', 'line'],
        'lines': [
            [HTTP_RESPONSE_LENGTH, 'length', 'absolute']
        ]
    },
    'status': {

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 64 Column: 1

              }


class Service(UrlService):
    def __init__(self, configuration=None, name=None):
        UrlService.__init__(self, configuration=configuration, name=name)
        self.order = ORDER
        self.definitions = CHARTS
        pattern = self.configuration.get('regex')

            

Reported by Pylint.

Missing class docstring
Error

Line: 64 Column: 1

              }


class Service(UrlService):
    def __init__(self, configuration=None, name=None):
        UrlService.__init__(self, configuration=configuration, name=name)
        self.order = ORDER
        self.definitions = CHARTS
        pattern = self.configuration.get('regex')

            

Reported by Pylint.

Line too long (106/100)
Error

Line: 88 Column: 1

                      url = self.url
        try:
            start = time()
            status, content = self._get_raw_data_with_status(retries=1 if self.follow_redirect else False,
                                                             redirect=self.follow_redirect)
            diff = time() - start
            data[HTTP_RESPONSE_TIME] = max(round(diff * 10000), 0)
            self.debug('Url: {url}. Host responded with status code {code} in {diff} s'.format(
                url=url, code=status, diff=diff

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 115 Column: 5

              
        return data

    def process_response(self, content, data, status):
        data[HTTP_RESPONSE_LENGTH] = len(content)
        self.debug('Content: \n\n{content}\n'.format(content=content))
        if status in self.status_codes_accepted:
            if self.regex and self.regex.search(content) is None:
                self.debug('No match for regex "{regex}" found'.format(regex=self.regex.pattern))

            

Reported by Pylint.

collectors/python.d.plugin/dockerd/dockerd.chart.py
9 issues
Unable to import 'bases.FrameworkServices.SimpleService'
Error

Line: 14 Column: 1

              
from distutils.version import StrictVersion

from bases.FrameworkServices.SimpleService import SimpleService

# charts order (can be overridden if you want less charts, or different order)
ORDER = [
    'running_containers',
    'healthy_containers',

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # -*- coding: utf-8 -*-
# Description: docker netdata python.d module
# Author: Kévin Darcel (@tuxity)

try:
    import docker

    HAS_DOCKER = True
except ImportError:

            

Reported by Pylint.

Missing class docstring
Error

Line: 50 Column: 1

              MIN_REQUIRED_VERSION = '3.2.0'


class Service(SimpleService):
    def __init__(self, configuration=None, name=None):
        SimpleService.__init__(self, configuration=configuration, name=name)
        self.order = ORDER
        self.definitions = CHARTS
        self.client = None

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 57 Column: 5

                      self.definitions = CHARTS
        self.client = None

    def check(self):
        if not HAS_DOCKER:
            self.error("'docker' package is needed to use dockerd module")
            return False

        if StrictVersion(docker.__version__) < StrictVersion(MIN_REQUIRED_VERSION):

            

Reported by Pylint.

Line too long (117/100)
Error

Line: 63 Column: 1

                          return False

        if StrictVersion(docker.__version__) < StrictVersion(MIN_REQUIRED_VERSION):
            self.error("installed 'docker' package version {0}, minimum required version {1}, please upgrade".format(
                docker.__version__,
                MIN_REQUIRED_VERSION,
            ))
            return False


            

Reported by Pylint.

Line too long (111/100)
Error

Line: 69 Column: 1

                          ))
            return False

        self.client = docker.DockerClient(base_url=self.configuration.get('url', 'unix://var/run/docker.sock'))

        try:
            self.client.ping()
        except docker.errors.APIError as error:
            self.error(error)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 79 Column: 5

              
        return True

    def get_data(self):
        data = dict()

        data['running_containers'] = len(self.client.containers.list(sparse=True))
        data['healthy_containers'] = len(self.client.containers.list(filters={'health': 'healthy'}, sparse=True))
        data['unhealthy_containers'] = len(self.client.containers.list(filters={'health': 'unhealthy'}, sparse=True))

            

Reported by Pylint.

Line too long (113/100)
Error

Line: 83 Column: 1

                      data = dict()

        data['running_containers'] = len(self.client.containers.list(sparse=True))
        data['healthy_containers'] = len(self.client.containers.list(filters={'health': 'healthy'}, sparse=True))
        data['unhealthy_containers'] = len(self.client.containers.list(filters={'health': 'unhealthy'}, sparse=True))

        return data or None

            

Reported by Pylint.

Line too long (117/100)
Error

Line: 84 Column: 1

              
        data['running_containers'] = len(self.client.containers.list(sparse=True))
        data['healthy_containers'] = len(self.client.containers.list(filters={'health': 'healthy'}, sparse=True))
        data['unhealthy_containers'] = len(self.client.containers.list(filters={'health': 'unhealthy'}, sparse=True))

        return data or None

            

Reported by Pylint.

collectors/python.d.plugin/chrony/chrony.chart.py
9 issues
Unable to import 'bases.FrameworkServices.ExecutableService'
Error

Line: 6 Column: 1

              # Author: Dominik Schloesser (domschl)
# SPDX-License-Identifier: GPL-3.0-or-later

from bases.FrameworkServices.ExecutableService import ExecutableService

# default module values (can be overridden per job in `config`)
update_every = 5

CHRONY_COMMAND = 'chronyc -n tracking'

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # -*- coding: utf-8 -*-
# Description: chrony netdata python.d module
# Author: Dominik Schloesser (domschl)
# SPDX-License-Identifier: GPL-3.0-or-later

from bases.FrameworkServices.ExecutableService import ExecutableService

# default module values (can be overridden per job in `config`)
update_every = 5

            

Reported by Pylint.

Constant name "update_every" doesn't conform to UPPER_CASE naming style
Error

Line: 9 Column: 1

              from bases.FrameworkServices.ExecutableService import ExecutableService

# default module values (can be overridden per job in `config`)
update_every = 5

CHRONY_COMMAND = 'chronyc -n tracking'

# charts order (can be overridden if you want less charts, or different order)
ORDER = [

            

Reported by Pylint.

Line too long (106/100)
Error

Line: 26 Column: 1

              
CHARTS = {
    'system': {
        'options': [None, 'Chrony System Time Deltas', 'microseconds', 'system', 'chrony.system', 'area'],
        'lines': [
            ['timediff', 'system time', 'absolute', 1, 1000]
        ]
    },
    'offsets': {

            

Reported by Pylint.

Line too long (108/100)
Error

Line: 32 Column: 1

                      ]
    },
    'offsets': {
        'options': [None, 'Chrony System Time Offsets', 'microseconds', 'system', 'chrony.offsets', 'area'],
        'lines': [
            ['lastoffset', 'last offset', 'absolute', 1, 1000],
            ['rmsoffset', 'RMS offset', 'absolute', 1, 1000]
        ]
    },

            

Reported by Pylint.

Line too long (108/100)
Error

Line: 58 Column: 1

                      ]
    },
    'residualfreq': {
        'options': [None, 'Chrony Residual frequency', 'ppm', 'frequencies', 'chrony.residualfreq', 'area'],
        'lines': [
            ['residualfreq', 'residual frequency', 'absolute', 1, 1000]
        ]
    },
    'skew': {

            

Reported by Pylint.

Line too long (112/100)
Error

Line: 64 Column: 1

                      ]
    },
    'skew': {
        'options': [None, 'Chrony Skew, error bound on frequency', 'ppm', 'frequencies', 'chrony.skew', 'area'],
        'lines': [
            ['skew', None, 'absolute', 1, 1000]
        ]
    }
}

            

Reported by Pylint.

Missing class docstring
Error

Line: 84 Column: 1

              ]


class Service(ExecutableService):
    def __init__(self, configuration=None, name=None):
        ExecutableService.__init__(
            self, configuration=configuration, name=name)
        self.order = ORDER
        self.definitions = CHARTS

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 84 Column: 1

              ]


class Service(ExecutableService):
    def __init__(self, configuration=None, name=None):
        ExecutableService.__init__(
            self, configuration=configuration, name=name)
        self.order = ORDER
        self.definitions = CHARTS

            

Reported by Pylint.

web/api/badges/web_buffer_svg.c
9 issues
strcpy - Does not check for buffer overflows when copying to destination [MS-banned]
Security

Line: 192 Column: 21 CWE codes: 120
Suggestion: Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)

              
            case '&':
                if(i > 5) {
                    strcpy(dst, "&amp;");
                    i -= 5;
                    dst += 5;
                    src++;
                }
                else goto cleanup;

            

Reported by FlawFinder.

strcpy - Does not check for buffer overflows when copying to destination [MS-banned]
Security

Line: 202 Column: 21 CWE codes: 120
Suggestion: Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)

              
            case '<':
                if(i > 4) {
                    strcpy(dst, "&lt;");
                    i -= 4;
                    dst += 4;
                    src++;
                }
                else goto cleanup;

            

Reported by FlawFinder.

strcpy - Does not check for buffer overflows when copying to destination [MS-banned]
Security

Line: 212 Column: 21 CWE codes: 120
Suggestion: Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)

              
            case '>':
                if(i > 4) {
                    strcpy(dst, "&gt;");
                    i -= 4;
                    dst += 4;
                    src++;
                }
                else goto cleanup;

            

Reported by FlawFinder.

strcpy - Does not check for buffer overflows when copying to destination [MS-banned]
Security

Line: 222 Column: 21 CWE codes: 120
Suggestion: Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)

              
            case '"':
                if(i > 6) {
                    strcpy(dst, "&quot;");
                    i -= 6;
                    dst += 6;
                    src++;
                }
                else goto cleanup;

            

Reported by FlawFinder.

strcpy - Does not check for buffer overflows when copying to destination [MS-banned]
Security

Line: 232 Column: 21 CWE codes: 120
Suggestion: Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)

              
            case '\'':
                if(i > 6) {
                    strcpy(dst, "&apos;");
                    i -= 6;
                    dst += 6;
                    src++;
                }
                else goto cleanup;

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 562 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(isnan(value) || isinf(value))
        value = NAN;

    char color_buffer[256 + 1] = "";
    char value_buffer[256 + 1] = "";
    BADGE_COLOR_COMPARISON comparison = COLOR_COMPARE_GREATER;

    // example input:
    // color<max|color>min|color:null...

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 563 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

                      value = NAN;

    char color_buffer[256 + 1] = "";
    char value_buffer[256 + 1] = "";
    BADGE_COLOR_COMPARISON comparison = COLOR_COMPARE_GREATER;

    // example input:
    // color<max|color>min|color:null...


            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 736 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

              }

void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const char *units, const char *label_color, const char *value_color, int precision, int scale, uint32_t options, int fixed_width_lbl, int fixed_width_val, const char* text_color_lbl, const char* text_color_val) {
    char    value_color_buffer[COLOR_STRING_SIZE + 1]
            , value_string[VALUE_STRING_SIZE + 1]
            , label_escaped[LABEL_STRING_SIZE + 1]
            , value_escaped[VALUE_STRING_SIZE + 1];

    const char *label_color_parsed;

            

Reported by FlawFinder.

strcpy - Does not check for buffer overflows when copying to destination [MS-banned]
Security

Line: 494 Column: 9 CWE codes: 120
Suggestion: Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)

                      units = "%";

    if(unlikely(isnan(value) || isinf(value))) {
        strcpy(value_string, "-");
        return value_string;
    }

    return format_value_with_precision_and_unit(value_string, value_string_len, value, units, precision);
}

            

Reported by FlawFinder.

collectors/python.d.plugin/python_modules/third_party/mcrcon.py
9 issues
Missing module docstring
Error

Line: 1 Column: 1

              # Minecraft Remote Console module.
#
# Copyright (C) 2015 Barnaby Gale
#
# SPDX-License-Identifier: MIT

import socket
import select
import struct

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              import time


class MCRconException(Exception):
    pass


class MCRcon(object):
    socket = None

            

Reported by Pylint.

Class 'MCRcon' inherits from object, can be safely removed from bases in python3
Error

Line: 17 Column: 1

                  pass


class MCRcon(object):
    socket = None

    def connect(self, host, port, password):
        if self.socket is not None:
            raise MCRconException("Already connected")

            

Reported by Pylint.

Missing class docstring
Error

Line: 17 Column: 1

                  pass


class MCRcon(object):
    socket = None

    def connect(self, host, port, password):
        if self.socket is not None:
            raise MCRconException("Already connected")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 5

              class MCRcon(object):
    socket = None

    def connect(self, host, port, password):
        if self.socket is not None:
            raise MCRconException("Already connected")
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.socket.settimeout(0.9)
        self.socket.connect((host, port))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 5

                      self.socket.connect((host, port))
        self.send(3, password)

    def disconnect(self):
        if self.socket is None:
            raise MCRconException("Already disconnected")
        self.socket.close()
        self.socket = None


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 5

                      self.socket.close()
        self.socket = None

    def read(self, length):
        data = b""
        while len(data) < length:
            data += self.socket.recv(length - len(data))
        return data


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 40 Column: 5

                          data += self.socket.recv(length - len(data))
        return data

    def send(self, out_type, out_data):
        if self.socket is None:
            raise MCRconException("Must connect before sending data")

        # Send a request packet
        out_payload = struct.pack('<ii', 0, out_type) + out_data.encode('utf8') + b'\x00\x00'

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 71 Column: 5

                          if len(select.select([self.socket], [], [], 0)[0]) == 0:
                return in_data

    def command(self, command):
        result = self.send(2, command)
        time.sleep(0.003) # MC-72390 workaround
        return result

            

Reported by Pylint.

collectors/python.d.plugin/python_modules/urllib3/util/__init__.py
9 issues
Unable to import '__init__.connection'
Error

Line: 4 Column: 1

              # SPDX-License-Identifier: MIT
from __future__ import absolute_import
# For backwards compatibility, provide imports that used to be here.
from .connection import is_connection_dropped
from .request import make_headers
from .response import is_fp_closed
from .ssl_ import (
    SSLContext,
    HAS_SNI,

            

Reported by Pylint.

Unable to import '__init__.request'
Error

Line: 5 Column: 1

              from __future__ import absolute_import
# For backwards compatibility, provide imports that used to be here.
from .connection import is_connection_dropped
from .request import make_headers
from .response import is_fp_closed
from .ssl_ import (
    SSLContext,
    HAS_SNI,
    IS_PYOPENSSL,

            

Reported by Pylint.

Unable to import '__init__.response'
Error

Line: 6 Column: 1

              # For backwards compatibility, provide imports that used to be here.
from .connection import is_connection_dropped
from .request import make_headers
from .response import is_fp_closed
from .ssl_ import (
    SSLContext,
    HAS_SNI,
    IS_PYOPENSSL,
    IS_SECURETRANSPORT,

            

Reported by Pylint.

Unable to import '__init__.ssl_'
Error

Line: 7 Column: 1

              from .connection import is_connection_dropped
from .request import make_headers
from .response import is_fp_closed
from .ssl_ import (
    SSLContext,
    HAS_SNI,
    IS_PYOPENSSL,
    IS_SECURETRANSPORT,
    assert_fingerprint,

            

Reported by Pylint.

Unable to import '__init__.timeout'
Error

Line: 17 Column: 1

                  resolve_ssl_version,
    ssl_wrap_socket,
)
from .timeout import (
    current_time,
    Timeout,
)

from .retry import Retry

            

Reported by Pylint.

Unable to import '__init__.retry'
Error

Line: 22 Column: 1

                  Timeout,
)

from .retry import Retry
from .url import (
    get_host,
    parse_url,
    split_first,
    Url,

            

Reported by Pylint.

Unable to import '__init__.url'
Error

Line: 23 Column: 1

              )

from .retry import Retry
from .url import (
    get_host,
    parse_url,
    split_first,
    Url,
)

            

Reported by Pylint.

Unable to import '__init__.wait'
Error

Line: 29 Column: 1

                  split_first,
    Url,
)
from .wait import (
    wait_for_read,
    wait_for_write
)

__all__ = (

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # SPDX-License-Identifier: MIT
from __future__ import absolute_import
# For backwards compatibility, provide imports that used to be here.
from .connection import is_connection_dropped
from .request import make_headers
from .response import is_fp_closed
from .ssl_ import (
    SSLContext,
    HAS_SNI,

            

Reported by Pylint.

health/health_log.c
9 issues
fopen - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 13 Column: 27 CWE codes: 362

                  if(host->health_log_fp)
        fclose(host->health_log_fp);

    host->health_log_fp = fopen(host->health_log_filename, "a");

    if(host->health_log_fp) {
        if (setvbuf(host->health_log_fp, NULL, _IOLBF, 0) != 0)
            error("HEALTH [%s]: cannot set line buffering on health log file '%s'.", host->hostname, host->health_log_filename);
        return 0;

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 43 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(unlikely(host->health_log_entries_written > rotate_every)) {
        health_alarm_log_close(host);

        char old_filename[FILENAME_MAX + 1];
        snprintfz(old_filename, FILENAME_MAX, "%s.old", host->health_log_filename);

        if(unlink(old_filename) == -1 && errno != ENOENT)
            error("HEALTH [%s]: cannot remove old alarms log file '%s'", host->hostname, old_filename);


            

Reported by FlawFinder.

fopen - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 56 Column: 31 CWE codes: 362

                          error("HEALTH [%s]: cannot remove old alarms log file '%s'", host->hostname, host->health_log_filename);

        // open it with truncate
        host->health_log_fp = fopen(host->health_log_filename, "w");

        if(host->health_log_fp)
            fclose(host->health_log_fp);
        else
            error("HEALTH [%s]: cannot truncate health log '%s'", host->hostname, host->health_log_filename);

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 199 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

                      line++;

        int max_entries = 33, entries = 0;
        char *pointers[max_entries];

        pointers[entries++] = s++;
        while(*s) {
            if(unlikely(*s == '\t')) {
                *s = '\0';

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 385 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

                              if(!*ae->type) { freez(ae->type); ae->type = NULL; }
            }

            char value_string[100 + 1];
            freez(ae->old_value_string);
            freez(ae->new_value_string);
            ae->old_value_string = strdupz(format_value_and_unit(value_string, 100, ae->old_value, ae->units, -1));
            ae->new_value_string = strdupz(format_value_and_unit(value_string, 100, ae->new_value, ae->units, -1));


            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 429 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 health_alarm_log_load(RRDHOST *host) {
    health_alarm_log_close(host);

    char filename[FILENAME_MAX + 1];
    snprintfz(filename, FILENAME_MAX, "%s.old", host->health_log_filename);
    FILE *fp = fopen(filename, "r");
    if(!fp)
        error("HEALTH [%s]: cannot open health file: %s", host->hostname, filename);
    else {

            

Reported by FlawFinder.

fopen - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 431 Column: 16 CWE codes: 362

              
    char filename[FILENAME_MAX + 1];
    snprintfz(filename, FILENAME_MAX, "%s.old", host->health_log_filename);
    FILE *fp = fopen(filename, "r");
    if(!fp)
        error("HEALTH [%s]: cannot open health file: %s", host->hostname, filename);
    else {
        health_alarm_log_read(host, fp, filename);
        fclose(fp);

            

Reported by FlawFinder.

fopen - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 440 Column: 10 CWE codes: 362

                  }

    host->health_log_entries_written = 0;
    fp = fopen(host->health_log_filename, "r");
    if(!fp)
        error("HEALTH [%s]: cannot open health file: %s", host->hostname, host->health_log_filename);
    else {
        health_alarm_log_read(host, fp, host->health_log_filename);
        fclose(fp);

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 514 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

                  ae->old_value = old_value;
    ae->new_value = new_value;

    char value_string[100 + 1];
    ae->old_value_string = strdupz(format_value_and_unit(value_string, 100, ae->old_value, ae->units, -1));
    ae->new_value_string = strdupz(format_value_and_unit(value_string, 100, ae->new_value, ae->units, -1));

    char *replaced_info = NULL;
    if (likely(info)) {

            

Reported by FlawFinder.

collectors/python.d.plugin/python_modules/bases/FrameworkServices/LogService.py
9 issues
Unable to import 'bases.FrameworkServices.SimpleService'
Error

Line: 11 Column: 1

              import sys
import os

from bases.FrameworkServices.SimpleService import SimpleService


class LogService(SimpleService):
    def __init__(self, configuration=None, name=None):
        SimpleService.__init__(self, configuration=configuration, name=name)

            

Reported by Pylint.

Module name "LogService" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              # -*- coding: utf-8 -*-
# Description:
# Author: Pawel Krupa (paulfantom)
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later

from glob import glob
import sys
import os

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # -*- coding: utf-8 -*-
# Description:
# Author: Pawel Krupa (paulfantom)
# Author: Ilya Mashchenko (ilyam8)
# SPDX-License-Identifier: GPL-3.0-or-later

from glob import glob
import sys
import os

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

              from bases.FrameworkServices.SimpleService import SimpleService


class LogService(SimpleService):
    def __init__(self, configuration=None, name=None):
        SimpleService.__init__(self, configuration=configuration, name=name)
        self.log_path = self.configuration.get('path')
        self.__glob_path = self.log_path
        self._last_position = 0

            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 33 Column: 13

                          if self.__re_find['current'] == self.__re_find['run']:
                self._find_recent_log_file()
            size = os.path.getsize(self.log_path)
            if size == self._last_position:
                self.__re_find['current'] += 1
                return list()  # return empty list if nothing has changed
            elif size < self._last_position:
                self._last_position = 0  # read from beginning if file has shrunk


            

Reported by Pylint.

Variable name "fp" doesn't conform to snake_case naming style
Error

Line: 39 Column: 61

                          elif size < self._last_position:
                self._last_position = 0  # read from beginning if file has shrunk

            with open(self.log_path, **self.__open_args) as fp:
                fp.seek(self._last_position)
                for line in fp:
                    lines.append(line)
                self._last_position = fp.tell()
                self.__re_find['current'] = 0

            

Reported by Pylint.

Line too long (103/100)
Error

Line: 57 Column: 1

                      """
        self.__re_find['run'] = self.__re_find['maximum']
        self.__re_find['current'] = 0
        self.__glob_path = self.__glob_path or self.log_path  # workaround for modules w/o config files
        path_list = glob(self.__glob_path)
        if path_list:
            self.log_path = max(path_list)
            return True
        return False

            

Reported by Pylint.

Line too long (112/100)
Error

Line: 73 Column: 1

                          self.error('No path to log specified')
            return None

        if self._find_recent_log_file() and os.access(self.log_path, os.R_OK) and os.path.isfile(self.log_path):
            return True
        self.error('Cannot access {0}'.format(self.log_path))
        return False

    def create(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 78 Column: 5

                      self.error('Cannot access {0}'.format(self.log_path))
        return False

    def create(self):
        # set cursor at last byte of log file
        self._last_position = os.path.getsize(self.log_path)
        status = SimpleService.create(self)
        return status

            

Reported by Pylint.

exporting/prometheus/remote_write/remote_write.c
9 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 7 Column: 1 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 as_collected;
static int homogeneous;
char context[PROMETHEUS_ELEMENT_MAX + 1];
char chart[PROMETHEUS_ELEMENT_MAX + 1];
char family[PROMETHEUS_ELEMENT_MAX + 1];
char units[PROMETHEUS_ELEMENT_MAX + 1] = "";

/**

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 8 Column: 1 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 as_collected;
static int homogeneous;
char context[PROMETHEUS_ELEMENT_MAX + 1];
char chart[PROMETHEUS_ELEMENT_MAX + 1];
char family[PROMETHEUS_ELEMENT_MAX + 1];
char units[PROMETHEUS_ELEMENT_MAX + 1] = "";

/**
 * Prepare HTTP header

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 9 Column: 1 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 homogeneous;
char context[PROMETHEUS_ELEMENT_MAX + 1];
char chart[PROMETHEUS_ELEMENT_MAX + 1];
char family[PROMETHEUS_ELEMENT_MAX + 1];
char units[PROMETHEUS_ELEMENT_MAX + 1] = "";

/**
 * Prepare HTTP header
 *

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 10 Column: 1 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 context[PROMETHEUS_ELEMENT_MAX + 1];
char chart[PROMETHEUS_ELEMENT_MAX + 1];
char family[PROMETHEUS_ELEMENT_MAX + 1];
char units[PROMETHEUS_ELEMENT_MAX + 1] = "";

/**
 * Prepare HTTP header
 *
 * @param instance an instance data structure.

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 151 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 prometheus_remote_write_specific_data *connector_specific_data =
        (struct prometheus_remote_write_specific_data *)simple_connector_data->connector_specific_data;

    char hostname[PROMETHEUS_ELEMENT_MAX + 1];
    prometheus_label_copy(
        hostname,
        (host == localhost) ? instance->config.hostname : host->hostname,
        PROMETHEUS_ELEMENT_MAX);


            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 168 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

                          if (!should_send_label(instance, label))
                continue;

            char key[PROMETHEUS_ELEMENT_MAX + 1];
            prometheus_name_copy(key, label->key, PROMETHEUS_ELEMENT_MAX);

            char value[PROMETHEUS_ELEMENT_MAX + 1];
            prometheus_label_copy(value, label->value, PROMETHEUS_ELEMENT_MAX);


            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 171 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

                          char key[PROMETHEUS_ELEMENT_MAX + 1];
            prometheus_name_copy(key, label->key, PROMETHEUS_ELEMENT_MAX);

            char value[PROMETHEUS_ELEMENT_MAX + 1];
            prometheus_label_copy(value, label->value, PROMETHEUS_ELEMENT_MAX);

            add_label(connector_specific_data->write_request, key, value);
        }
        netdata_rwlock_unlock(&host->labels.labels_rwlock);

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 229 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

                      (struct prometheus_remote_write_specific_data *)simple_connector_data->connector_specific_data;

    if (rd->collections_counter && !rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE)) {
        char name[PROMETHEUS_LABELS_MAX + 1];
        char dimension[PROMETHEUS_ELEMENT_MAX + 1];
        char *suffix = "";
        RRDHOST *host = rd->rrdset->rrdhost;

        if (as_collected) {

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 230 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 (rd->collections_counter && !rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE)) {
        char name[PROMETHEUS_LABELS_MAX + 1];
        char dimension[PROMETHEUS_ELEMENT_MAX + 1];
        char *suffix = "";
        RRDHOST *host = rd->rrdset->rrdhost;

        if (as_collected) {
            // we need as-collected / raw data

            

Reported by FlawFinder.

aclk/legacy/aclk_stats.c
9 issues
system - This causes a new program to execute and is difficult to use safely
Security

Line: 15 Column: 13 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

              // ACLK per query thread cpu stats
struct legacy_aclk_cpu_data {
    RRDDIM *user;
    RRDDIM *system;
    RRDSET *st;
} *legacy_aclk_cpu_data = NULL;

uint32_t *legacy_aclk_queries_per_thread = NULL;
uint32_t *legacy_aclk_queries_per_thread_sample = NULL;

            

Reported by FlawFinder.

system - This causes a new program to execute and is difficult to use safely
Security

Line: 321 Column: 83 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

              
    for (int i = 0; i < legacy_query_thread_count; i++) {
        rrddim_set_by_pointer(legacy_aclk_cpu_data[i].st, legacy_aclk_cpu_data[i].user, rusage_per_thread[i].ru_utime.tv_sec * 1000000ULL + rusage_per_thread[i].ru_utime.tv_usec);
        rrddim_set_by_pointer(legacy_aclk_cpu_data[i].st, legacy_aclk_cpu_data[i].system, rusage_per_thread[i].ru_stime.tv_sec * 1000000ULL + rusage_per_thread[i].ru_stime.tv_usec);
        rrdset_done(legacy_aclk_cpu_data[i].st);
    }
}

void legacy_aclk_stats_thread_cleanup()

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 204 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

                  rrdset_done(st);
}

static char *cloud_req_type_names[ACLK_STATS_CLOUD_REQ_TYPE_CNT] = {
    "other",   
    "info",
    "data",
    "alarms",
    "alarm_log",

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

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

              {
    static RRDSET *st = NULL;

    char dim_name[MAX_DIM_NAME];

    if (unlikely(!st)) {
        st = rrdset_create_localhost(
            "netdata", "aclk_query_threads", NULL, "aclk", NULL, "Queries Processed Per Thread", "req/s",
            "netdata", "stats", 200008, localhost->rrd_update_every, RRDSET_TYPE_STACKED);

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 299 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 void aclk_stats_cpu_threads(void)
{
    char id[100 + 1];
    char title[100 + 1];

    for (int i = 0; i < legacy_query_thread_count; i++) {
        if (unlikely(!legacy_aclk_cpu_data[i].st)) {


            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 300 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 void aclk_stats_cpu_threads(void)
{
    char id[100 + 1];
    char title[100 + 1];

    for (int i = 0; i < legacy_query_thread_count; i++) {
        if (unlikely(!legacy_aclk_cpu_data[i].st)) {

            snprintfz(id, 100, "aclk_thread%d_cpu", i);

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 367 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      LEGACY_ACLK_STATS_LOCK;
        // to not hold lock longer than necessary, especially not to hold it
        // during database rrd* operations
        memcpy(&per_sample, &legacy_aclk_metrics_per_sample, sizeof(struct legacy_aclk_metrics_per_sample));
        memcpy(&permanent, &legacy_aclk_metrics, sizeof(struct legacy_aclk_metrics));
        memset(&legacy_aclk_metrics_per_sample, 0, sizeof(struct legacy_aclk_metrics_per_sample));

        memcpy(legacy_aclk_queries_per_thread_sample, legacy_aclk_queries_per_thread, sizeof(uint32_t) * legacy_query_thread_count);
        memset(legacy_aclk_queries_per_thread, 0, sizeof(uint32_t) * legacy_query_thread_count);

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 368 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      // to not hold lock longer than necessary, especially not to hold it
        // during database rrd* operations
        memcpy(&per_sample, &legacy_aclk_metrics_per_sample, sizeof(struct legacy_aclk_metrics_per_sample));
        memcpy(&permanent, &legacy_aclk_metrics, sizeof(struct legacy_aclk_metrics));
        memset(&legacy_aclk_metrics_per_sample, 0, sizeof(struct legacy_aclk_metrics_per_sample));

        memcpy(legacy_aclk_queries_per_thread_sample, legacy_aclk_queries_per_thread, sizeof(uint32_t) * legacy_query_thread_count);
        memset(legacy_aclk_queries_per_thread, 0, sizeof(uint32_t) * legacy_query_thread_count);
        memset(getrusage_called_this_tick, 0, sizeof(uint8_t) * legacy_query_thread_count);

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 371 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      memcpy(&permanent, &legacy_aclk_metrics, sizeof(struct legacy_aclk_metrics));
        memset(&legacy_aclk_metrics_per_sample, 0, sizeof(struct legacy_aclk_metrics_per_sample));

        memcpy(legacy_aclk_queries_per_thread_sample, legacy_aclk_queries_per_thread, sizeof(uint32_t) * legacy_query_thread_count);
        memset(legacy_aclk_queries_per_thread, 0, sizeof(uint32_t) * legacy_query_thread_count);
        memset(getrusage_called_this_tick, 0, sizeof(uint8_t) * legacy_query_thread_count);
        LEGACY_ACLK_STATS_UNLOCK;

        aclk_stats_collect(&per_sample, &permanent);

            

Reported by FlawFinder.