The following issues were found

src/third_party/abseil-cpp-master/abseil-cpp/absl/flags/parse.cc
14 issues
StrCat - Does not check for buffer overflows when concatenating to destination [MS-banned]
Security

Line: 177 Column: 15 CWE codes: 120

              
  if (!flag_file) {
    flags_internal::ReportUsageError(
        absl::StrCat("Can't open flagfile ", flag_file_name), true);

    return false;
  }

  // This argument represents fake argv[0], which should be present in all arg

            

Reported by FlawFinder.

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

Line: 211 Column: 15 CWE codes: 120

                  }

    flags_internal::ReportUsageError(
        absl::StrCat("Unexpected line in the flagfile ", flag_file_name, ": ",
                     line),
        true);

    success = false;
  }

            

Reported by FlawFinder.

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

Line: 367 Column: 17 CWE codes: 120

                  // Avoid infinite recursion.
    if (flag_name == "fromenv" || flag_name == "tryfromenv") {
      flags_internal::ReportUsageError(
          absl::StrCat("Infinite recursion on flag ", flag_name), true);

      success = false;
      continue;
    }


            

Reported by FlawFinder.

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

Line: 373 Column: 39 CWE codes: 120

                    continue;
    }

    const std::string envname = absl::StrCat("FLAGS_", flag_name);
    std::string envval;
    if (!GetEnvVar(envname.c_str(), envval)) {
      if (fail_on_absent_in_env) {
        flags_internal::ReportUsageError(
            absl::StrCat(envname, " not found in environment"), true);

            

Reported by FlawFinder.

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

Line: 378 Column: 19 CWE codes: 120

                  if (!GetEnvVar(envname.c_str(), envval)) {
      if (fail_on_absent_in_env) {
        flags_internal::ReportUsageError(
            absl::StrCat(envname, " not found in environment"), true);

        success = false;
      }

      continue;

            

Reported by FlawFinder.

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

Line: 386 Column: 26 CWE codes: 120

                    continue;
    }

    args.push_back(absl::StrCat("--", flag_name, "=", envval));
  }

  if (success) {
    input_args.emplace_back(args);
  }

            

Reported by FlawFinder.

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

Line: 517 Column: 19 CWE codes: 120

                    if (is_empty_value) {
        // "--bool_flag=" case
        flags_internal::ReportUsageError(
            absl::StrCat(
                "Missing the value after assignment for the boolean flag '",
                flag.Name(), "'"),
            true);
        return std::make_tuple(false, "");
      }

            

Reported by FlawFinder.

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

Line: 529 Column: 17 CWE codes: 120

                  } else if (is_negative) {
      // "--nobool_flag=Y" case
      flags_internal::ReportUsageError(
          absl::StrCat("Negative form with assignment is not valid for the "
                       "boolean flag '",
                       flag.Name(), "'"),
          true);
      return std::make_tuple(false, "");
    }

            

Reported by FlawFinder.

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

