The following issues were found

src/third_party/wiredtiger/test/suite/test_rollback_to_stable04.py
21 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.

from wiredtiger import stat
from wtdataset import SimpleDataSet
from wtscenario import make_scenarios
from test_rollback_to_stable01 import test_rollback_to_stable_base

def mod_val(value, char, location, nbytes=1):

            

Reported by Pylint.

An attribute defined in wttest line 401 hides this method
Error

Line: 60 Column: 5

              
    scenarios = make_scenarios(key_format_values, in_memory_values, prepare_values)

    def conn_config(self):
        config = 'cache_size=500MB,statistics=(all)'
        if self.in_memory:
            config += ',in_memory=true'
        else:
            config += ',log=(enabled),in_memory=false'

            

Reported by Pylint.

Undefined variable 'wttest'
Error

Line: 162 Column: 5

                          self.assertGreaterEqual(upd_aborted + hs_removed + hs_sweep, nrows * 11)

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

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
#
# Public Domain 2014-present MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 1

              from wtscenario import make_scenarios
from test_rollback_to_stable01 import test_rollback_to_stable_base

def mod_val(value, char, location, nbytes=1):
    return value[0:location] + char + value[location+nbytes:]

# test_rollback_to_stable04.py
# Test that rollback to stable always replaces the on-disk value with a full update
# from the history store.

            

Reported by Pylint.

Class name "test_rollback_to_stable04" doesn't conform to PascalCase naming style
Error

Line: 40 Column: 1

              # test_rollback_to_stable04.py
