The following issues were found

src/third_party/wiredtiger/test/suite/test_cursor_random.py
57 issues
Unable to import 'wiredtiger'
Error

Line: 29 Column: 1

              # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

import wiredtiger, wttest
from wtdataset import SimpleDataSet, ComplexDataSet, simple_key, simple_value
from wtscenario import make_scenarios

# test_cursor_random.py
#    Cursor next_random operations

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 57 Column: 41

                      self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.compare(cursor), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.insert(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.prev(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.remove(), msg)
        self.assertRaisesWithMessage(

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 59 Column: 41

                      self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.insert(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.prev(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.remove(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.search(), msg)
        self.assertRaisesWithMessage(

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 61 Column: 41

                      self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.prev(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.remove(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.search(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.search_near(), msg)
        self.assertRaisesWithMessage(

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 63 Column: 41

                      self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.remove(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.search(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.search_near(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.update(), msg)


            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 65 Column: 41

                      self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.search(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.search_near(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.update(), msg)

        self.assertTrue(cursor.next(), wiredtiger.WT_NOTFOUND)
        self.assertEquals(cursor.reconfigure(), 0)

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 67 Column: 41

                      self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.search_near(), msg)
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError, lambda: cursor.update(), msg)

        self.assertTrue(cursor.next(), wiredtiger.WT_NOTFOUND)
        self.assertEquals(cursor.reconfigure(), 0)
        self.assertEquals(cursor.reset(), 0)
        cursor.close()

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 70 Column: 9

                          wiredtiger.WiredTigerError, lambda: cursor.update(), msg)

        self.assertTrue(cursor.next(), wiredtiger.WT_NOTFOUND)
        self.assertEquals(cursor.reconfigure(), 0)
        self.assertEquals(cursor.reset(), 0)
        cursor.close()

    # Check that next_random fails with an empty tree, repeatedly.
    def test_cursor_random_empty(self):

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 71 Column: 9

              
        self.assertTrue(cursor.next(), wiredtiger.WT_NOTFOUND)
        self.assertEquals(cursor.reconfigure(), 0)
        self.assertEquals(cursor.reset(), 0)
        cursor.close()

    # Check that next_random fails with an empty tree, repeatedly.
    def test_cursor_random_empty(self):
        uri = self.type

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 79 Column: 13

                      uri = self.type
        self.session.create(uri, 'key_format=S,value_format=S')
        cursor = self.session.open_cursor(uri, None, self.config)
        for i in range(1,5):
            self.assertTrue(cursor.next(), wiredtiger.WT_NOTFOUND)
        cursor.close

    # Check that next_random works with a single value, repeatedly.
    def test_cursor_random_single_record(self):

            

Reported by Pylint.

src/third_party/wiredtiger/test/3rdparty/testscenarios-0.4/lib/testscenarios/tests/test_scenarios.py
57 issues
Unable to import 'testtools'
Error

Line: 28 Column: 1

                  load_tests_apply_scenarios,
    multiply_scenarios,
    )
import testtools
from testtools.tests.helpers import LoggingResult


class TestGenerateScenarios(testtools.TestCase):


            

Reported by Pylint.

Unable to import 'testtools.tests.helpers'
Error

Line: 29 Column: 1

                  multiply_scenarios,
    )
import testtools
from testtools.tests.helpers import LoggingResult


class TestGenerateScenarios(testtools.TestCase):

    def hook_apply_scenarios(self):

            

Reported by Pylint.

Unused LoggingResult imported from testtools.tests.helpers
Error

Line: 29 Column: 1

                  multiply_scenarios,
    )
import testtools
from testtools.tests.helpers import LoggingResult


class TestGenerateScenarios(testtools.TestCase):

    def hook_apply_scenarios(self):

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 129 Column: 17

                                  does nothing but pass unconditionally.

                    """
                pass

        self.ReferenceTest = ReferenceTest

    def test_sets_specified_id(self):
        raw_test = self.ReferenceTest('test_pass')

            

Reported by Pylint.

Unused variable 'raw_id'
Error

Line: 135 Column: 9

              
    def test_sets_specified_id(self):
        raw_test = self.ReferenceTest('test_pass')
        raw_id = "testscenarios.tests.test_scenarios.ReferenceTest.test_pass"
        scenario_name = self.scenario_name
        expect_id = "%(raw_id)s(%(scenario_name)s)" % vars()
        modified_test = apply_scenario(self.scenario, raw_test)
        self.assertEqual(expect_id, modified_test.id())


            

Reported by Pylint.

Unused variable 'scenario_name'
Error

Line: 136 Column: 9

                  def test_sets_specified_id(self):
        raw_test = self.ReferenceTest('test_pass')
        raw_id = "testscenarios.tests.test_scenarios.ReferenceTest.test_pass"
        scenario_name = self.scenario_name
        expect_id = "%(raw_id)s(%(scenario_name)s)" % vars()
        modified_test = apply_scenario(self.scenario, raw_test)
        self.assertEqual(expect_id, modified_test.id())

    def test_sets_specified_attributes(self):

            

Reported by Pylint.

Unused variable 'raw_desc'
Error

Line: 150 Column: 9

                      raw_test = self.ReferenceTest('test_pass_with_docstring')
        modified_test = apply_scenario(self.scenario, raw_test)
        raw_doc = self.ReferenceTest.test_pass_with_docstring.__doc__
        raw_desc = raw_doc.split("\n")[0].strip()
        scenario_name = self.scenario_name
        expect_desc = "%(raw_desc)s (%(scenario_name)s)" % vars()
        self.assertEqual(expect_desc, modified_test.shortDescription())

class TestApplyScenarios(testtools.TestCase):

            

Reported by Pylint.

Unused variable 'scenario_name'
Error

Line: 151 Column: 9

                      modified_test = apply_scenario(self.scenario, raw_test)
        raw_doc = self.ReferenceTest.test_pass_with_docstring.__doc__
        raw_desc = raw_doc.split("\n")[0].strip()
        scenario_name = self.scenario_name
        expect_desc = "%(raw_desc)s (%(scenario_name)s)" % vars()
        self.assertEqual(expect_desc, modified_test.shortDescription())

class TestApplyScenarios(testtools.TestCase):


            

Reported by Pylint.

Unused variable 'result'
Error

Line: 165 Column: 9

                          log.append((scenario, test))
        testscenarios.scenarios.apply_scenario = capture
        scenarios = ["foo", "bar"]
        result = list(apply_scenarios(scenarios, "test"))
        self.assertEqual([('foo', 'test'), ('bar', 'test')], log)

    def test_preserves_scenarios_attribute(self):
        class ReferenceTest(unittest.TestCase):
            scenarios = [('demo', {})]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #  testscenarios: extensions to python unittest to allow declarative
#  dependency injection ('scenarios') by tests.
#
# Copyright (c) 2009, Robert Collins <robertc@robertcollins.net>
# Copyright (c) 2010, 2011 Martin Pool <mbp@sourcefrog.net>
# 
# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
# license at the users choice. A copy of both licenses are available in the
# project source as Apache-2.0 and BSD. You may not use this file except in

            

Reported by Pylint.

src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Variables/__init__.py
57 issues
Unable to import '__init__.BoolVariable'
Error

Line: 40 Column: 1

              import SCons.Util
import SCons.Warnings

from .BoolVariable import BoolVariable  # okay
from .EnumVariable import EnumVariable  # okay
from .ListVariable import ListVariable  # naja
from .PackageVariable import PackageVariable # naja
from .PathVariable import PathVariable # okay


            

Reported by Pylint.

Unable to import '__init__.EnumVariable'
Error

Line: 41 Column: 1

              import SCons.Warnings

from .BoolVariable import BoolVariable  # okay
from .EnumVariable import EnumVariable  # okay
from .ListVariable import ListVariable  # naja
from .PackageVariable import PackageVariable # naja
from .PathVariable import PathVariable # okay



            

Reported by Pylint.

Unable to import '__init__.ListVariable'
Error

Line: 42 Column: 1

              
from .BoolVariable import BoolVariable  # okay
from .EnumVariable import EnumVariable  # okay
from .ListVariable import ListVariable  # naja
from .PackageVariable import PackageVariable # naja
from .PathVariable import PathVariable # okay


class Variables(object):

            

Reported by Pylint.

Unable to import '__init__.PackageVariable'
Error

Line: 43 Column: 1

              from .BoolVariable import BoolVariable  # okay
from .EnumVariable import EnumVariable  # okay
from .ListVariable import ListVariable  # naja
from .PackageVariable import PackageVariable # naja
from .PathVariable import PathVariable # okay


class Variables(object):
    instance=None

            

Reported by Pylint.

Unable to import '__init__.PathVariable'
Error

Line: 44 Column: 1

              from .EnumVariable import EnumVariable  # okay
from .ListVariable import ListVariable  # naja
from .PackageVariable import PackageVariable # naja
from .PathVariable import PathVariable # okay


class Variables(object):
    instance=None


            

Reported by Pylint.

Invalid assignment to self in method
Error

Line: 77 Column: 13

              
        # create the singleton instance
        if is_global:
            self=Variables.instance

            if not Variables.instance:
                Variables.instance=self

    def _do_add(self, key, help="", default=None, validator=None, converter=None):

            

Reported by Pylint.

Redefining built-in 'help'
Error

Line: 82 Column: 28

                          if not Variables.instance:
                Variables.instance=self

    def _do_add(self, key, help="", default=None, validator=None, converter=None):
        class Variable(object):
            pass

        option = Variable()


            

Reported by Pylint.

Attribute 'key' defined outside __init__
Error

Line: 91 Column: 13

                      # if we get a list or a tuple, we take the first element as the
        # option key and store the remaining in aliases.
        if SCons.Util.is_List(key) or SCons.Util.is_Tuple(key):
            option.key     = key[0]
            option.aliases = key[1:]
        else:
            option.key     = key
            option.aliases = [ key ]
        option.help = help

            

Reported by Pylint.

Attribute 'aliases' defined outside __init__
Error

Line: 92 Column: 13

                      # option key and store the remaining in aliases.
        if SCons.Util.is_List(key) or SCons.Util.is_Tuple(key):
            option.key     = key[0]
            option.aliases = key[1:]
        else:
            option.key     = key
            option.aliases = [ key ]
        option.help = help
        option.default = default

            

Reported by Pylint.

Attribute 'key' defined outside __init__
Error

Line: 94 Column: 13

                          option.key     = key[0]
            option.aliases = key[1:]
        else:
            option.key     = key
            option.aliases = [ key ]
        option.help = help
        option.default = default
        option.validator = validator
        option.converter = converter

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_txn19.py
57 issues
Unable to import 'wiredtiger'
Error

Line: 40 Column: 1

              import fnmatch, os, shutil, time
from wtscenario import make_scenarios
from suite_subprocess import suite_subprocess
import wiredtiger, wttest

# This test uses an artificially small log file limit, and creates
# large records so two fit into a log file. This allows us to test
# both the case when corruption happens at the beginning of a log file
# (an even number of records have been created), and when corruption

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 123 Column: 5

              
    # This function prunes out unnecessary or problematic test cases
    # from the list of scenarios.
    def includeFunc(name, dictarg):
        kind = dictarg['kind']
        corruptpos = dictarg['corruptpos']
        chkpt = dictarg['chkpt']

        # corruptpos == 0 indicates there is no corruption.

            

Reported by Pylint.

Too many arguments for format string
Error

Line: 289 Column: 25

                      # Then does a restart with recovery, then starts again with salvage,
        # and finally starts again with recovery (adding new records).

        create_params = 'key_format=i,value_format=S'.format(self.key_format)
        self.session.create(self.uri, create_params)
        self.inserts([x for x in range(0, self.nrecords)])
        newdir = "RESTART"
        copy_for_crash_restart(self.home, newdir)
        self.close_conn()

            

Reported by Pylint.

Unused import fnmatch
Error

Line: 37 Column: 1

              #   Transactions: test recovery with corrupted log files
#

import fnmatch, os, shutil, time
from wtscenario import make_scenarios
from suite_subprocess import suite_subprocess
import wiredtiger, wttest

# This test uses an artificially small log file limit, and creates

            

Reported by Pylint.

Unused import time
Error

Line: 37 Column: 1

              #   Transactions: test recovery with corrupted log files
#

import fnmatch, os, shutil, time
from wtscenario import make_scenarios
from suite_subprocess import suite_subprocess
import wiredtiger, wttest

# This test uses an artificially small log file limit, and creates

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 80 Column: 44

                                'debug_mode=(corruption_abort=false),'
    conn_config = base_config
    corruption_type = [
        ('removal', dict(kind='removal', f=lambda fname:
            os.remove(fname))),
        ('truncate', dict(kind='truncate', f=lambda fname:
            corrupt(fname, True, 0, None))),
        ('truncate-middle', dict(kind='truncate-middle', f=lambda fname:
            corrupt(fname, True, 1024 * 25, None))),

            

Reported by Pylint.

Unused variable 'chkpt'
Error

Line: 126 Column: 9

                  def includeFunc(name, dictarg):
        kind = dictarg['kind']
        corruptpos = dictarg['corruptpos']
        chkpt = dictarg['chkpt']

        # corruptpos == 0 indicates there is no corruption.
        # (i.e. corrupt log file 0, which doesn't exist)
        # We do want to test the case of no corruption, but we don't
        # need to try it against every type of corruption, only one.

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 366 Column: 44

              
    # The type of corruption to be applied
    corruption_scenarios = [
        ('removal', dict(kind='removal', f=lambda fname:
            os.remove(fname))),
        ('truncate', dict(kind='truncate', f=lambda fname:
            corrupt(fname, True, 0, None))),
        ('truncate-middle', dict(kind='truncate-middle', f=lambda fname:
            corrupt(fname, True, 1024 * 25, None))),

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 487 Column: 32

                      key = self.kind + ':' + self.filename
        return key not in self.not_salvageable

    def run_wt_and_check(self, dir, expect_fail):
        if expect_fail:
            errmsg = '/WT_TRY_SALVAGE: database corruption detected/'
            if self.filename == 'WiredTigerHS.wt':
                if self.kind == 'removal':
                    errmsg = '/hs_exists/'

            

Reported by Pylint.

Cell variable salvagedir defined in loop
Error

Line: 564 Column: 46

                              # messages produced during the error is variable by which case
                # it is, and even variable from system to system.
                self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
                    lambda: self.reopen_conn(salvagedir, salvage_config),
                    '/.*/')

if __name__ == '__main__':
    wttest.run()

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_reserve.py
57 issues
Unable to import 'wiredtiger'
Error

Line: 32 Column: 1

              # test_reserve.py
#       Reserve update tests.

import wiredtiger, wttest
from wtdataset import SimpleDataSet, SimpleIndexDataSet
from wtdataset import SimpleLSMDataSet, ComplexDataSet, ComplexLSMDataSet
from wtscenario import make_scenarios

# Test WT_CURSOR.reserve.

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 72 Column: 13

                      c = s.open_cursor(uri, None)

        # Repeatedly update a record.
        for i in range(1, 5):
            s.begin_transaction('isolation=snapshot')
            c.set_key(ds.key(100))
            c.set_value(ds.value(100))
            self.assertEquals(c.update(), 0)
            s.commit_transaction()

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 76 Column: 13

                          s.begin_transaction('isolation=snapshot')
            c.set_key(ds.key(100))
            c.set_value(ds.value(100))
            self.assertEquals(c.update(), 0)
            s.commit_transaction()

        # Confirm reserve fails if the record doesn't exist.
        s.begin_transaction('isolation=snapshot')
        c.set_key(ds.key(600))

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 82 Column: 55

                      # Confirm reserve fails if the record doesn't exist.
        s.begin_transaction('isolation=snapshot')
        c.set_key(ds.key(600))
        self.assertRaises(wiredtiger.WiredTigerError, lambda:c.reserve())
        s.rollback_transaction()

        # Repeatedly reserve a record and commit.
        for i in range(1, 5):
            s.begin_transaction('isolation=snapshot')

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 89 Column: 13

                      for i in range(1, 5):
            s.begin_transaction('isolation=snapshot')
            c.set_key(ds.key(100))
            self.assertEquals(c.reserve(), 0)
            s.commit_transaction()

        # Repeatedly reserve a record and rollback.
        for i in range(1, 5):
            s.begin_transaction('isolation=snapshot')

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 96 Column: 13

                      for i in range(1, 5):
            s.begin_transaction('isolation=snapshot')
            c.set_key(ds.key(100))
            self.assertEquals(c.reserve(), 0)
            s.rollback_transaction()

        # Repeatedly reserve, then update, a record, and commit.
        for i in range(1, 5):
            s.begin_transaction('isolation=snapshot')

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 103 Column: 13

                      for i in range(1, 5):
            s.begin_transaction('isolation=snapshot')
            c.set_key(ds.key(100))
            self.assertEquals(c.reserve(), 0)
            c.set_value(ds.value(100))
            self.assertEquals(c.update(), 0)
            s.commit_transaction()

        # Repeatedly reserve, then update, a record, and rollback.

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 105 Column: 13

                          c.set_key(ds.key(100))
            self.assertEquals(c.reserve(), 0)
            c.set_value(ds.value(100))
            self.assertEquals(c.update(), 0)
            s.commit_transaction()

        # Repeatedly reserve, then update, a record, and rollback.
        for i in range(1, 5):
            s.begin_transaction('isolation=snapshot')

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 112 Column: 13

                      for i in range(1, 5):
            s.begin_transaction('isolation=snapshot')
            c.set_key(ds.key(100))
            self.assertEquals(c.reserve(), 0)
            c.set_value(ds.value(100))
            self.assertEquals(c.update(), 0)
            s.commit_transaction()

        # Reserve a slot, repeatedly try and update a record from another

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 114 Column: 13

                          c.set_key(ds.key(100))
            self.assertEquals(c.reserve(), 0)
            c.set_value(ds.value(100))
            self.assertEquals(c.update(), 0)
            s.commit_transaction()

        # Reserve a slot, repeatedly try and update a record from another
        # transaction (which should fail), repeatedly update a record and
        # commit.

            

Reported by Pylint.

src/third_party/wiredtiger/bench/wtperf/wtperf.c
57 issues
strcat - Does not check for buffer overflows when concatenating to destination [MS-banned]
Security

Line: 2313 Column: 17 CWE codes: 120
Suggestion: Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused)

                              user_cconfig =
                  drealloc(user_cconfig, strlen(user_cconfig) + strlen(__wt_optarg) + 2);
                strcat(user_cconfig, ",");
                strcat(user_cconfig, __wt_optarg);
            }
            break;
        case 'h':
            free(wtperf->home);
            wtperf->home = dstrdup(__wt_optarg);

            

Reported by FlawFinder.

strcat - Does not check for buffer overflows when concatenating to destination [MS-banned]
Security

Line: 2335 Column: 17 CWE codes: 120
Suggestion: Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused)

                              user_tconfig =
                  drealloc(user_tconfig, strlen(user_tconfig) + strlen(__wt_optarg) + 2);
                strcat(user_tconfig, ",");
                strcat(user_tconfig, __wt_optarg);
            }
            break;
        case '?':
            usage();
            goto einval;

            

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

                  uint64_t next_val, prev_val;
    int64_t rand_range, range;
    char *range_key_buf;
    char buf[512];
    int ret;

    wtperf = thread->wtperf;
    ret = 0;


            

Reported by FlawFinder.

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

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

                  uint8_t *op, *op_end;
    int measure_latency, nmodify, ret, truncated;
    char *key_buf, *value, *value_buf;
    char buf[512];

    thread = (WTPERF_THREAD *)arg;
    workload = thread->workload;
    wtperf = thread->wtperf;
    opts = wtperf->opts;

            

Reported by FlawFinder.

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

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

                  size_t buf_size;
    int msg_err;
    const char *str;
    char buf[64], *path;
    bool first;

    wtperf = (WTPERF *)arg;
    opts = wtperf->opts;
    assert(opts->sample_interval != 0);

            

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: 1065 Column: 15 CWE codes: 362

                  len = strlen(wtperf->monitor_dir) + 100;
    path = dmalloc(len);
    testutil_check(__wt_snprintf(path, len, "%s/monitor", wtperf->monitor_dir));
    if ((fp = fopen(path, "w")) == NULL) {
        lprintf(wtperf, errno, 0, "%s", path);
        goto err;
    }
    testutil_check(__wt_snprintf(path, len, "%s/monitor.json", wtperf->monitor_dir));
    if ((jfp = fopen(path, "w")) == NULL) {

            

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: 1070 Column: 16 CWE codes: 362

                      goto err;
    }
    testutil_check(__wt_snprintf(path, len, "%s/monitor.json", wtperf->monitor_dir));
    if ((jfp = fopen(path, "w")) == NULL) {
        lprintf(wtperf, errno, 0, "%s", path);
        goto err;
    }
    /* Set line buffering for monitor file. */
    __wt_stream_set_line_buffer(fp);

            

Reported by FlawFinder.

atoi - Unless checked, the resulting number can exceed the expected range
Security

Line: 1782 Column: 34 CWE codes: 190
Suggestion: If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended)

                          lprintf(wtperf, ret, 0, "find_table_count: cursor get_key failed");
            goto err;
        }
        table_icount = (uint32_t)atoi(key);
        if (table_icount > max_icount)
            max_icount = table_icount;

        if ((ret = cursor->close(cursor)) != 0) {
            lprintf(wtperf, ret, 0, "find_table_count: cursor close failed");

            

Reported by FlawFinder.

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

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

                  size_t i;
    int ret;
    uint32_t total_table_count;
    char buf[512];

    opts = wtperf->opts;

    if ((ret = wtperf->conn->open_session(wtperf->conn, NULL, opts->sess_config, &session)) != 0) {
        lprintf(wtperf, ret, 0, "Error opening a session on %s", wtperf->home);

            

Reported by FlawFinder.

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

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

                  if (src->workload_cnt != 0) {
        dest->workload_cnt = src->workload_cnt;
        dest->workload = dcalloc(src->workload_cnt, sizeof(WORKLOAD));
        memcpy(dest->workload, src->workload, src->workload_cnt * sizeof(WORKLOAD));
    }

    TAILQ_INIT(&dest->stone_head);

    dest->opts = src->opts;

            

Reported by FlawFinder.

site_scons/site_tools/distsrc.py
56 issues
Unable to import 'SCons'
Error

Line: 23 Column: 1

              # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

import SCons
import os
import os.path as ospath
import subprocess
import shutil
import tarfile

            

Reported by Pylint.

Instance of 'DistSrcFile' has no 'name' member
Error

Line: 43 Column: 16

                      [setattr(self, key, val) for (key, val) in list(kwargs.items())]

    def __str__(self):
        return self.name


class DistSrcArchive:
    def __init__(self, archive_type, archive_file, filename, mode):
        self.archive_type = archive_type

            

Reported by Pylint.

Unused import os
Error

Line: 24 Column: 1

              #

import SCons
import os
import os.path as ospath
import subprocess
import shutil
import tarfile
import time

            

Reported by Pylint.

Unused os.path imported as ospath
Error

Line: 25 Column: 1

              
import SCons
import os
import os.path as ospath
import subprocess
import shutil
import tarfile
import time
import zipfile

            

Reported by Pylint.

Unused import subprocess
Error

Line: 26 Column: 1

              import SCons
import os
import os.path as ospath
import subprocess
import shutil
import tarfile
import time
import zipfile
import io

            

Reported by Pylint.

Unused import shutil
Error

Line: 27 Column: 1

              import os
import os.path as ospath
import subprocess
import shutil
import tarfile
import time
import zipfile
import io


            

Reported by Pylint.

Expression "[setattr(self, key, val) for (key, val) in list(kwargs.items())]" is assigned to nothing
Error

Line: 40 Column: 9

              
class DistSrcFile:
    def __init__(self, **kwargs):
        [setattr(self, key, val) for (key, val) in list(kwargs.items())]

    def __str__(self):
        return self.name



            

Reported by Pylint.

Unused argument 'mtime'
Error

Line: 145 Column: 9

                      self,
        filename,
        file_contents,
        mtime=time.time(),
        mode=0o644,
        uname="root",
        gname="root",
    ):
        self.archive_file.writestr(filename, file_contents)

            

Reported by Pylint.

Unused argument 'mode'
Error

Line: 146 Column: 9

                      filename,
        file_contents,
        mtime=time.time(),
        mode=0o644,
        uname="root",
        gname="root",
    ):
        self.archive_file.writestr(filename, file_contents)


            

Reported by Pylint.

Unused argument 'uname'
Error

Line: 147 Column: 9

                      file_contents,
        mtime=time.time(),
        mode=0o644,
        uname="root",
        gname="root",
    ):
        self.archive_file.writestr(filename, file_contents)

    def append_file(self, filename, localfile):

            

Reported by Pylint.

src/third_party/mozjs-60/extract/js/src/jit/arm/Simulator-arm.cpp
56 issues
Shifting 32-bit value by 32 bits is undefined behaviour
Error

Line: 3667 CWE codes: 758

                                          int32_t shift = instr->bits(11, 7);
                            if (shift == 0)
                                shift = 32;
                            rm_val >>= shift;
                            set_register(rd, (rn_val & 0xFFFF0000U) | (rm_val & 0xFFFF));
                        }
                    } else {
                        MOZ_CRASH();
                    }

            

Reported by Cppcheck.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 427 Column: 23 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                      return nullptr;
    }

    char* stopAtStr = getenv("ARM_SIM_STOP_AT");
    int64_t stopAt;
    if (stopAtStr && sscanf(stopAtStr, "%lld", &stopAt) == 1) {
        fprintf(stderr, "\nStopping simulation at icount %lld\n", stopAt);
        Simulator::StopSimAt = stopAt;
    }

            

Reported by FlawFinder.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 1314 Column: 9 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

              bool
SimulatorProcess::init()
{
    if (getenv("ARM_SIM_ICACHE_CHECKS"))
        ICacheCheckingDisableCount = 0;

    return icache_.init();
}


            

Reported by FlawFinder.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 3357 Column: 21 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                            }
              case 7: { // BKPT
                fprintf(stderr, "Simulator hit BKPT.\n");
                if (getenv("ARM_SIM_DEBUGGER")) {
                    ArmDebugger dbg(this);
                    dbg.debug();
                } else {
                    fprintf(stderr, "Use ARM_SIM_DEBUGGER=1 to enter the builtin debugger.\n");
                    MOZ_CRASH("ARM simulator breakpoint");

            

Reported by FlawFinder.

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

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

                  }

  private:
    char data_[kPageSize];   // The cached data.
    static const int kValidityMapSize = kPageSize >> kLineShift;
    char validity_map_[kValidityMapSize];  // One byte per line.
};

// Protects the icache() and redirection() properties of the

            

Reported by FlawFinder.

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

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

                private:
    char data_[kPageSize];   // The cached data.
    static const int kValidityMapSize = kPageSize >> kLineShift;
    char validity_map_[kValidityMapSize];  // One byte per line.
};

// Protects the icache() and redirection() properties of the
// Simulator.
class AutoLockSimulatorCache : public LockGuard<Mutex>

            

Reported by FlawFinder.

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

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

              ReadLine(const char* prompt)
{
    char* result = nullptr;
    char line_buf[256];
    int offset = 0;
    bool keep_going = true;
    fprintf(stdout, "%s", prompt);
    fflush(stdout);
    while (keep_going) {

            

Reported by FlawFinder.

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

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

                              return nullptr;
            // Copy the existing input into the new array and set the new
            // array as the result.
            memcpy(new_result, result, offset * sizeof(char));
            js_free(result);
            result = new_result;
        }
        // Copy the newly read line into the result.
        memcpy(result + offset, line_buf, len * sizeof(char));

            

Reported by FlawFinder.

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

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

                          result = new_result;
        }
        // Copy the newly read line into the result.
        memcpy(result + offset, line_buf, len * sizeof(char));
        offset += len;
    }

    MOZ_ASSERT(result);
    result[offset] = '\0';

            

Reported by FlawFinder.

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

Line: 684 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 STR(a) #a
#define XSTR(a) STR(a)

    char cmd[COMMAND_SIZE + 1];
    char arg1[ARG_SIZE + 1];
    char arg2[ARG_SIZE + 1];
    char* argv[3] = { cmd, arg1, arg2 };

    // Make sure to have a proper terminating character if reaching the limit.

            

Reported by FlawFinder.

src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Tool/FortranCommon.py
55 issues
Module name "FortranCommon" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              """SCons.Tool.FortranCommon

Stuff for processing Fortran, common to all fortran dialects.

"""

#
# Copyright (c) 2001 - 2019 The SCons Foundation
#

            

Reported by Pylint.

Line too long (124/100)
Error

Line: 31 Column: 1

              #
from __future__ import print_function

__revision__ = "src/engine/SCons/Tool/FortranCommon.py bee7caf9defd6e108fc2998a2520ddb36a967691 2019-12-17 02:07:09 bdeegan"

import re
import os.path

import SCons.Action

            

Reported by Pylint.

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

Line: 55 Column: 9

                  if not source:
        # Source might be None for unusual cases like SConf.
        return 0
    for s in source:
        if s.sources:
            ext = os.path.splitext(str(s.sources[0]))[1]
            if ext in fsuffixes:
                return 1
    return 0

            

Reported by Pylint.

Function name "_fortranEmitter" doesn't conform to snake_case naming style
Error

Line: 62 Column: 1

                              return 1
    return 0

def _fortranEmitter(target, source, env):
    node = source[0].rfile()
    if not node.exists() and not node.is_derived():
       print("Could not locate " + str(node.name))
       return ([], [])
    # This has to match the def_regex in the Fortran scanner

            

Reported by Pylint.

Bad indentation. Found 7 spaces, expected 8
Style

Line: 65 Column: 1

              def _fortranEmitter(target, source, env):
    node = source[0].rfile()
    if not node.exists() and not node.is_derived():
       print("Could not locate " + str(node.name))
       return ([], [])
    # This has to match the def_regex in the Fortran scanner
    mod_regex = r"""(?i)^\s*MODULE\s+(?!PROCEDURE|SUBROUTINE|FUNCTION|PURE|ELEMENTAL)(\w+)"""
    cre = re.compile(mod_regex,re.M)
    # Retrieve all USE'd module names

            

Reported by Pylint.

Bad indentation. Found 7 spaces, expected 8
Style

Line: 66 Column: 1

                  node = source[0].rfile()
    if not node.exists() and not node.is_derived():
       print("Could not locate " + str(node.name))
       return ([], [])
    # This has to match the def_regex in the Fortran scanner
    mod_regex = r"""(?i)^\s*MODULE\s+(?!PROCEDURE|SUBROUTINE|FUNCTION|PURE|ELEMENTAL)(\w+)"""
    cre = re.compile(mod_regex,re.M)
    # Retrieve all USE'd module names
    modules = cre.findall(node.get_text_contents())

            

Reported by Pylint.

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

Line: 78 Column: 9

                  suffix = env.subst('$FORTRANMODSUFFIX', target=target, source=source)
    moddir = env.subst('$FORTRANMODDIR', target=target, source=source)
    modules = [x.lower() + suffix for x in modules]
    for m in modules:
       target.append(env.fs.File(m, moddir))
    return (target, source)

def FortranEmitter(target, source, env):
    target, source = _fortranEmitter(target, source, env)

            

Reported by Pylint.

Bad indentation. Found 7 spaces, expected 8
Style

Line: 79 Column: 1

                  moddir = env.subst('$FORTRANMODDIR', target=target, source=source)
    modules = [x.lower() + suffix for x in modules]
    for m in modules:
       target.append(env.fs.File(m, moddir))
    return (target, source)

def FortranEmitter(target, source, env):
    target, source = _fortranEmitter(target, source, env)
    return SCons.Defaults.StaticObjectEmitter(target, source, env)

            

Reported by Pylint.

Function name "FortranEmitter" doesn't conform to snake_case naming style
Error

Line: 82 Column: 1

                     target.append(env.fs.File(m, moddir))
    return (target, source)

def FortranEmitter(target, source, env):
    target, source = _fortranEmitter(target, source, env)
    return SCons.Defaults.StaticObjectEmitter(target, source, env)

def ShFortranEmitter(target, source, env):
    target, source = _fortranEmitter(target, source, env)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 82 Column: 1

                     target.append(env.fs.File(m, moddir))
    return (target, source)

def FortranEmitter(target, source, env):
    target, source = _fortranEmitter(target, source, env)
    return SCons.Defaults.StaticObjectEmitter(target, source, env)

def ShFortranEmitter(target, source, env):
    target, source = _fortranEmitter(target, source, env)

            

Reported by Pylint.

src/third_party/wiredtiger/lang/python/setup_pip.py
55 issues
Unused import site
Error

Line: 36 Column: 1

              # are part of the package. To create the distribution, in this directory, run
# "python setup_pip.py sdist", this creates a tar.gz file under ./dist .
from __future__ import print_function
import os, os.path, re, shutil, site, sys
from setuptools import setup, Distribution, Extension
import distutils.sysconfig
import distutils.ccompiler
import subprocess
from subprocess import call

            

Reported by Pylint.

Redefining name 'build_dir' from outer scope (line 183)
Error

Line: 58 Column: 30

              
# build_commands --
#   Run a sequence of commands, and die if any fail.
def build_commands(commands, build_dir, build_env):
    for command in commands:
        callargs = [ 'sh', '-c', command ]
        verbose_command = '"' + '" "'.join(callargs) + '"'
        print('running: ' + verbose_command)
        if call(callargs, cwd=build_dir, env=build_env) != 0:

            

Reported by Pylint.

Redefining name 'builtins' from outer scope (line 199)
Error

Line: 70 Column: 31

              #   Make a quick check of any needed library dependencies, and
# add to the library path and include path as needed.  If a library
# is not found, it is not definitive.
def check_needed_dependencies(builtins, inc_paths, lib_paths):
    library_dirs = get_library_dirs()
    compiler = distutils.ccompiler.new_compiler()
    distutils.sysconfig.customize_compiler(compiler)
    compiler.set_library_dirs(library_dirs)
    missing = []

            

Reported by Pylint.

Redefining name 'lib_paths' from outer scope (line 232)
Error

Line: 70 Column: 52

              #   Make a quick check of any needed library dependencies, and
# add to the library path and include path as needed.  If a library
# is not found, it is not definitive.
def check_needed_dependencies(builtins, inc_paths, lib_paths):
    library_dirs = get_library_dirs()
    compiler = distutils.ccompiler.new_compiler()
    distutils.sysconfig.customize_compiler(compiler)
    compiler.set_library_dirs(library_dirs)
    missing = []

            

Reported by Pylint.

Redefining name 'inc_paths' from outer scope (line 231)
Error

Line: 70 Column: 41

              #   Make a quick check of any needed library dependencies, and
# add to the library path and include path as needed.  If a library
# is not found, it is not definitive.
def check_needed_dependencies(builtins, inc_paths, lib_paths):
    library_dirs = get_library_dirs()
    compiler = distutils.ccompiler.new_compiler()
    distutils.sysconfig.customize_compiler(compiler)
    compiler.set_library_dirs(library_dirs)
    missing = []

            

Reported by Pylint.

XXX: we are not accounting for other directories that might be
Error

Line: 88 Column: 3

                          inc_paths.append(os.path.join(package_top, 'include'))
            lib_paths.append(os.path.join(package_top, 'lib'))

    # XXX: we are not accounting for other directories that might be
    # discoverable via /sbin/ldconfig. It might be better to write a tiny
    # compile using  -lsnappy, -lz...
    #
    #if len(missing) > 0:
    #    die("install packages for: " + str(missing))

            

Reported by Pylint.

Redefining name 'inc_paths' from outer scope (line 231)
Error

Line: 98 Column: 23

              # get_compile_flags --
#   Get system specific compile flags.  Return a triple: C preprocessor
# flags, C compilation flags and linker flags.
def get_compile_flags(inc_paths, lib_paths):
    # Suppress warnings building SWIG generated code
    if sys.platform == 'win32':
        # Windows untested and incomplete, don't claim that it works.
        die('Windows is not supported by this setup script')
    else:

            

Reported by Pylint.

Redefining name 'lib_paths' from outer scope (line 232)
Error

Line: 98 Column: 34

              # get_compile_flags --
#   Get system specific compile flags.  Return a triple: C preprocessor
# flags, C compilation flags and linker flags.
def get_compile_flags(inc_paths, lib_paths):
    # Suppress warnings building SWIG generated code
    if sys.platform == 'win32':
        # Windows untested and incomplete, don't claim that it works.
        die('Windows is not supported by this setup script')
    else:

            

Reported by Pylint.

Redefining name 'cflags' from outer scope (line 236)
Error

Line: 104 Column: 9

                      # Windows untested and incomplete, don't claim that it works.
        die('Windows is not supported by this setup script')
    else:
        cflags = [ '-w', '-Wno-sign-conversion', '-std=c11' ]
        cppflags = ['-I' + path for path in inc_paths]
        cppflags.append('-DHAVE_CONFIG_H')
        ldflags = ['-L' + path for path in lib_paths]
        if sys.platform == 'darwin':
            cflags.extend([ '-arch', 'x86_64' ])

            

Reported by Pylint.

Redefining name 'cppflags' from outer scope (line 236)
Error

Line: 105 Column: 9

                      die('Windows is not supported by this setup script')
    else:
        cflags = [ '-w', '-Wno-sign-conversion', '-std=c11' ]
        cppflags = ['-I' + path for path in inc_paths]
        cppflags.append('-DHAVE_CONFIG_H')
        ldflags = ['-L' + path for path in lib_paths]
        if sys.platform == 'darwin':
            cflags.extend([ '-arch', 'x86_64' ])
    return (cppflags, cflags, ldflags)

            

Reported by Pylint.