Line: 538 Column: 15 CWE codes: 120

                } else if (is_negative) {
    // "--noint_flag=1" case
    flags_internal::ReportUsageError(
        absl::StrCat("Negative form is not valid for the flag '", flag.Name(),
                     "'"),
        true);
    return std::make_tuple(false, "");
  } else if (value.empty() && (!is_empty_value)) {
    if (curr_list->Size() == 1) {

            

Reported by FlawFinder.

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

Line: 546 Column: 17 CWE codes: 120

                  if (curr_list->Size() == 1) {
      // "--int_flag" case
      flags_internal::ReportUsageError(
          absl::StrCat("Missing the value for the flag '", flag.Name(), "'"),
          true);
      return std::make_tuple(false, "");
    }

    // "--int_flag" "10" case

            

Reported by FlawFinder.

src/third_party/wiredtiger/test/suite/test_prepare06.py
14 issues
Unable to import 'wiredtiger'
Error

Line: 34 Column: 1

              #

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

class test_prepare06(wttest.WiredTigerTestCase, suite_subprocess):
    tablename = 'test_prepare06'
    uri = 'table:' + tablename

            

Reported by Pylint.

Unused variable 'c'
Error

Line: 51 Column: 9

              
    def test_timestamp_api(self):
        self.session.create(self.uri, 'key_format={},value_format=i'.format(self.key_format))
        c = self.session.open_cursor(self.uri)

        # It is illegal to set the prepare timestamp older than the oldest
        # timestamp.
        self.conn.set_timestamp('oldest_timestamp=' + self.timestamp_str(20))
        self.conn.set_timestamp('stable_timestamp=' + self.timestamp_str(30))

            

Reported by Pylint.

String statement has no effect
Error

Line: 72 Column: 9

                      self.session.timestamp_transaction('durable_timestamp=' + self.timestamp_str(35))
        self.session.commit_transaction()

        '''
        Commented out for now: the system panics if we fail after preparing a transaction.

        # Check setting a prepared transaction timestamps earlier than the
        # oldest timestamp is invalid, if durable timestamp is less than the
        # stable timestamp.

            

Reported by Pylint.

String statement has no effect
Error

Line: 107 Column: 9

                          self.assertEqual(self.session.prepare_transaction('prepare_timestamp=' + self.timestamp_str(40)), 0)
            self.session.rollback_transaction()

        '''
        Commented out for now: the system panics if we fail after preparing a transaction.

        # It is illegal to set a commit timestamp less than the prepare
        # timestamp of a transaction.
        self.session.begin_transaction()

            

Reported by Pylint.

String statement has no effect
Error

Line: 121 Column: 9

                          "/less than the prepare timestamp/")
        '''

        '''
        Commented out for now: the system panics if we fail after preparing a transaction.

        # It is legal to set a commit timestamp older than prepare timestamp of
        # a transaction with roundup_timestamps settings.
        self.session.begin_transaction('roundup_timestamps=(prepared=true)')

            

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 (wiredtiger, wttest)
Error

Line: 34 Column: 1

              #

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

class test_prepare06(wttest.WiredTigerTestCase, suite_subprocess):
    tablename = 'test_prepare06'
    uri = 'table:' + tablename

            

Reported by Pylint.

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

Line: 34 Column: 1

              #

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

class test_prepare06(wttest.WiredTigerTestCase, suite_subprocess):
    tablename = 'test_prepare06'
    uri = 'table:' + tablename

            

Reported by Pylint.

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

Line: 37 Column: 1

              import wiredtiger, wttest
from wtscenario import make_scenarios

class test_prepare06(wttest.WiredTigerTestCase, suite_subprocess):
    tablename = 'test_prepare06'
    uri = 'table:' + tablename
    session_config = 'isolation=snapshot'

    key_format_values = [

            

Reported by Pylint.

Missing class docstring
Error

Line: 37 Column: 1

              import wiredtiger, wttest
from wtscenario import make_scenarios

class test_prepare06(wttest.WiredTigerTestCase, suite_subprocess):
    tablename = 'test_prepare06'
    uri = 'table:' + tablename
    session_config = 'isolation=snapshot'

    key_format_values = [

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_util07.py
14 issues
Unable to import 'wiredtiger'
Error

Line: 31 Column: 1

              
import os, struct
from suite_subprocess import suite_subprocess
import wiredtiger, wttest

# test_util07.py
#    Utilities: wt read
class test_util07(wttest.WiredTigerTestCase, suite_subprocess):
    tablename = 'test_util07.a'

            

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
import wiredtiger, wttest

# test_util07.py
#    Utilities: wt read

            

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
import wiredtiger, wttest

# test_util07.py
#    Utilities: wt read

            

Reported by Pylint.

Unused import wiredtiger
Error

Line: 31 Column: 1

              
import os, struct
from suite_subprocess import suite_subprocess
import wiredtiger, wttest

# test_util07.py
#    Utilities: wt read
class test_util07(wttest.WiredTigerTestCase, suite_subprocess):
    tablename = 'test_util07.a'

            

Reported by Pylint.

Parameters differ from overridden 'close_conn' method
Error

Line: 51 Column: 5

                          cursor[key] = val
        cursor.close()

    def close_conn(self):
        """
        Close the connection if already open.
        """
        if self.conn != None:
            self.conn.close()

            

Reported by Pylint.

Parameters differ from overridden 'open_conn' method
Error

Line: 59 Column: 5

                          self.conn.close()
            self.conn = None

    def open_conn(self):
        """
        Open the connection if already closed.
        """
        if self.conn == None:
            self.conn = self.setUpConnectionOpen(".")

            

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
import wiredtiger, wttest

# test_util07.py
#    Utilities: wt read

            

Reported by Pylint.

Multiple imports on one line (wiredtiger, wttest)
Error

Line: 31 Column: 1

              
import os, struct
from suite_subprocess import suite_subprocess
import wiredtiger, wttest

# test_util07.py
#    Utilities: wt read
class test_util07(wttest.WiredTigerTestCase, suite_subprocess):
    tablename = 'test_util07.a'

            

Reported by Pylint.

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

Line: 31 Column: 1

              
import os, struct
from suite_subprocess import suite_subprocess
import wiredtiger, wttest

# test_util07.py
#    Utilities: wt read
class test_util07(wttest.WiredTigerTestCase, suite_subprocess):
    tablename = 'test_util07.a'

            

Reported by Pylint.

src/third_party/wiredtiger/dist/flags.py
14 issues
Redefining name 'name' from outer scope (line 77)
Error

Line: 15 Column: 18

              # #define WT_NEW_FLAG_NAME      0x0u
#
# and it will be automatically alphabetized and assigned the proper value.
def flag_declare(name):
    tmp_file = '__tmp'
    with open(name, 'r') as f:
        tfile = open(tmp_file, 'w')

        lcnt = 0

            

Reported by Pylint.

Anomalous backslash in string: '\d'. String constant might be missing an r prefix.
Error

Line: 26 Column: 32

                      for line in f:
            lcnt = lcnt + 1
            if line.find('AUTOMATIC FLAG VALUE GENERATION START') != -1:
                m = re.search("\d+", line)
                if m == None:
                    print(name + ": automatic flag generation start at line " +
                        str(lcnt) + " needs start value e.g. AUTOMATIC FLAG VALUE" +
                        " GENERATION START 0", file=sys.stderr)
                    sys.exit(1)

            

Reported by Pylint.

Anomalous backslash in string: '\d'. String constant might be missing an r prefix.
Error

Line: 37 Column: 32

                              defines = []
                parsing = True
            elif line.find('AUTOMATIC FLAG VALUE GENERATION STOP') != -1:
                m = re.search("\d+", line)
                if m == None:
                    print(name + ": automatic flag generation stop at line " +
                        str(lcnt) + " needs stop value e.g. AUTOMATIC FLAG VALUE" +
                        " GENERATION STOP 32", file=sys.stderr)
                    sys.exit(1)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python

from __future__ import print_function
import re, sys
from dist import all_c_files, all_h_files, compare_srcfile

# Automatically build flags values: read through all of the header files, and
# for each group of flags, sort them, check the start and stop boundaries on
# the flags and give them a unique value.

            

Reported by Pylint.

Multiple imports on one line (re, sys)
Error

Line: 4 Column: 1

              #!/usr/bin/env python

from __future__ import print_function
import re, sys
from dist import all_c_files, all_h_files, compare_srcfile

# Automatically build flags values: read through all of the header files, and
# for each group of flags, sort them, check the start and stop boundaries on
# the flags and give them a unique value.

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

              # #define WT_NEW_FLAG_NAME      0x0u
#
# and it will be automatically alphabetized and assigned the proper value.
def flag_declare(name):
    tmp_file = '__tmp'
    with open(name, 'r') as f:
        tfile = open(tmp_file, 'w')

        lcnt = 0

            

Reported by Pylint.

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

Line: 17 Column: 29

              # and it will be automatically alphabetized and assigned the proper value.
def flag_declare(name):
    tmp_file = '__tmp'
    with open(name, 'r') as f:
        tfile = open(tmp_file, 'w')

        lcnt = 0
        parsing = False
        start = 0

            

Reported by Pylint.

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

Line: 26 Column: 17

                      for line in f:
            lcnt = lcnt + 1
            if line.find('AUTOMATIC FLAG VALUE GENERATION START') != -1:
                m = re.search("\d+", line)
                if m == None:
                    print(name + ": automatic flag generation start at line " +
                        str(lcnt) + " needs start value e.g. AUTOMATIC FLAG VALUE" +
                        " GENERATION START 0", file=sys.stderr)
                    sys.exit(1)

            

Reported by Pylint.

Comparison 'm == None' should be 'm is None'
Error

Line: 27 Column: 20

                          lcnt = lcnt + 1
            if line.find('AUTOMATIC FLAG VALUE GENERATION START') != -1:
                m = re.search("\d+", line)
                if m == None:
                    print(name + ": automatic flag generation start at line " +
                        str(lcnt) + " needs start value e.g. AUTOMATIC FLAG VALUE" +
                        " GENERATION START 0", file=sys.stderr)
                    sys.exit(1)
                start = int(m.group(0))

            

Reported by Pylint.

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

Line: 37 Column: 17

                              defines = []
                parsing = True
            elif line.find('AUTOMATIC FLAG VALUE GENERATION STOP') != -1:
                m = re.search("\d+", line)
                if m == None:
                    print(name + ": automatic flag generation stop at line " +
                        str(lcnt) + " needs stop value e.g. AUTOMATIC FLAG VALUE" +
                        " GENERATION STOP 32", file=sys.stderr)
                    sys.exit(1)

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_alter01.py
14 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 wtscenario import make_scenarios

# test_alter01.py
#    Smoke-test the session alter operations.
class test_alter01(wttest.WiredTigerTestCase):

            

Reported by Pylint.

Unused 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 wtscenario import make_scenarios

# test_alter01.py
#    Smoke-test the session alter operations.
class test_alter01(wttest.WiredTigerTestCase):

            

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 (wiredtiger, wttest)
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 wtscenario import make_scenarios

# test_alter01.py
#    Smoke-test the session alter operations.
class test_alter01(wttest.WiredTigerTestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 34 Column: 1

              
# test_alter01.py
#    Smoke-test the session alter operations.
class test_alter01(wttest.WiredTigerTestCase):
    name = "alter01"
    entries = 100
    # Settings for access_pattern_hint
    types = [
        ('file', dict(uri='file:', use_cg=False, use_index=False)),

            

Reported by Pylint.

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

Line: 34 Column: 1

              
# test_alter01.py
#    Smoke-test the session alter operations.
class test_alter01(wttest.WiredTigerTestCase):
    name = "alter01"
    entries = 100
    # Settings for access_pattern_hint
    types = [
        ('file', dict(uri='file:', use_cg=False, use_index=False)),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 65 Column: 5

                  cache_alter=('', 'false', 'true')
    scenarios = make_scenarios(types, hints, resid, reopen)

    def verify_metadata(self, metastr):
        if metastr == '':
            return
        cursor = self.session.open_cursor('metadata:', None, None)
        #
        # Walk through all the metadata looking for the entries that are

            

Reported by Pylint.

Comparison 'found == True' should be 'found is True' if checking for the singleton value True, or 'bool(found)' if testing for truthiness
Error

Line: 86 Column: 25

                              found = True
                self.assertTrue(value.find(metastr) != -1)
        cursor.close()
        self.assertTrue(found == True)

    # Alter: Change the access pattern hint after creation
    def test_alter01_access(self):
        uri = self.uri + self.name
        create_params = 'key_format=i,value_format=i,'

            

Reported by Pylint.

Too many statements (55/50)
Error

Line: 89 Column: 5

                      self.assertTrue(found == True)

    # Alter: Change the access pattern hint after creation
    def test_alter01_access(self):
        uri = self.uri + self.name
        create_params = 'key_format=i,value_format=i,'
        complex_params = ''
        #
        # If we're not explicitly setting the parameter, then don't

            

Reported by Pylint.

Too many branches (17/12)
Error

Line: 89 Column: 5

                      self.assertTrue(found == True)

    # Alter: Change the access pattern hint after creation
    def test_alter01_access(self):
        uri = self.uri + self.name
        create_params = 'key_format=i,value_format=i,'
        complex_params = ''
        #
        # If we're not explicitly setting the parameter, then don't

            

Reported by Pylint.

src/mongo/shell/mongo_main.cpp
14 issues
system - This causes a new program to execute and is difficult to use safely
Security

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

                  sb << editor << " " << filename;
    int ret = [&] {
        auto lds = ShellBackend::LoggingDisabledScope();
        return ::system(sb.str().c_str());
    }();
    if (ret) {
        if (ret == -1) {
            int systemErrno = errno;
            std::cout << "failed to launch $EDITOR (" << editor

            

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: 531 Column: 44 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                  if (shellMainScope->type("EDITOR") == String) {
        editor = shellMainScope->getString("EDITOR");
    } else {
        static const char* editorFromEnv = getenv("EDITOR");
        if (editorFromEnv) {
            editor = editorFromEnv;
        }
    }
    if (editor.empty()) {

            

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: 947 Column: 21 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                          std::string rcLocation;
            if (!shellGlobalParams.norc) {
#ifndef _WIN32
                if (getenv("HOME") != nullptr)
                    rcLocation = str::stream() << getenv("HOME") << "/.mongorc.js";
#else
                if (getenv("HOMEDRIVE") != nullptr && getenv("HOMEPATH") != nullptr)
                    rcLocation = str::stream()
                        << toUtf8String(_wgetenv(L"HOMEDRIVE"))

            

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: 948 Column: 51 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                          if (!shellGlobalParams.norc) {
#ifndef _WIN32
                if (getenv("HOME") != nullptr)
                    rcLocation = str::stream() << getenv("HOME") << "/.mongorc.js";
#else
                if (getenv("HOMEDRIVE") != nullptr && getenv("HOMEPATH") != nullptr)
                    rcLocation = str::stream()
                        << toUtf8String(_wgetenv(L"HOMEDRIVE"))
                        << toUtf8String(_wgetenv(L"HOMEPATH")) << "\\.mongorc.js";

            

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: 950 Column: 21 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                              if (getenv("HOME") != nullptr)
                    rcLocation = str::stream() << getenv("HOME") << "/.mongorc.js";
#else
                if (getenv("HOMEDRIVE") != nullptr && getenv("HOMEPATH") != nullptr)
                    rcLocation = str::stream()
                        << toUtf8String(_wgetenv(L"HOMEDRIVE"))
                        << toUtf8String(_wgetenv(L"HOMEPATH")) << "\\.mongorc.js";
#endif
                if (!rcLocation.empty() && ::mongo::shell_utils::fileExists(rcLocation)) {

            

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: 950 Column: 55 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                              if (getenv("HOME") != nullptr)
                    rcLocation = str::stream() << getenv("HOME") << "/.mongorc.js";
#else
                if (getenv("HOMEDRIVE") != nullptr && getenv("HOMEPATH") != nullptr)
                    rcLocation = str::stream()
                        << toUtf8String(_wgetenv(L"HOMEDRIVE"))
                        << toUtf8String(_wgetenv(L"HOMEPATH")) << "\\.mongorc.js";
#endif
                if (!rcLocation.empty() && ::mongo::shell_utils::fileExists(rcLocation)) {

            

Reported by FlawFinder.

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

Line: 581 Column: 9 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                  for (i = 0; i < maxAttempts; ++i) {
        StringBuilder sb;
#ifdef _WIN32
        char tempFolder[MAX_PATH];
        GetTempPathA(sizeof tempFolder, tempFolder);
        sb << tempFolder << "mongo_edit" << time(0) + i << ".js";
#else
        sb << "/tmp/mongo_edit" << time(nullptr) + i << ".js";
#endif

            

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: 599 Column: 22 CWE codes: 362

              
    // Create the temp file
    FILE* tempFileStream;
    tempFileStream = fopen(filename.c_str(), "wt");
    if (!tempFileStream) {
        std::cout << "couldn't create temp file (" << filename << "): " << errnoWithDescription()
                  << std::endl;
        return;
    }

            

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: 638 Column: 22 CWE codes: 362

                  }

    // The editor gave return code zero, so read the file back in
    tempFileStream = fopen(filename.c_str(), "rt");
    if (!tempFileStream) {
        std::cout << "couldn't open temp file on return from editor: " << errnoWithDescription()
                  << std::endl;
        remove(filename.c_str());
        return;

            

Reported by FlawFinder.

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

Line: 648 Column: 9 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                  sb.reset();
    int bytes;
    do {
        char buf[1024];
        bytes = fread(buf, sizeof(char), sizeof buf, tempFileStream);
        if (ferror(tempFileStream)) {
            std::cout << "failed to read temp file: " << errnoWithDescription() << std::endl;
            fclose(tempFileStream);
            remove(filename.c_str());

            

Reported by FlawFinder.

src/third_party/wiredtiger/test/suite/test_compact01.py
14 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 suite_subprocess import suite_subprocess
from wtdataset import SimpleDataSet, ComplexDataSet
from wiredtiger import stat
from wtscenario import make_scenarios


            

Reported by Pylint.

Unable to import 'wiredtiger'
Error

Line: 32 Column: 1

              import wiredtiger, wttest
from suite_subprocess import suite_subprocess
from wtdataset import SimpleDataSet, ComplexDataSet
from wiredtiger import stat
from wtscenario import make_scenarios

# test_compact.py
#    session level compact operation
class test_compact(wttest.WiredTigerTestCase, suite_subprocess):

            

Reported by Pylint.

Unused 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 suite_subprocess import suite_subprocess
from wtdataset import SimpleDataSet, ComplexDataSet
from wiredtiger import stat
from wtscenario import make_scenarios


            

Reported by Pylint.

FIXME-WT-7187
Error

Line: 65 Column: 3

              
    # Test compaction.
    def test_compact(self):
        # FIXME-WT-7187
        # This test is temporarily disabled for OS/X, it fails often, but not consistently.
        import platform
        if platform.system() == 'Darwin':
            self.skipTest('Compaction tests skipped, as they fail on OS/X')


            

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 (wiredtiger, wttest)
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 suite_subprocess import suite_subprocess
from wtdataset import SimpleDataSet, ComplexDataSet
from wiredtiger import stat
from wtscenario import make_scenarios


            

Reported by Pylint.

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

Line: 32 Column: 1

              import wiredtiger, wttest
from suite_subprocess import suite_subprocess
from wtdataset import SimpleDataSet, ComplexDataSet
from wiredtiger import stat
from wtscenario import make_scenarios

# test_compact.py
#    session level compact operation
class test_compact(wttest.WiredTigerTestCase, suite_subprocess):

            

Reported by Pylint.

Missing class docstring
Error

Line: 37 Column: 1

              
# test_compact.py
#    session level compact operation
class test_compact(wttest.WiredTigerTestCase, suite_subprocess):
    name = 'test_compact'

    # Use a small page size because we want to create lots of pages.
    config = 'allocation_size=512,' +\
        'leaf_page_max=512,key_format=S'

            

Reported by Pylint.

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

Line: 37 Column: 1

              
# test_compact.py
#    session level compact operation
class test_compact(wttest.WiredTigerTestCase, suite_subprocess):
    name = 'test_compact'

    # Use a small page size because we want to create lots of pages.
    config = 'allocation_size=512,' +\
        'leaf_page_max=512,key_format=S'

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 64 Column: 5

                      'eviction_dirty_target=80,eviction_dirty_trigger=95,statistics=(all)'

    # Test compaction.
    def test_compact(self):
        # FIXME-WT-7187
        # This test is temporarily disabled for OS/X, it fails often, but not consistently.
        import platform
        if platform.system() == 'Darwin':
            self.skipTest('Compaction tests skipped, as they fail on OS/X')

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_gc03.py
14 issues
Unable to import 'wiredtiger'
Error

Line: 30 Column: 1

              # OTHER DEALINGS IN THE SOFTWARE.

from test_gc01 import test_gc_base
from wiredtiger import stat
from wtdataset import SimpleDataSet

# test_gc03.py
# Test that checkpoint cleans the obsolete history store pages that are in-memory.
class test_gc03(test_gc_base):

            

Reported by Pylint.

Undefined variable 'wttest'
Error

Line: 143 Column: 5

                      self.check(bigvalue, uri, nrows, 300)

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

            

Reported by Pylint.

Redefining name 'stat' from outer scope (line 30)
Error

Line: 39 Column: 24

                  conn_config = 'cache_size=4GB,log=(enabled),statistics=(all),statistics_log=(wait=0,on_close=true)'
    session_config = 'isolation=snapshot'

    def get_stat(self, stat):
        stat_cursor = self.session.open_cursor('statistics:')
        val = stat_cursor[stat][2]
        stat_cursor.close()
        return val


            

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 stat" should be placed before "from test_gc01 import test_gc_base"
Error

Line: 30 Column: 1

              # OTHER DEALINGS IN THE SOFTWARE.

from test_gc01 import test_gc_base
from wiredtiger import stat
from wtdataset import SimpleDataSet

# test_gc03.py
# Test that checkpoint cleans the obsolete history store pages that are in-memory.
class test_gc03(test_gc_base):

            

Reported by Pylint.

Missing class docstring
Error

Line: 35 Column: 1

              
# test_gc03.py
# Test that checkpoint cleans the obsolete history store pages that are in-memory.
class test_gc03(test_gc_base):
    conn_config = 'cache_size=4GB,log=(enabled),statistics=(all),statistics_log=(wait=0,on_close=true)'
    session_config = 'isolation=snapshot'

    def get_stat(self, stat):
        stat_cursor = self.session.open_cursor('statistics:')

            

Reported by Pylint.

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

Line: 35 Column: 1

              
# test_gc03.py
# Test that checkpoint cleans the obsolete history store pages that are in-memory.
class test_gc03(test_gc_base):
    conn_config = 'cache_size=4GB,log=(enabled),statistics=(all),statistics_log=(wait=0,on_close=true)'
    session_config = 'isolation=snapshot'

    def get_stat(self, stat):
        stat_cursor = self.session.open_cursor('statistics:')

            

Reported by Pylint.

Line too long (103/100)
Error

Line: 36 Column: 1

              # test_gc03.py
# Test that checkpoint cleans the obsolete history store pages that are in-memory.
class test_gc03(test_gc_base):
    conn_config = 'cache_size=4GB,log=(enabled),statistics=(all),statistics_log=(wait=0,on_close=true)'
    session_config = 'isolation=snapshot'

    def get_stat(self, stat):
        stat_cursor = self.session.open_cursor('statistics:')
        val = stat_cursor[stat][2]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 5

                  conn_config = 'cache_size=4GB,log=(enabled),statistics=(all),statistics_log=(wait=0,on_close=true)'
    session_config = 'isolation=snapshot'

    def get_stat(self, stat):
        stat_cursor = self.session.open_cursor('statistics:')
        val = stat_cursor[stat][2]
        stat_cursor.close()
        return val


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 45 Column: 5

                      stat_cursor.close()
        return val

    def test_gc(self):
        nrows = 10000

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

            

Reported by Pylint.

src/third_party/wiredtiger/test/readonly/readonly.c
14 issues
system - This causes a new program to execute and is difficult to use safely
Security

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

                   */
    testutil_check(__wt_snprintf(
      cmd, sizeof(cmd), "cp -rp %s/* %s; rm -f %s/WiredTiger.lock", home, home_wr, home_wr));
    if ((status = system(cmd)) < 0)
        testutil_die(status, "system: %s", cmd);

    testutil_check(__wt_snprintf(cmd, sizeof(cmd),
      "cp -rp %s/* %s; chmod 0555 %s; chmod -R 0444 %s/*", home, home_rd, home_rd, home_rd));
    if ((status = system(cmd)) < 0)

            

Reported by FlawFinder.

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

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

              
    testutil_check(__wt_snprintf(cmd, sizeof(cmd),
      "cp -rp %s/* %s; chmod 0555 %s; chmod -R 0444 %s/*", home, home_rd, home_rd, home_rd));
    if ((status = system(cmd)) < 0)
        testutil_die(status, "system: %s", cmd);

    testutil_check(__wt_snprintf(cmd, sizeof(cmd),
      "cp -rp %s/* %s; rm -f %s/WiredTiger.lock; chmod 0555 %s; chmod -R 0444 %s/*", home, home_rd2,
      home_rd2, home_rd2, home_rd2));

            

Reported by FlawFinder.

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

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

                  testutil_check(__wt_snprintf(cmd, sizeof(cmd),
      "cp -rp %s/* %s; rm -f %s/WiredTiger.lock; chmod 0555 %s; chmod -R 0444 %s/*", home, home_rd2,
      home_rd2, home_rd2, home_rd2));
    if ((status = system(cmd)) < 0)
        testutil_die(status, "system: %s", cmd);

    /*
     * Run four scenarios.  Sometimes expect errors, sometimes success.
     * The writable database directories should always fail to allow the

            

Reported by FlawFinder.

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

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

                   * The child will exit with success if its test passes.
     */
    testutil_check(__wt_snprintf(cmd, sizeof(cmd), "%s -h %s -R", saved_argv0, working_dir));
    if ((status = system(cmd)) < 0)
        testutil_die(status, "system: %s", cmd);
    if (WEXITSTATUS(status) != 0)
        testutil_die(WEXITSTATUS(status), "system: %s", cmd);

    /*

            

Reported by FlawFinder.

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

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

                   * Scenario 2. Run child with writable config.
     */
    testutil_check(__wt_snprintf(cmd, sizeof(cmd), "%s -h %s -W", saved_argv0, working_dir));
    if ((status = system(cmd)) < 0)
        testutil_die(status, "system: %s", cmd);
    if (WEXITSTATUS(status) != 0)
        testutil_die(WEXITSTATUS(status), "system: %s", cmd);

    /*

            

Reported by FlawFinder.

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

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

                   * Scenario 3. Child read-only.
     */
    testutil_check(__wt_snprintf(cmd, sizeof(cmd), "%s -h %s -R", saved_argv0, working_dir));
    if ((status = system(cmd)) < 0)
        testutil_die(status, "system: %s", cmd);
    if (WEXITSTATUS(status) != 0)
        testutil_die(WEXITSTATUS(status), "system: %s", cmd);

    /*

            

Reported by FlawFinder.

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

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

                   * Scenario 4. Run child with writable config.
     */
    testutil_check(__wt_snprintf(cmd, sizeof(cmd), "%s -h %s -W", saved_argv0, working_dir));
    if ((status = system(cmd)) < 0)
        testutil_die(status, "system: %s", cmd);
    if (WEXITSTATUS(status) != 0)
        testutil_die(WEXITSTATUS(status), "system: %s", cmd);

    /*

            

Reported by FlawFinder.

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

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

                   * We need to chmod the read-only databases back so that they can be removed by scripts.
     */
    testutil_check(__wt_snprintf(cmd, sizeof(cmd), "chmod 0777 %s %s", home_rd, home_rd2));
    if ((status = system(cmd)) < 0)
        testutil_die(status, "system: %s", cmd);
    testutil_check(__wt_snprintf(cmd, sizeof(cmd), "chmod -R 0666 %s/* %s/*", home_rd, home_rd2));
    if ((status = system(cmd)) < 0)
        testutil_die(status, "system: %s", cmd);
    printf(" *** Readonly test successful ***\n");

            

Reported by FlawFinder.

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

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

                  if ((status = system(cmd)) < 0)
        testutil_die(status, "system: %s", cmd);
    testutil_check(__wt_snprintf(cmd, sizeof(cmd), "chmod -R 0666 %s/* %s/*", home_rd, home_rd2));
    if ((status = system(cmd)) < 0)
        testutil_die(status, "system: %s", cmd);
    printf(" *** Readonly test successful ***\n");
    return (EXIT_SUCCESS);
}

            

Reported by FlawFinder.

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

Line: 34 Column: 8 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              #include <sys/wait.h>

#define HOME_SIZE 512
static char home[HOME_SIZE];       /* Program working dir lock file */
#define HOME_WR_SUFFIX ".WRNOLOCK" /* Writable dir copy no lock file */
static char home_wr[HOME_SIZE + sizeof(HOME_WR_SUFFIX)];
#define HOME_RD_SUFFIX ".RD" /* Read-only dir */
static char home_rd[HOME_SIZE + sizeof(HOME_RD_SUFFIX)];
#define HOME_RD2_SUFFIX ".RDNOLOCK" /* Read-only dir no lock file */

            

Reported by FlawFinder.

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

# test_debug_info.py
#    Test WT_CONNECTION::debug_info undocumented feature
class test_debug_info(wttest.WiredTigerTestCase):
    conn_config = 'create,log=(enabled),statistics=(fast)'

            

Reported by Pylint.

Unused 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

# test_debug_info.py
#    Test WT_CONNECTION::debug_info undocumented feature
class test_debug_info(wttest.WiredTigerTestCase):
    conn_config = 'create,log=(enabled),statistics=(fast)'

            

Reported by Pylint.

Unused variable 'val'
Error

Line: 45 Column: 9

                          c[k] = 1
        c.close()
        c = self.session.open_cursor(self.uri, None)
        val = c[50]
        self.conn.debug_info('cursors')
        c.close()

    def conn_cursors_special(self, special_uri):
        c = self.session.open_cursor(special_uri, None, None)

            

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 (wiredtiger, wttest)
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

# test_debug_info.py
#    Test WT_CONNECTION::debug_info undocumented feature
class test_debug_info(wttest.WiredTigerTestCase):
    conn_config = 'create,log=(enabled),statistics=(fast)'

            

Reported by Pylint.

Missing class docstring
Error

Line: 33 Column: 1

              
# test_debug_info.py
#    Test WT_CONNECTION::debug_info undocumented feature
class test_debug_info(wttest.WiredTigerTestCase):
    conn_config = 'create,log=(enabled),statistics=(fast)'
    uri = 'file:test_conndump'
    def conn_cursors(self):

        self.session.create(self.uri, 'key_format=i,value_format=i')

            

Reported by Pylint.

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

Line: 33 Column: 1

              
# test_debug_info.py
#    Test WT_CONNECTION::debug_info undocumented feature
class test_debug_info(wttest.WiredTigerTestCase):
    conn_config = 'create,log=(enabled),statistics=(fast)'
    uri = 'file:test_conndump'
    def conn_cursors(self):

        self.session.create(self.uri, 'key_format=i,value_format=i')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 36 Column: 5

              class test_debug_info(wttest.WiredTigerTestCase):
    conn_config = 'create,log=(enabled),statistics=(fast)'
    uri = 'file:test_conndump'
    def conn_cursors(self):

        self.session.create(self.uri, 'key_format=i,value_format=i')
        c = self.session.open_cursor(self.uri, None)
        keys = range(1, 101)
        for k in keys:

            

Reported by Pylint.

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

Line: 39 Column: 9

                  def conn_cursors(self):

        self.session.create(self.uri, 'key_format=i,value_format=i')
        c = self.session.open_cursor(self.uri, None)
        keys = range(1, 101)
        for k in keys:
            c[k] = 1
        c.close()
        c = self.session.open_cursor(self.uri, None)

            

Reported by Pylint.

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

Line: 44 Column: 9

                      for k in keys:
            c[k] = 1
        c.close()
        c = self.session.open_cursor(self.uri, None)
        val = c[50]
        self.conn.debug_info('cursors')
        c.close()

    def conn_cursors_special(self, special_uri):

            

Reported by Pylint.