# Test that rollback to stable always replaces the on-disk value with a full update
# from the history store.
class test_rollback_to_stable04(test_rollback_to_stable_base):
    session_config = 'isolation=snapshot'

    key_format_values = [
        ('column', dict(key_format='r')),
        ('integer_row', dict(key_format='i')),

            

Reported by Pylint.

Missing class docstring
Error

Line: 40 Column: 1

              # test_rollback_to_stable04.py
# Test that rollback to stable always replaces the on-disk value with a full update
# from the history store.
class test_rollback_to_stable04(test_rollback_to_stable_base):
    session_config = 'isolation=snapshot'

    key_format_values = [
        ('column', dict(key_format='r')),
        ('integer_row', dict(key_format='i')),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 60 Column: 5

              
    scenarios = make_scenarios(key_format_values, in_memory_values, prepare_values)

    def conn_config(self):
        config = 'cache_size=500MB,statistics=(all)'
        if self.in_memory:
            config += ',in_memory=true'
        else:
            config += ',log=(enabled),in_memory=false'

            

Reported by Pylint.

Too many local variables (24/15)
Error

Line: 68 Column: 5

                          config += ',log=(enabled),in_memory=false'
        return config

    def test_rollback_to_stable(self):
        nrows = 1000

        # Create a table without logging.
        uri = "table:rollback_to_stable04"
        ds = SimpleDataSet(

            

Reported by Pylint.

Too many statements (72/50)
Error

Line: 68 Column: 5

                          config += ',log=(enabled),in_memory=false'
        return config

    def test_rollback_to_stable(self):
        nrows = 1000

        # Create a table without logging.
        uri = "table:rollback_to_stable04"
        ds = SimpleDataSet(

            

Reported by Pylint.

src/third_party/wiredtiger/test/3rdparty/testtools-0.9.34/testtools/matchers/_filesystem.py
21 issues
Attempted relative import beyond top-level package
Error

Line: 18 Column: 1

              import os
import tarfile

from ._basic import Equals
from ._higherorder import (
    MatchesAll,
    MatchesPredicate,
    )
from ._impl import (

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 19 Column: 1

              import tarfile

from ._basic import Equals
from ._higherorder import (
    MatchesAll,
    MatchesPredicate,
    )
from ._impl import (
    Matcher,

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 23 Column: 1

                  MatchesAll,
    MatchesPredicate,
    )
from ._impl import (
    Matcher,
    )


def PathExists():

            

Reported by Pylint.

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

Line: 28 Column: 1

                  )


def PathExists():
    """Matches if the given path exists.

    Use like this::

      assertThat('/some/path', PathExists())

            

Reported by Pylint.

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

Line: 38 Column: 1

                  return MatchesPredicate(os.path.exists, "%s does not exist.")


def DirExists():
    """Matches if the path exists and is a directory."""
    return MatchesAll(
        PathExists(),
        MatchesPredicate(os.path.isdir, "%s is not a directory."),
        first_only=True)

            

Reported by Pylint.

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

Line: 46 Column: 1

                      first_only=True)


def FileExists():
    """Matches if the given path exists and is a file."""
    return MatchesAll(
        PathExists(),
        MatchesPredicate(os.path.isfile, "%s is not a file."),
        first_only=True)

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 54 Column: 1

                      first_only=True)


class DirContains(Matcher):
    """Matches if the given directory contains files with the given names.

    That is, is the directory listing exactly equal to the given files?
    """


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 85 Column: 5

                      else:
            self.matcher = Equals(sorted(filenames))

    def match(self, path):
        mismatch = DirExists().match(path)
        if mismatch is not None:
            return mismatch
        return self.matcher.match(sorted(os.listdir(path)))


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 119 Column: 5

                      else:
            self.matcher = matcher

    def match(self, path):
        mismatch = PathExists().match(path)
        if mismatch is not None:
            return mismatch
        f = open(path)
        try:

            

Reported by Pylint.

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

Line: 123 Column: 9

                      mismatch = PathExists().match(path)
        if mismatch is not None:
            return mismatch
        f = open(path)
        try:
            actual_contents = f.read()
            return self.matcher.match(actual_contents)
        finally:
            f.close()

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_checkpoint07.py
21 issues
Unable to import 'wiredtiger'
Error

Line: 32 Column: 1

              # test_checkpoint07.py
# Test that the checkpoints timing statistics are populated as expected.

import wiredtiger, wttest
from wiredtiger import stat
from wtdataset import SimpleDataSet

class test_checkpoint07(wttest.WiredTigerTestCase):
    conn_config = 'cache_size=50MB,log=(enabled),statistics=(all)'

            

Reported by Pylint.

Unable to import 'wiredtiger'
Error

Line: 33 Column: 1

              # Test that the checkpoints timing statistics are populated as expected.

import wiredtiger, wttest
from wiredtiger import stat
from wtdataset import SimpleDataSet

class test_checkpoint07(wttest.WiredTigerTestCase):
    conn_config = 'cache_size=50MB,log=(enabled),statistics=(all)'
    session_config = 'isolation=snapshot'

            

Reported by Pylint.

Unused import wiredtiger
Error

Line: 32 Column: 1

              # test_checkpoint07.py
# Test that the checkpoints timing statistics are populated as expected.

import wiredtiger, wttest
from wiredtiger import stat
from wtdataset import SimpleDataSet

class test_checkpoint07(wttest.WiredTigerTestCase):
    conn_config = 'cache_size=50MB,log=(enabled),statistics=(all)'

            

Reported by Pylint.

Unused SimpleDataSet imported from wtdataset
Error

Line: 34 Column: 1

              
import wiredtiger, wttest
from wiredtiger import stat
from wtdataset import SimpleDataSet

class test_checkpoint07(wttest.WiredTigerTestCase):
    conn_config = 'cache_size=50MB,log=(enabled),statistics=(all)'
    session_config = 'isolation=snapshot'


            

Reported by Pylint.

Attribute 'uri1' defined outside __init__
Error

Line: 48 Column: 9

                      return val

    def test_checkpoint07(self):
        self.uri1 = 'table:ckpt05.1'
        self.file1 = 'file:ckpt05.1.wt'
        self.uri2 = 'table:ckpt05.2'
        self.file2 = 'file:ckpt05.2.wt'
        self.uri3 = 'table:ckpt05.3'
        self.file3 = 'file:ckpt05.3.wt'

            

Reported by Pylint.

Attribute 'file1' defined outside __init__
Error

Line: 49 Column: 9

              
    def test_checkpoint07(self):
        self.uri1 = 'table:ckpt05.1'
        self.file1 = 'file:ckpt05.1.wt'
        self.uri2 = 'table:ckpt05.2'
        self.file2 = 'file:ckpt05.2.wt'
        self.uri3 = 'table:ckpt05.3'
        self.file3 = 'file:ckpt05.3.wt'
        self.session.create(self.uri1, 'key_format=i,value_format=i')

            

Reported by Pylint.

Attribute 'uri2' defined outside __init__
Error

Line: 50 Column: 9

                  def test_checkpoint07(self):
        self.uri1 = 'table:ckpt05.1'
        self.file1 = 'file:ckpt05.1.wt'
        self.uri2 = 'table:ckpt05.2'
        self.file2 = 'file:ckpt05.2.wt'
        self.uri3 = 'table:ckpt05.3'
        self.file3 = 'file:ckpt05.3.wt'
        self.session.create(self.uri1, 'key_format=i,value_format=i')
        self.session.create(self.uri2, 'key_format=i,value_format=i')

            

Reported by Pylint.

Attribute 'file2' defined outside __init__
Error

Line: 51 Column: 9

                      self.uri1 = 'table:ckpt05.1'
        self.file1 = 'file:ckpt05.1.wt'
        self.uri2 = 'table:ckpt05.2'
        self.file2 = 'file:ckpt05.2.wt'
        self.uri3 = 'table:ckpt05.3'
        self.file3 = 'file:ckpt05.3.wt'
        self.session.create(self.uri1, 'key_format=i,value_format=i')
        self.session.create(self.uri2, 'key_format=i,value_format=i')
        self.session.create(self.uri3, 'key_format=i,value_format=i')

            

Reported by Pylint.

Attribute 'uri3' defined outside __init__
Error

Line: 52 Column: 9

                      self.file1 = 'file:ckpt05.1.wt'
        self.uri2 = 'table:ckpt05.2'
        self.file2 = 'file:ckpt05.2.wt'
        self.uri3 = 'table:ckpt05.3'
        self.file3 = 'file:ckpt05.3.wt'
        self.session.create(self.uri1, 'key_format=i,value_format=i')
        self.session.create(self.uri2, 'key_format=i,value_format=i')
        self.session.create(self.uri3, 'key_format=i,value_format=i')


            

Reported by Pylint.

Attribute 'file3' defined outside __init__
Error

Line: 53 Column: 9

                      self.uri2 = 'table:ckpt05.2'
        self.file2 = 'file:ckpt05.2.wt'
        self.uri3 = 'table:ckpt05.3'
        self.file3 = 'file:ckpt05.3.wt'
        self.session.create(self.uri1, 'key_format=i,value_format=i')
        self.session.create(self.uri2, 'key_format=i,value_format=i')
        self.session.create(self.uri3, 'key_format=i,value_format=i')

        # Setup: Insert some data and checkpoint it. Then modify only

            

Reported by Pylint.

src/third_party/mozjs-60/extract/js/src/devtools/rootAnalysis/t/suppression/test.py
21 issues
Undefined variable 'test'
Error

Line: 1 Column: 1

              test.compile("source.cpp")
test.run_analysis_script('gcTypes', upto='gcFunctions')

# The suppressions file uses only mangled names since it's for internal use,
# though I may change that soon given (1) the unfortunate non-uniqueness of
# mangled constructor names, and (2) the usefulness of this file for
# mrgiggles's reporting.
suppressed = test.load_suppressed_functions()


            

Reported by Pylint.

Undefined variable 'test'
Error

Line: 2 Column: 1

              test.compile("source.cpp")
test.run_analysis_script('gcTypes', upto='gcFunctions')

# The suppressions file uses only mangled names since it's for internal use,
# though I may change that soon given (1) the unfortunate non-uniqueness of
# mangled constructor names, and (2) the usefulness of this file for
# mrgiggles's reporting.
suppressed = test.load_suppressed_functions()


            

Reported by Pylint.

Undefined variable 'test'
Error

Line: 8 Column: 14

              # though I may change that soon given (1) the unfortunate non-uniqueness of
# mangled constructor names, and (2) the usefulness of this file for
# mrgiggles's reporting.
suppressed = test.load_suppressed_functions()

# Only one of these is fully suppressed (ie, *always* called within the scope
# of an AutoSuppressGC).
assert(len(list(filter(lambda f: 'suppressedFunction' in f, suppressed))) == 1)
assert(len(list(filter(lambda f: 'halfSuppressedFunction' in f, suppressed))) == 0)

            

Reported by Pylint.

Undefined variable 'test'
Error

Line: 17 Column: 15

              assert(len(list(filter(lambda f: 'unsuppressedFunction' in f, suppressed))) == 0)

# gcFunctions should be the inverse, but we get to rely on unmangled names here.
gcFunctions = test.load_gcFunctions()
print(gcFunctions)
assert('void GC()' in gcFunctions)
assert('void suppressedFunction()' not in gcFunctions)
assert('void halfSuppressedFunction()' in gcFunctions)
assert('void unsuppressedFunction()' in gcFunctions)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              test.compile("source.cpp")
test.run_analysis_script('gcTypes', upto='gcFunctions')

# The suppressions file uses only mangled names since it's for internal use,
# though I may change that soon given (1) the unfortunate non-uniqueness of
# mangled constructor names, and (2) the usefulness of this file for
# mrgiggles's reporting.
suppressed = test.load_suppressed_functions()


            

Reported by Pylint.

Unnecessary parens after 'assert' keyword
Error

Line: 12 Column: 1

              
# Only one of these is fully suppressed (ie, *always* called within the scope
# of an AutoSuppressGC).
assert(len(list(filter(lambda f: 'suppressedFunction' in f, suppressed))) == 1)
assert(len(list(filter(lambda f: 'halfSuppressedFunction' in f, suppressed))) == 0)
assert(len(list(filter(lambda f: 'unsuppressedFunction' in f, suppressed))) == 0)

# gcFunctions should be the inverse, but we get to rely on unmangled names here.
gcFunctions = test.load_gcFunctions()

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 12
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              
# Only one of these is fully suppressed (ie, *always* called within the scope
# of an AutoSuppressGC).
assert(len(list(filter(lambda f: 'suppressedFunction' in f, suppressed))) == 1)
assert(len(list(filter(lambda f: 'halfSuppressedFunction' in f, suppressed))) == 0)
assert(len(list(filter(lambda f: 'unsuppressedFunction' in f, suppressed))) == 0)

# gcFunctions should be the inverse, but we get to rely on unmangled names here.
gcFunctions = test.load_gcFunctions()

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 13
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              # Only one of these is fully suppressed (ie, *always* called within the scope
# of an AutoSuppressGC).
assert(len(list(filter(lambda f: 'suppressedFunction' in f, suppressed))) == 1)
assert(len(list(filter(lambda f: 'halfSuppressedFunction' in f, suppressed))) == 0)
assert(len(list(filter(lambda f: 'unsuppressedFunction' in f, suppressed))) == 0)

# gcFunctions should be the inverse, but we get to rely on unmangled names here.
gcFunctions = test.load_gcFunctions()
print(gcFunctions)

            

Reported by Bandit.

Unnecessary parens after 'assert' keyword
Error

Line: 13 Column: 1

              # Only one of these is fully suppressed (ie, *always* called within the scope
# of an AutoSuppressGC).
assert(len(list(filter(lambda f: 'suppressedFunction' in f, suppressed))) == 1)
assert(len(list(filter(lambda f: 'halfSuppressedFunction' in f, suppressed))) == 0)
assert(len(list(filter(lambda f: 'unsuppressedFunction' in f, suppressed))) == 0)

# gcFunctions should be the inverse, but we get to rely on unmangled names here.
gcFunctions = test.load_gcFunctions()
print(gcFunctions)

            

Reported by Pylint.

Unnecessary parens after 'assert' keyword
Error

Line: 14 Column: 1

              # of an AutoSuppressGC).
assert(len(list(filter(lambda f: 'suppressedFunction' in f, suppressed))) == 1)
assert(len(list(filter(lambda f: 'halfSuppressedFunction' in f, suppressed))) == 0)
assert(len(list(filter(lambda f: 'unsuppressedFunction' in f, suppressed))) == 0)

# gcFunctions should be the inverse, but we get to rely on unmangled names here.
gcFunctions = test.load_gcFunctions()
print(gcFunctions)
assert('void GC()' in gcFunctions)

            

Reported by Pylint.

src/third_party/wiredtiger/bench/wtperf/config.c
21 issues
fprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 807 Column: 17 CWE codes: 134
Suggestion: Use a constant for the format specification

                          }
            if (workp->table_index != INT32_MAX &&
              workp->table_index >= (int32_t)opts->table_count) {
                fprintf(stderr,
                  "Workload table index %" PRId32 " is larger than table count %" PRIu32,
                  workp->table_index, opts->table_count);
                return (EINVAL);
            }
            if (workp->modify != 0 && workp->ops_per_txn == 0) {

            

Reported by FlawFinder.

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

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

                                   */
                    val_pointer = strchr(test_line->string, '=') + 2;
                    concat_str = dmalloc(strlen(conf_line->string) + strlen(val_pointer) + 1);
                    strcpy(concat_str, conf_line->string);
                    concat_str[strlen(concat_str) - 1] = ',';
                    strcat(concat_str, val_pointer);
                    free(test_line->string);
                    test_line->string = concat_str;
                }

            

Reported by FlawFinder.

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

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

                                  concat_str = dmalloc(strlen(conf_line->string) + strlen(val_pointer) + 1);
                    strcpy(concat_str, conf_line->string);
                    concat_str[strlen(concat_str) - 1] = ',';
                    strcat(concat_str, val_pointer);
                    free(test_line->string);
                    test_line->string = concat_str;
                }

                TAILQ_REMOVE(&opts->config_head, conf_line, q);

            

Reported by FlawFinder.

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

Line: 500 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 linelen, optionpos;
    int linenum, ret;
    bool contline;
    char line[4 * 1024], option[4 * 1024];
    char *comment, *ltrim, *rtrim;

    ret = 0;

    if ((fp = fopen(filename, "r")) == 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: 505 Column: 15 CWE codes: 362

              
    ret = 0;

    if ((fp = fopen(filename, "r")) == NULL) {
        fprintf(stderr, "wtperf: %s: %s\n", filename, strerror(errno));
        return (errno);
    }

    optionpos = 0;

            

Reported by FlawFinder.

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

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

                          break;
        }

        memcpy(&option[optionpos], ltrim, linelen);
        option[optionpos + linelen] = '\0';
        if (contline)
            optionpos += linelen;
        else {
            if ((ret = config_opt_str(wtperf, option)) != 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: 891 Column: 30 CWE codes: 362

                  CONFIG_QUEUE_ENTRY *config_line;
    FILE *fp;

    testutil_checkfmt(((fp = fopen(path, "w")) == NULL), "%s", path);

    config_consolidate(opts);

    fprintf(fp,
      "# Warning: This config includes unwritten, implicit configuration defaults.\n"

            

Reported by FlawFinder.

read - Check buffer boundaries if used in a loop including recursive loops
Security

Line: 348 Column: 61 CWE codes: 120 20

                      if (workp->truncate != 0 && workp->threads > 1)
            goto err;
        if (workp->truncate != 0 &&
          (workp->insert > 0 || workp->modify > 0 || workp->read > 0 || workp->update > 0))
            goto err;
        wtperf->workers_cnt += (u_int)workp->threads;
    }

    ret = group->close(group);

            

Reported by FlawFinder.

strlen - Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected)
Security

Line: 389 Column: 13 CWE codes: 126

              
    desc = NULL;
    for (i = 0; i < WT_ELEMENTS(config_opts_desc); i++)
        if (strlen(config_opts_desc[i].name) == k->len &&
          strncmp(config_opts_desc[i].name, k->str, k->len) == 0) {
            desc = &config_opts_desc[i];
            break;
        }
    if (desc == NULL) {

            

Reported by FlawFinder.

strlen - Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected)
Security

Line: 450 Column: 22 CWE codes: 126

                      if (*strp == NULL)
            begin = newstr = dstrdup(v->str);
        else {
            newlen = strlen(*strp) + v->len + strlen(",") + 1;
            newstr = dmalloc(newlen);
            testutil_check(__wt_snprintf(newstr, newlen, "%s,%.*s", *strp, (int)v->len, v->str));
            /* Free the old value now we've copied it. */
            free(*strp);
            begin = &newstr[(newlen - 1) - v->len];

            

Reported by FlawFinder.

src/third_party/fmt/dist/include/fmt/printf.h
21 issues
vprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 182 Column: 6 CWE codes: 134
Suggestion: Use a constant for the format specification

              };

template <typename Char, typename Context>
void vprintf(buffer<Char>& buf, basic_string_view<Char> format,
             basic_format_args<Context> args) {
  Context(buffer_appender<Char>(buf), format, args).format();
}
}  // namespace detail


            

Reported by FlawFinder.

printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 190 Column: 21 CWE codes: 134
Suggestion: Use a constant for the format specification

              
// For printing into memory_buffer.
template <typename Char, typename Context>
FMT_DEPRECATED void printf(detail::buffer<Char>& buf,
                           basic_string_view<Char> format,
                           basic_format_args<Context> args) {
  return detail::vprintf(buf, format, args);
}
using detail::vprintf;

            

Reported by FlawFinder.

vprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 193 Column: 18 CWE codes: 134
Suggestion: Use a constant for the format specification

              FMT_DEPRECATED void printf(detail::buffer<Char>& buf,
                           basic_string_view<Char> format,
                           basic_format_args<Context> args) {
  return detail::vprintf(buf, format, args);
}
using detail::vprintf;

template <typename Char>
class basic_printf_parse_context : public basic_format_parse_context<Char> {

            

Reported by FlawFinder.

vprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 195 Column: 15 CWE codes: 134
Suggestion: Use a constant for the format specification

                                         basic_format_args<Context> args) {
  return detail::vprintf(buf, format, args);
}
using detail::vprintf;

template <typename Char>
class basic_printf_parse_context : public basic_format_parse_context<Char> {
  using basic_format_parse_context<Char>::basic_format_parse_context;
};

            

Reported by FlawFinder.

vsprintf - Potential format string problem
Security

Line: 634 Column: 32 CWE codes: 134
Suggestion: Make format string constant

              }

template <typename S, typename Char = char_t<S>>
inline std::basic_string<Char> vsprintf(
    const S& format,
    basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
  basic_memory_buffer<Char> buffer;
  vprintf(buffer, to_string_view(format), args);
  return to_string(buffer);

            

Reported by FlawFinder.

vprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 638 Column: 3 CWE codes: 134
Suggestion: Use a constant for the format specification

                  const S& format,
    basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
  basic_memory_buffer<Char> buffer;
  vprintf(buffer, to_string_view(format), args);
  return to_string(buffer);
}

/**
  \rst

            

Reported by FlawFinder.

sprintf - Potential format string problem
Security

Line: 653 Column: 32 CWE codes: 134
Suggestion: Make format string constant

              */
template <typename S, typename... Args,
          typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
inline std::basic_string<Char> sprintf(const S& format, const Args&... args) {
  using context = basic_printf_context_t<Char>;
  return vsprintf(to_string_view(format), make_format_args<context>(args...));
}

template <typename S, typename Char = char_t<S>>

            

Reported by FlawFinder.

vsprintf - Potential format string problem
Security

Line: 655 Column: 10 CWE codes: 134
Suggestion: Make format string constant

                        typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
inline std::basic_string<Char> sprintf(const S& format, const Args&... args) {
  using context = basic_printf_context_t<Char>;
  return vsprintf(to_string_view(format), make_format_args<context>(args...));
}

template <typename S, typename Char = char_t<S>>
inline int vfprintf(
    std::FILE* f, const S& format,

            

Reported by FlawFinder.

vfprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 659 Column: 12 CWE codes: 134
Suggestion: Use a constant for the format specification

              }

template <typename S, typename Char = char_t<S>>
inline int vfprintf(
    std::FILE* f, const S& format,
    basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
  basic_memory_buffer<Char> buffer;
  vprintf(buffer, to_string_view(format), args);
  size_t size = buffer.size();

            

Reported by FlawFinder.

vprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 663 Column: 3 CWE codes: 134
Suggestion: Use a constant for the format specification

                  std::FILE* f, const S& format,
    basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
  basic_memory_buffer<Char> buffer;
  vprintf(buffer, to_string_view(format), args);
  size_t size = buffer.size();
  return std::fwrite(buffer.data(), sizeof(Char), size, f) < size
             ? -1
             : static_cast<int>(size);
}

            

Reported by FlawFinder.

src/third_party/wiredtiger/test/suite/test_stat04.py
21 issues
Unable to import 'wiredtiger'
Error

Line: 32 Column: 1

              import os, struct
from suite_subprocess import suite_subprocess
from wtscenario import make_scenarios
import wiredtiger, wttest
from wiredtiger import stat

# test_stat04.py
#    Statistics key/value pair count
class test_stat04(wttest.WiredTigerTestCase, suite_subprocess):

            

Reported by Pylint.

Unable to import 'wiredtiger'
Error

Line: 33 Column: 1

              from suite_subprocess import suite_subprocess
from wtscenario import make_scenarios
import wiredtiger, wttest
from wiredtiger import stat

# test_stat04.py
#    Statistics key/value pair count
class test_stat04(wttest.WiredTigerTestCase, suite_subprocess):
    uripfx = 'table:test_stat04.'

            

Reported by Pylint.

Unused import struct
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 os, struct
from suite_subprocess import suite_subprocess
from wtscenario import make_scenarios
import wiredtiger, wttest
from wiredtiger import stat


            

Reported by Pylint.

Unused import os
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 os, struct
from suite_subprocess import suite_subprocess
from wtscenario import make_scenarios
import wiredtiger, wttest
from wiredtiger import stat


            

Reported by Pylint.

Unused import wiredtiger
Error

Line: 32 Column: 1

              import os, struct
from suite_subprocess import suite_subprocess
from wtscenario import make_scenarios
import wiredtiger, wttest
from wiredtiger import stat

# test_stat04.py
#    Statistics key/value pair count
class test_stat04(wttest.WiredTigerTestCase, suite_subprocess):

            

Reported by Pylint.

Attribute 'valuepfx' defined outside __init__
Error

Line: 56 Column: 9

                  conn_config = 'statistics=(all)'

    def init_test(self):
        self.valuepfx = self.valuesize * 'X'

    def genkey(self, n):
        if self.keyfmt == 'S':
            return 'SOMEKEY' + str(n)
        else:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
#
# Public Domain 2014-present MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled

            

Reported by Pylint.

Multiple imports on one line (os, struct)
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 os, struct
from suite_subprocess import suite_subprocess
from wtscenario import make_scenarios
import wiredtiger, wttest
from wiredtiger import stat


            

Reported by Pylint.

Multiple imports on one line (wiredtiger, wttest)
Error

Line: 32 Column: 1

              import os, struct
from suite_subprocess import suite_subprocess
from wtscenario import make_scenarios
import wiredtiger, wttest
from wiredtiger import stat

# test_stat04.py
#    Statistics key/value pair count
class test_stat04(wttest.WiredTigerTestCase, suite_subprocess):

            

Reported by Pylint.

third party import "import wiredtiger, wttest" should be placed before "from suite_subprocess import suite_subprocess"
Error

Line: 32 Column: 1

              import os, struct
from suite_subprocess import suite_subprocess
from wtscenario import make_scenarios
import wiredtiger, wttest
from wiredtiger import stat

# test_stat04.py
#    Statistics key/value pair count
class test_stat04(wttest.WiredTigerTestCase, suite_subprocess):

            

Reported by Pylint.

src/mongo/dbtests/jsontests.cpp
21 issues
syntax error
Error

Line: 86

                  }
}

TEST(JsonStringTest, BasicTest) {
    checkJsonStringEach({
        {B().obj(), "{}"},                                 // Empty
        {B().append("a", "b").obj(), R"({ "a" : "b" })"},  // SingleStringMember
        {B().append("a", "\" \\ / \b \f \n \r \t").obj(),
         R"({ "a" : "\" \\ / \b \f \n \r \t" })"},  // EscapedCharacters

            

Reported by Cppcheck.

sprintf - Potential format string problem
Security

Line: 679 Column: 21 CWE codes: 134
Suggestion: Make format string constant

                  std::string json = R"({"0":true})";
    BSONObj bson = B().append("0", true).obj();
    for (int depth = 35; depth-- > 0;) {
        json = fmt::sprintf(R"({"%d":%s})", depth, json);
        bson = B().append(std::to_string(depth), bson).obj();
    }
    checkEquivalence(json, bson);
}


            

Reported by FlawFinder.

sprintf - Potential format string problem
Security

Line: 842 Column: 18 CWE codes: 134
Suggestion: Make format string constant

                  };
    for (const auto& ts : specs) {
        checkEquivalence(
            fmt::sprintf(R"({ "a" : { "$binary" : "YWJj", "$type" : "%02x" } })", ts.code),
            BSONObjBuilder().appendBinData("a", 3, ts.bdt, "abc").obj());
    }
}

TEST(FromJsonTest, BinDataPadded) {

            

Reported by FlawFinder.

sprintf - Potential format string problem
Security

Line: 914 Column: 15 CWE codes: 134
Suggestion: Make format string constant

                      // DateStrictMaxUnsigned
        // Need to handle this because jsonString outputs the value of Date_t as unsigned.
        // See SERVER-8330 and SERVER-8573.
        {fmt::sprintf(R"({ "a" : { "$date" : %u } })", u64Max), negDate},

        {fmt::sprintf(R"({ "a" : Date( %u ) })", u64Max), negDate},  // DateMaxUnsigned
        {R"({ "a" : { "$date" : -1 } })", negDate},                  // DateStrictNegative
        {R"({ "a" : Date( -1 ) })", negDate},                        // DateNegative
    });

            

Reported by FlawFinder.

sprintf - Potential format string problem
Security

Line: 916 Column: 15 CWE codes: 134
Suggestion: Make format string constant

                      // See SERVER-8330 and SERVER-8573.
        {fmt::sprintf(R"({ "a" : { "$date" : %u } })", u64Max), negDate},

        {fmt::sprintf(R"({ "a" : Date( %u ) })", u64Max), negDate},  // DateMaxUnsigned
        {R"({ "a" : { "$date" : -1 } })", negDate},                  // DateStrictNegative
        {R"({ "a" : Date( -1 ) })", negDate},                        // DateNegative
    });
    checkRejectionEach({
        fmt::sprintf(R"({ "a" : { "$date" : %u1 } })", u64Max),  // DateStrictTooLong

            

Reported by FlawFinder.

sprintf - Potential format string problem
Security

Line: 921 Column: 14 CWE codes: 134
Suggestion: Make format string constant

                      {R"({ "a" : Date( -1 ) })", negDate},                        // DateNegative
    });
    checkRejectionEach({
        fmt::sprintf(R"({ "a" : { "$date" : %u1 } })", u64Max),  // DateStrictTooLong
        fmt::sprintf(R"({ "a" : Date( %u1 } ) })", u64Max),      // DateTooLong
        R"({ "a" : { "$date" : "100" } })",                      // DateIsString
        R"({ "a" : Date("a") })",                                // DateIsString1
        R"({ "a" : new Date("a") })",                            // DateIsString2
        R"({ "a" : { "$date" : 1.1 } })",                        // DateIsFloat

            

Reported by FlawFinder.

sprintf - Potential format string problem
Security

Line: 922 Column: 14 CWE codes: 134
Suggestion: Make format string constant

                  });
    checkRejectionEach({
        fmt::sprintf(R"({ "a" : { "$date" : %u1 } })", u64Max),  // DateStrictTooLong
        fmt::sprintf(R"({ "a" : Date( %u1 } ) })", u64Max),      // DateTooLong
        R"({ "a" : { "$date" : "100" } })",                      // DateIsString
        R"({ "a" : Date("a") })",                                // DateIsString1
        R"({ "a" : new Date("a") })",                            // DateIsString2
        R"({ "a" : { "$date" : 1.1 } })",                        // DateIsFloat
        R"({ "a" : Date(1.1) })",                                // DateIsFloat1

            

Reported by FlawFinder.

sprintf - Potential format string problem
Security

Line: 938 Column: 15 CWE codes: 134
Suggestion: Make format string constant

              TEST(FromJsonTest, NumberTest) {
    checkEquivalenceEach({
        {R"({ "a" : NumberLong( 20000 ) })", B().append("a", 20000LL).obj()},  // NumberLong
        {fmt::sprintf(R"({'a': NumberLong(%d) })", std::numeric_limits<long long>::min()),
         B().append("a", std::numeric_limits<long long>::min()).obj()},  // NumberLongMin

        {R"({ "a" : NumberInt( 20000 ) })", B().appendNumber("a", 20000).obj()},    // NumberInt
        {R"({ "a" : NumberLong( -20000 ) })", B().append("a", -20000LL).obj()},     // NumberLongNeg
        {R"({ "a" : NumberInt( -20000 ) })", B().appendNumber("a", -20000).obj()},  // NumberIntNeg

            

Reported by FlawFinder.

sprintf - Potential format string problem
Security

Line: 1110 Column: 18 CWE codes: 134
Suggestion: Make format string constant

                      const BSONObj obj =
            B().append("int", val.i).append("long", val.l).append("double", val.d).obj();
        const std::string altReps[] = {
            fmt::sprintf(R"({ "int": %d, "long": %d, "double": %.2f })", val.i, val.l, val.d),
            fmt::sprintf(R"({ 'int': NumberInt(%d), 'long': NumberLong(%d), 'double': %.2f })",
                         val.i,
                         val.l,
                         val.d),
        };

            

Reported by FlawFinder.

sprintf - Potential format string problem
Security

Line: 1111 Column: 18 CWE codes: 134
Suggestion: Make format string constant

                          B().append("int", val.i).append("long", val.l).append("double", val.d).obj();
        const std::string altReps[] = {
            fmt::sprintf(R"({ "int": %d, "long": %d, "double": %.2f })", val.i, val.l, val.d),
            fmt::sprintf(R"({ 'int': NumberInt(%d), 'long': NumberLong(%d), 'double': %.2f })",
                         val.i,
                         val.l,
                         val.d),
        };
        for (const auto& json : altReps) {

            

Reported by FlawFinder.

src/third_party/wiredtiger/test/suite/test_txn22.py
21 issues
Unable to import 'wiredtiger'
Error

Line: 35 Column: 1

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

def copy_for_crash_restart(olddir, newdir):
    ''' Simulate a crash from olddir and restart in newdir. '''
    # with the connection still open, copy files to new directory
    shutil.rmtree(newdir, ignore_errors=True)

            

Reported by Pylint.

Unused import time
Error

Line: 32 Column: 1

              # test_txn22.py
#   Transactions: test salvage with removed

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

def copy_for_crash_restart(olddir, newdir):

            

Reported by Pylint.

Unused import fnmatch
Error

Line: 32 Column: 1

              # test_txn22.py
#   Transactions: test salvage with removed

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

def copy_for_crash_restart(olddir, newdir):

            

Reported by Pylint.

Cell variable salvagedir defined in loop
Error

Line: 161 Column: 50

                                  # But the nature of the 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, self.base_config),
                        '/.*/')

                self.reopen_conn(salvagedir, salvage_config)
                if self.filename == 'test_txn22':
                    self.checks()

            

Reported by Pylint.

Cell variable salvagedir defined in loop
Error

Line: 173 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),
                    '/.*/')

        # The test may output the following error message while opening a file that
        # does not exist. Ignore that.
        self.ignoreStderrPatternIfExists('No such file or directory')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
#
# Public Domain 2014-present MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled

            

Reported by Pylint.

Multiple imports on one line (fnmatch, os, shutil, time)
Error

Line: 32 Column: 1

              # test_txn22.py
#   Transactions: test salvage with removed

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

def copy_for_crash_restart(olddir, newdir):

            

Reported by Pylint.

Multiple imports on one line (wiredtiger, wttest)
Error

Line: 35 Column: 1

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

def copy_for_crash_restart(olddir, newdir):
    ''' Simulate a crash from olddir and restart in newdir. '''
    # with the connection still open, copy files to new directory
    shutil.rmtree(newdir, ignore_errors=True)

            

Reported by Pylint.

third party import "import wiredtiger, wttest" should be placed before "from wtscenario import make_scenarios"
Error

Line: 35 Column: 1

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

def copy_for_crash_restart(olddir, newdir):
    ''' Simulate a crash from olddir and restart in newdir. '''
    # with the connection still open, copy files to new directory
    shutil.rmtree(newdir, ignore_errors=True)

            

Reported by Pylint.

Class name "test_txn22" doesn't conform to PascalCase naming style
Error

Line: 51 Column: 1

                          "Preplog" not in fullname:
            shutil.copy(fullname, newdir)

class test_txn22(wttest.WiredTigerTestCase, suite_subprocess):
    base_config = 'cache_size=1GB'
    conn_config = base_config

    key_format_values = [
        ('integer-row', dict(key_format='i')),

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_prepare15.py
21 issues
Unable to import 'wiredtiger'
Error

Line: 30 Column: 1

              # OTHER DEALINGS IN THE SOFTWARE.

import wttest
from wiredtiger import WT_NOTFOUND
from wtscenario import make_scenarios

# test_prepare15.py
# Test that the prepare transaction rollback removes the on-disk key
# or replace it with history store and commit retains the changes when

            

Reported by Pylint.

An attribute defined in wttest line 401 hides this method
Error

Line: 55 Column: 5

              
    scenarios = make_scenarios(in_memory_values, key_format_values, txn_end_values)

    def conn_config(self):
        config = 'cache_size=50MB'
        if self.in_memory:
            config += ',in_memory=true'
        else:
            config += ',in_memory=false'

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 104 Column: 9

                      # Search for the key so we position our cursor on the page that we want to evict.
        self.session.begin_transaction('ignore_prepare = true')
        evict_cursor.set_key(str(0))
        self.assertEquals(evict_cursor.search(), WT_NOTFOUND)
        evict_cursor.reset()
        evict_cursor.close()
        self.session.commit_transaction()

        if self.commit:

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 124 Column: 9

                      # Search for the key so we position our cursor on the page that we want to evict.
        self.session.begin_transaction()
        evict_cursor.set_key(str(0))
        self.assertEquals(evict_cursor.search(), WT_NOTFOUND)
        evict_cursor.reset()
        evict_cursor.close()
        self.session.commit_transaction()

        self.session.begin_transaction('read_timestamp=' + self.timestamp_str(20))

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 132 Column: 9

                      self.session.begin_transaction('read_timestamp=' + self.timestamp_str(20))
        cursor2 = self.session.open_cursor(uri)
        cursor2.set_key(str(0))
        self.assertEquals(cursor2.search(), 0)
        self.assertEqual(cursor2.get_value(), valuea)
        self.session.commit_transaction()

    def test_prepare_not_found(self):
        # Create a table without logging.

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 164 Column: 9

                      # Search for the key so we position our cursor on the page that we want to evict.
        self.session.begin_transaction("ignore_prepare = true")
        evict_cursor.set_key(str(0))
        self.assertEquals(evict_cursor.search(), WT_NOTFOUND)
        evict_cursor.reset()
        evict_cursor.close()
        self.session.commit_transaction()

        if self.commit:

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 184 Column: 9

                      # Search for the key so we position our cursor on the page that we want to evict.
        self.session.begin_transaction()
        evict_cursor.set_key(str(0))
        self.assertEquals(evict_cursor.search(), WT_NOTFOUND)
        evict_cursor.reset()
        evict_cursor.close()
        self.session.commit_transaction()

        self.session.begin_transaction()

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 192 Column: 9

                      self.session.begin_transaction()
        cursor2 = self.session.open_cursor(uri)
        cursor2.set_key(str(0))
        self.assertEquals(cursor2.search(), WT_NOTFOUND)
        self.session.commit_transaction()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
#
# Public Domain 2014-present MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled

            

Reported by Pylint.

third party import "from wiredtiger import WT_NOTFOUND" should be placed before "import wttest"
Error

Line: 30 Column: 1

              # OTHER DEALINGS IN THE SOFTWARE.

import wttest
from wiredtiger import WT_NOTFOUND
from wtscenario import make_scenarios

# test_prepare15.py
# Test that the prepare transaction rollback removes the on-disk key
# or replace it with history store and commit retains the changes when

            

Reported by Pylint.