The following issues were found

src/third_party/gperftools/dist/src/base/linux_syscall_support.h
9 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 209 Column: 3 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

                long long          d_off;
  unsigned short     d_reclen;
  unsigned char      d_type;
  char               d_name[256];
};

/* include/linux/dirent.h                                                    */
struct kernel_dirent {
  long               d_ino;

            

Reported by FlawFinder.

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

Line: 217 Column: 3 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

                long               d_ino;
  long               d_off;
  unsigned short     d_reclen;
  char               d_name[256];
};

/* include/linux/time.h                                                      */
struct kernel_timespec {
  long               tv_sec;

            

Reported by FlawFinder.

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

Line: 362 Column: 12 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

              #else
struct kernel_stat64 {
  unsigned long long st_dev;
  unsigned char      __pad0[4];
  unsigned           __st_ino;
  unsigned           st_mode;
  unsigned           st_nlink;
  unsigned           st_uid;
  unsigned           st_gid;

            

Reported by FlawFinder.

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

Line: 369 Column: 12 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

                unsigned           st_uid;
  unsigned           st_gid;
  unsigned long long st_rdev;
  unsigned char      __pad3[4];
  long long          st_size;
  unsigned           st_blksize;
  unsigned long long st_blocks;
  unsigned           st_atime_;
  unsigned           st_atime_nsec_;

            

Reported by FlawFinder.

open - 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: 2721 Column: 29 CWE codes: 362

                #endif
  #ifdef __NR_openat
    LSS_INLINE _syscall4(int, openat, int, d, const char *, p, int, f, int, m)
    LSS_INLINE int LSS_NAME(open)(const char* p, int f, int m) {
      return LSS_NAME(openat)(AT_FDCWD,p,f,m );
    }
  #else
  LSS_INLINE _syscall3(int,     open,            const char*, p,
                       int,            f, int,    m)

            

Reported by FlawFinder.

open - 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: 2725 Column: 33 CWE codes: 362

                    return LSS_NAME(openat)(AT_FDCWD,p,f,m );
    }
  #else
  LSS_INLINE _syscall3(int,     open,            const char*, p,
                       int,            f, int,    m)
  #endif
  LSS_INLINE int LSS_NAME(sigemptyset)(struct kernel_sigset_t *set) {
    memset(&set->sig, 0, sizeof(set->sig));
    return 0;

            

Reported by FlawFinder.

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

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

                      rc = LSS_NAME(_sigaction)(signum, ptr_a, ptr_oa);
        if (rc == 0 && oldact) {
          if (act) {
            memcpy(oldact, act, sizeof(*act));
          } else {
            memset(oldact, 0, sizeof(*oldact));
          }
          oldact->sa_handler_    = ptr_oa->sa_handler_;
          oldact->sa_flags       = ptr_oa->sa_flags;

            

Reported by FlawFinder.

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

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

                        }
          oldact->sa_handler_    = ptr_oa->sa_handler_;
          oldact->sa_flags       = ptr_oa->sa_flags;
          memcpy(&oldact->sa_mask, &ptr_oa->sa_mask, sizeof(ptr_oa->sa_mask));
          #ifndef __mips__
          oldact->sa_restorer    = ptr_oa->sa_restorer;
          #endif
        }
      }

            

Reported by FlawFinder.

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

Line: 2633 Column: 33 CWE codes: 120 20

                                     long,           a)
  LSS_INLINE _syscall4(long,    ptrace,          int,         r,
                       pid_t,          p, void *, a, void *, d)
  LSS_INLINE _syscall3(ssize_t, read,            int,         f,
                       void *,         b, size_t, c)
  LSS_INLINE _syscall4(int,     rt_sigaction,    int,         s,
                       const struct kernel_sigaction*, a,
                       struct kernel_sigaction*, o, size_t,   c)
  LSS_INLINE _syscall4(int, rt_sigprocmask,      int,         h,

            

Reported by FlawFinder.

src/mongo/db/ftdc/file_manager.cpp
9 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

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

              
    if (boost::filesystem::exists(path)) {
        for (; _fileNameUniquifier < FTDCConfig::kMaxFileUniqifier; ++_fileNameUniquifier) {
            char buf[20];

            // Use leading zeros so the numbers sort lexigraphically
            int ret = snprintf(&buf[0], sizeof(buf), "%05u", _fileNameUniquifier);
            invariant(ret > 0 && ret < static_cast<int>((sizeof(buf) - 1)));


            

Reported by FlawFinder.

open - 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: 174 Column: 26 CWE codes: 362

                  Client* client,
    const boost::filesystem::path& path,
    const std::vector<std::tuple<FTDCBSONUtil::FTDCType, BSONObj, Date_t>>& docs) {
    auto sOpen = _writer.open(path);
    if (!sOpen.isOK()) {
        return sOpen;
    }

    // Append any old interim records

            

Reported by FlawFinder.

open - 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: 274 Column: 19 CWE codes: 362

                  }

    FTDCFileReader read;
    auto s = read.open(interimFile);
    if (!s.isOK()) {
        LOGV2(20630,
              "Unclean full-time diagnostic data capture shutdown detected, found interim file,  "
              "but failed to open it, some metrics may have been lost",
              "error"_attr = s);

            

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: 122 Column: 28 CWE codes: 126

                      auto filename = de.path().filename();

        std::string str = filename.generic_string();
        if (str.compare(0, strlen(kFTDCArchiveFile), kFTDCArchiveFile) == 0 &&
            str != kFTDCInterimTempFile && str != kFTDCInterimFile) {
            files.emplace_back(_path / filename);
        }
    }


            

Reported by FlawFinder.

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

Line: 273 Column: 20 CWE codes: 120 20

                      return docs;
    }

    FTDCFileReader read;
    auto s = read.open(interimFile);
    if (!s.isOK()) {
        LOGV2(20630,
              "Unclean full-time diagnostic data capture shutdown detected, found interim file,  "
              "but failed to open it, some metrics may have been lost",

            

Reported by FlawFinder.

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

Line: 274 Column: 14 CWE codes: 120 20

                  }

    FTDCFileReader read;
    auto s = read.open(interimFile);
    if (!s.isOK()) {
        LOGV2(20630,
              "Unclean full-time diagnostic data capture shutdown detected, found interim file,  "
              "but failed to open it, some metrics may have been lost",
              "error"_attr = s);

            

Reported by FlawFinder.

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

Line: 285 Column: 26 CWE codes: 120 20

                      return docs;
    }

    StatusWith<bool> m = read.hasNext();
    for (; m.isOK() && m.getValue(); m = read.hasNext()) {
        auto triplet = read.next();
        docs.emplace_back(std::tuple<FTDCBSONUtil::FTDCType, BSONObj, Date_t>(
            std::get<0>(triplet), std::get<1>(triplet).getOwned(), std::get<2>(triplet)));
    }

            

Reported by FlawFinder.

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

Line: 286 Column: 42 CWE codes: 120 20

                  }

    StatusWith<bool> m = read.hasNext();
    for (; m.isOK() && m.getValue(); m = read.hasNext()) {
        auto triplet = read.next();
        docs.emplace_back(std::tuple<FTDCBSONUtil::FTDCType, BSONObj, Date_t>(
            std::get<0>(triplet), std::get<1>(triplet).getOwned(), std::get<2>(triplet)));
    }


            

Reported by FlawFinder.

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

Line: 287 Column: 24 CWE codes: 120 20

              
    StatusWith<bool> m = read.hasNext();
    for (; m.isOK() && m.getValue(); m = read.hasNext()) {
        auto triplet = read.next();
        docs.emplace_back(std::tuple<FTDCBSONUtil::FTDCType, BSONObj, Date_t>(
            std::get<0>(triplet), std::get<1>(triplet).getOwned(), std::get<2>(triplet)));
    }

    // Warn if the interim file was corrupt or we had an unclean shutdown

            

Reported by FlawFinder.

src/third_party/wiredtiger/test/suite/test_hs15.py
9 issues
Unable to import 'wiredtiger'
Error

Line: 34 Column: 1

              # [END_TAGS]
#

import time, wiredtiger, wttest
from wtscenario import make_scenarios

# test_hs15.py
# Ensure eviction doesn't clear the history store again after checkpoint has done so because of the same update without timestamp.
class test_hs15(wttest.WiredTigerTestCase):

            

Reported by Pylint.

Unused import time
Error

Line: 34 Column: 1

              # [END_TAGS]
#

import time, wiredtiger, wttest
from wtscenario import make_scenarios

# test_hs15.py
# Ensure eviction doesn't clear the history store again after checkpoint has done so because of the same update without timestamp.
class test_hs15(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 (time, wiredtiger, wttest)
Error

Line: 34 Column: 1

              # [END_TAGS]
#

import time, wiredtiger, wttest
from wtscenario import make_scenarios

# test_hs15.py
# Ensure eviction doesn't clear the history store again after checkpoint has done so because of the same update without timestamp.
class test_hs15(wttest.WiredTigerTestCase):

            

Reported by Pylint.

Line too long (130/100)
Error

Line: 38 Column: 1

              from wtscenario import make_scenarios

# test_hs15.py
# Ensure eviction doesn't clear the history store again after checkpoint has done so because of the same update without timestamp.
class test_hs15(wttest.WiredTigerTestCase):
    conn_config = 'cache_size=5MB'
    session_config = 'isolation=snapshot'
    key_format_values = [
        ('column', dict(key_format='r')),

            

Reported by Pylint.

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

Line: 39 Column: 1

              
# test_hs15.py
# Ensure eviction doesn't clear the history store again after checkpoint has done so because of the same update without timestamp.
class test_hs15(wttest.WiredTigerTestCase):
    conn_config = 'cache_size=5MB'
    session_config = 'isolation=snapshot'
    key_format_values = [
        ('column', dict(key_format='r')),
        ('string-row', dict(key_format='S'))

            

Reported by Pylint.

Missing class docstring
Error

Line: 39 Column: 1

              
# test_hs15.py
# Ensure eviction doesn't clear the history store again after checkpoint has done so because of the same update without timestamp.
class test_hs15(wttest.WiredTigerTestCase):
    conn_config = 'cache_size=5MB'
    session_config = 'isolation=snapshot'
    key_format_values = [
        ('column', dict(key_format='r')),
        ('string-row', dict(key_format='S'))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 48 Column: 5

                  ]
    scenarios = make_scenarios(key_format_values)

    def create_key(self, i):
        if self.key_format == 'S':
            return str(i)
        return i

    def test_hs15(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 53 Column: 5

                          return str(i)
        return i

    def test_hs15(self):
        uri = 'table:test_hs15'
        self.session.create(uri, 'key_format={},value_format=S'.format(self.key_format))
        cursor = self.session.open_cursor(uri)

        value1 = 'a' * 500

            

Reported by Pylint.

src/third_party/wiredtiger/test/suite/test_checkpoint06.py
9 issues
Unable to import 'wiredtiger'
Error

Line: 30 Column: 1

              # OTHER DEALINGS IN THE SOFTWARE.

import time
import wiredtiger, wttest

# test_checkpoint06.py
# Verify that we rollback the truncation that is committed after stable
# timestamp in the checkpoint.
class test_checkpoint06(wttest.WiredTigerTestCase):

            

Reported by Pylint.

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

# test_checkpoint06.py
# Verify that we rollback the truncation that is committed after stable
# timestamp in the checkpoint.

            

Reported by Pylint.

Unused import wiredtiger
Error

Line: 30 Column: 1

              # OTHER DEALINGS IN THE SOFTWARE.

import time
import wiredtiger, wttest

# test_checkpoint06.py
# Verify that we rollback the truncation that is committed after stable
# timestamp in the checkpoint.
class test_checkpoint06(wttest.WiredTigerTestCase):

            

Reported by Pylint.

Attribute 'uri' defined outside __init__
Error

Line: 40 Column: 9

                  session_config = 'isolation=snapshot'

    def test_rollback_truncation_in_checkpoint(self):
        self.uri = 'table:ckpt06'
        self.session.create(self.uri, 'key_format=i,value_format=S')

        value = "abcdefghijklmnopqrstuvwxyz" * 3
        self.conn.set_timestamp('oldest_timestamp=' + self.timestamp_str(1))
        cursor = self.session.open_cursor(self.uri)

            

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: 30 Column: 1

              # OTHER DEALINGS IN THE SOFTWARE.

import time
import wiredtiger, wttest

# test_checkpoint06.py
# Verify that we rollback the truncation that is committed after stable
# timestamp in the checkpoint.
class test_checkpoint06(wttest.WiredTigerTestCase):

            

Reported by Pylint.

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

Line: 35 Column: 1

              # test_checkpoint06.py
# Verify that we rollback the truncation that is committed after stable
# timestamp in the checkpoint.
class test_checkpoint06(wttest.WiredTigerTestCase):
    conn_config = 'create,cache_size=50MB'
    session_config = 'isolation=snapshot'

    def test_rollback_truncation_in_checkpoint(self):
        self.uri = 'table:ckpt06'

            

Reported by Pylint.

Missing class docstring
Error

Line: 35 Column: 1

              # test_checkpoint06.py
# Verify that we rollback the truncation that is committed after stable
# timestamp in the checkpoint.
class test_checkpoint06(wttest.WiredTigerTestCase):
    conn_config = 'create,cache_size=50MB'
    session_config = 'isolation=snapshot'

    def test_rollback_truncation_in_checkpoint(self):
        self.uri = 'table:ckpt06'

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 5

                  conn_config = 'create,cache_size=50MB'
    session_config = 'isolation=snapshot'

    def test_rollback_truncation_in_checkpoint(self):
        self.uri = 'table:ckpt06'
        self.session.create(self.uri, 'key_format=i,value_format=S')

        value = "abcdefghijklmnopqrstuvwxyz" * 3
        self.conn.set_timestamp('oldest_timestamp=' + self.timestamp_str(1))

            

Reported by Pylint.

site_scons/mongo/pip_requirements.py
9 issues
Unable to import 'requirements'
Error

Line: 39 Column: 9

              
    # Import the prequisites for this function, providing hints on failure.
    try:
        import requirements
    except ModuleNotFoundError as ex:
        raiseSuggestion(ex, "requirements_parser")

    try:
        import pkg_resources

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 12 Column: 5

              
class MissingRequirements(Exception):
    """Raised when when verify_requirements() detects missing requirements."""
    pass


def verify_requirements(requirements_file: str, silent: bool = False):
    """Check if the modules in a pip requirements file are installed.
    This allows for a more friendly user message with guidance on how to

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # -*- mode: python; -*-

# Try to keep this modules imports minimum and only
# import python standard modules, because this module
# should be used for finding such external modules or
# missing dependencies.
import sys



            

Reported by Pylint.

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

Line: 30 Column: 5

                      if not silent:
            print(*args, **kwargs)

    def raiseSuggestion(ex, pip_pkg):
        raise MissingRequirements(
            f"{ex}\n"
            f"Try running:\n"
            f"    {sys.executable} -m pip install {pip_pkg}"
        ) from ex

            

Reported by Pylint.

Import outside toplevel (requirements)
Error

Line: 39 Column: 9

              
    # Import the prequisites for this function, providing hints on failure.
    try:
        import requirements
    except ModuleNotFoundError as ex:
        raiseSuggestion(ex, "requirements_parser")

    try:
        import pkg_resources

            

Reported by Pylint.

Import outside toplevel (pkg_resources)
Error

Line: 44 Column: 9

                      raiseSuggestion(ex, "requirements_parser")

    try:
        import pkg_resources
    except ModuleNotFoundError as ex:
        raiseSuggestion(ex, "setuptools")

    verbose("Checking required python packages...")


            

Reported by Pylint.

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

Line: 51 Column: 37

                  verbose("Checking required python packages...")

    # Reduce a pip requirements file to its PEP 508 requirement specifiers.
    with open(requirements_file) as fd:
        pip_lines = [p.line for p in requirements.parse(fd)]

    # The PEP 508 requirement specifiers can be parsed by the `pkg_resources`.
    pkg_requirements = list(pkg_resources.parse_requirements(pip_lines))


            

Reported by Pylint.

Consider using a set comprehension
Error

Line: 58 Column: 23

                  pkg_requirements = list(pkg_resources.parse_requirements(pip_lines))

    verbose("Requirements list:")
    for req in sorted(set([str(req) for req in pkg_requirements])):
        verbose(f"    {req}")

    # Resolve all the requirements at once.
    # This should help expose dependency hell among the requirements.
    try:

            

Reported by Pylint.

Consider using a set comprehension
Error

Line: 72 Column: 24

              

    verbose("Resolved to these distributions:")
    for dist in sorted(set([f"    {dist.key} {dist.version}" for dist in dists])):
        verbose(dist)

            

Reported by Pylint.

src/mongo/db/exec/sbe/vm/vm.cpp
9 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

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

                  static_assert(!IsEndian<T>::value);

    T val;
    memcpy(&val, ptr, sizeof(T));
    return val;
}

template <typename T>
size_t writeToMemory(uint8_t* ptr, const T val) noexcept {

            

Reported by FlawFinder.

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

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

              size_t writeToMemory(uint8_t* ptr, const T val) noexcept {
    static_assert(!IsEndian<T>::value);

    memcpy(ptr, &val, sizeof(T));
    return sizeof(T);
}
}  // namespace

void CodeFragment::adjustStackSimple(const Instruction& i) {

            

Reported by FlawFinder.

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

Line: 524 Column: 43 CWE codes: 120 20

                      return {false, tag, val};
    } else if (objTag == value::TypeTags::bsonObject) {
        auto be = value::bitcastTo<const char*>(objValue);
        auto end = be + ConstDataView(be).read<LittleEndian<uint32_t>>();
        // Skip document length.
        be += 4;
        while (*be != 0) {
            auto sv = bson::fieldNameView(be);


            

Reported by FlawFinder.

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

Line: 774 Column: 51 CWE codes: 120 20

              
            if (objTag == value::TypeTags::bsonObject) {
                auto be = value::bitcastTo<const char*>(objVal);
                auto end = be + ConstDataView(be).read<LittleEndian<uint32_t>>();

                // Skip document length.
                be += 4;
                while (*be != 0) {
                    auto sv = bson::fieldNameView(be);

            

Reported by FlawFinder.

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

Line: 815 Column: 47 CWE codes: 120 20

              
        if (objTag == value::TypeTags::bsonObject) {
            auto be = value::bitcastTo<const char*>(objVal);
            auto end = be + ConstDataView(be).read<LittleEndian<uint32_t>>();

            // Skip document length.
            be += 4;
            while (*be != 0) {
                auto sv = bson::fieldNameView(be);

            

Reported by FlawFinder.

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

Line: 1125 Column: 43 CWE codes: 120 20

              
    if (tagInObj == value::TypeTags::bsonObject) {
        auto be = value::bitcastTo<const char*>(valInObj);
        auto end = be + ConstDataView(be).read<LittleEndian<uint32_t>>();
        // Skip document length.
        be += 4;
        while (*be != 0) {
            auto sv = bson::fieldNameView(be);


            

Reported by FlawFinder.

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

Line: 1201 Column: 43 CWE codes: 120 20

              
    if (tagInObj == value::TypeTags::bsonObject) {
        auto be = value::bitcastTo<const char*>(valInObj);
        auto end = be + ConstDataView(be).read<LittleEndian<uint32_t>>();
        // Skip document length.
        be += 4;
        while (*be != 0) {
            auto sv = bson::fieldNameView(be);


            

Reported by FlawFinder.

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

Line: 2097 Column: 46 CWE codes: 120 20

                      return {false, value::TypeTags::NumberInt32, value::bitcastFrom<int32_t>(sz)};
    } else if (tagOperand == value::TypeTags::bsonObject) {
        auto beginObj = value::getRawPointerView(valOperand);
        int32_t sz = ConstDataView(beginObj).read<LittleEndian<int32_t>>();
        return {false, value::TypeTags::NumberInt32, value::bitcastFrom<int32_t>(sz)};
    }
    return {false, value::TypeTags::Nothing, 0};
}


            

Reported by FlawFinder.

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

Line: 2977 Column: 41 CWE codes: 120 20

                  BSONObj outputView = output.done();
    auto ptr = outputView.objdata();
    auto be = ptr + 4;
    auto end = ptr + ConstDataView(ptr).read<LittleEndian<uint32_t>>();
    return bson::convertFrom<false>(be, end, 0);
}

}  // namespace


            

Reported by FlawFinder.

src/third_party/wiredtiger/test/3rdparty/testtools-0.9.34/testtools/tests/matchers/test_doctest.py
9 issues
Undefined variable 'unicode'
Error

Line: 77 Column: 25

                      matcher = DocTestMatches(header, doctest.ELLIPSIS)
        mismatch = matcher.match(_b("GIF89a\1\0\1\0\0\0\0;"))
        # Must be treatable as unicode text, the exact output matters less
        self.assertTrue(unicode(mismatch.describe()))


def test_suite():
    from unittest import TestLoader
    return TestLoader().loadTestsFromName(__name__)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Copyright (c) 2008-2012 testtools developers. See LICENSE for details.

import doctest

from testtools import TestCase
from testtools.compat import (
    str_is_unicode,
    _b,
    _u,

            

Reported by Pylint.

Missing class docstring
Error

Line: 17 Column: 1

              


class TestDocTestMatchesInterface(TestCase, TestMatchersInterface):

    matches_matcher = DocTestMatches("Ran 1 test in ...s", doctest.ELLIPSIS)
    matches_matches = ["Ran 1 test in 0.000s", "Ran 1 test in 1.234s"]
    matches_mismatches = ["Ran 1 tests in 0.000s", "Ran 2 test in 0.000s"]


            

Reported by Pylint.

Missing class docstring
Error

Line: 33 Column: 1

                      DocTestMatches("Ran 1 tests in ...s", doctest.ELLIPSIS))]


class TestDocTestMatchesInterfaceUnicode(TestCase, TestMatchersInterface):

    matches_matcher = DocTestMatches(_u("\xa7..."), doctest.ELLIPSIS)
    matches_matches = [_u("\xa7"), _u("\xa7 more\n")]
    matches_mismatches = ["\\xa7", _u("more \xa7"), _u("\n\xa7")]


            

Reported by Pylint.

Missing class docstring
Error

Line: 49 Column: 1

                      DocTestMatches(_u("\xa7"), doctest.ELLIPSIS))]


class TestDocTestMatchesSpecific(TestCase):

    run_tests_with = FullStackRunTest

    def test___init__simple(self):
        matcher = DocTestMatches("foo")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 53 Column: 5

              
    run_tests_with = FullStackRunTest

    def test___init__simple(self):
        matcher = DocTestMatches("foo")
        self.assertEqual("foo\n", matcher.want)

    def test___init__flags(self):
        matcher = DocTestMatches("bar\n", doctest.ELLIPSIS)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 57 Column: 5

                      matcher = DocTestMatches("foo")
        self.assertEqual("foo\n", matcher.want)

    def test___init__flags(self):
        matcher = DocTestMatches("bar\n", doctest.ELLIPSIS)
        self.assertEqual("bar\n", matcher.want)
        self.assertEqual(doctest.ELLIPSIS, matcher.flags)

    def test_describe_non_ascii_bytes(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 80 Column: 1

                      self.assertTrue(unicode(mismatch.describe()))


def test_suite():
    from unittest import TestLoader
    return TestLoader().loadTestsFromName(__name__)

            

Reported by Pylint.

Import outside toplevel (unittest.TestLoader)
Error

Line: 81 Column: 5

              

def test_suite():
    from unittest import TestLoader
    return TestLoader().loadTestsFromName(__name__)

            

Reported by Pylint.

src/third_party/boost/boost/range/iterator_range_core.hpp
9 issues
equal - Function does not check the second iterator for over-read conditions
Security

Line: 110 Column: 21 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                      // This version is maintained since it is used in other boost libraries
        // such as Boost.Assign
        template< class Left, class Right >
        inline bool equal(const Left& l, const Right& r)
        {
            return boost::equal(l, r);
        }

struct range_tag

            

Reported by FlawFinder.

equal - Function does not check the second iterator for over-read conditions
Security

Line: 112 Column: 27 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                      template< class Left, class Right >
        inline bool equal(const Left& l, const Right& r)
        {
            return boost::equal(l, r);
        }

struct range_tag
{
};

            

Reported by FlawFinder.

equal - Function does not check the second iterator for over-read conditions
Security

Line: 248 Column: 10 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                      return empty();
    }

    bool equal(const iterator_range_base& r) const
    {
        return m_Begin == r.m_Begin && m_End == r.m_End;
    }

   reference front() const

            

Reported by FlawFinder.

equal - Function does not check the second iterator for over-read conditions
Security

Line: 587 Column: 27 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                      >::type
        operator==( const ForwardRange& l, const iterator_range<IteratorT>& r )
        {
            return boost::equal( l, r );
        }

        template< class IteratorT, class ForwardRange >
        inline BOOST_DEDUCED_TYPENAME boost::enable_if<
            mpl::not_<boost::is_base_and_derived<iterator_range_detail::iterator_range_tag, ForwardRange> >,

            

Reported by FlawFinder.

equal - Function does not check the second iterator for over-read conditions
Security

Line: 597 Column: 28 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                      >::type
        operator!=( const ForwardRange& l, const iterator_range<IteratorT>& r )
        {
            return !boost::equal( l, r );
        }

        template< class IteratorT, class ForwardRange >
        inline BOOST_DEDUCED_TYPENAME boost::enable_if<
            mpl::not_<boost::is_base_and_derived<iterator_range_detail::iterator_range_tag, ForwardRange> >,

            

Reported by FlawFinder.

equal - Function does not check the second iterator for over-read conditions
Security

Line: 644 Column: 27 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                      inline bool
        operator==( const iterator_range<Iterator1T>& l, const iterator_range<Iterator2T>& r )
        {
            return boost::equal( l, r );
        }

        template< class IteratorT, class ForwardRange >
        inline BOOST_DEDUCED_TYPENAME boost::enable_if<
            mpl::not_<boost::is_base_and_derived<iterator_range_detail::iterator_range_tag, ForwardRange> >,

            

Reported by FlawFinder.

equal - Function does not check the second iterator for over-read conditions
Security

Line: 654 Column: 27 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                      >::type
        operator==( const iterator_range<IteratorT>& l, const ForwardRange& r )
        {
            return boost::equal( l, r );
        }


        template< class Iterator1T, class Iterator2T >
        inline bool

            

Reported by FlawFinder.

equal - Function does not check the second iterator for over-read conditions
Security

Line: 662 Column: 28 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                      inline bool
        operator!=( const iterator_range<Iterator1T>& l, const iterator_range<Iterator2T>& r )
        {
            return !boost::equal( l, r );
        }

        template< class IteratorT, class ForwardRange >
        inline BOOST_DEDUCED_TYPENAME boost::enable_if<
            mpl::not_<boost::is_base_and_derived<iterator_range_detail::iterator_range_tag, ForwardRange> >,

            

Reported by FlawFinder.

equal - Function does not check the second iterator for over-read conditions
Security

Line: 672 Column: 28 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                      >::type
        operator!=( const iterator_range<IteratorT>& l, const ForwardRange& r )
        {
            return !boost::equal( l, r );
        }


        template< class Iterator1T, class Iterator2T >
        inline bool

            

Reported by FlawFinder.

src/third_party/boost/boost/range/algorithm/mismatch.hpp
9 issues
mismatch - Function does not check the second iterator for over-read conditions
Security

Line: 75 Column: 1 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

              inline std::pair<
    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
mismatch(SinglePassRange1& rng1, const SinglePassRange2 & rng2)
{
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));

    return ::boost::range_detail::mismatch_impl(

            

Reported by FlawFinder.

mismatch - Function does not check the second iterator for over-read conditions
Security

Line: 90 Column: 1 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

              inline std::pair<
    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2)
{
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));

    return ::boost::range_detail::mismatch_impl(

            

Reported by FlawFinder.

mismatch - Function does not check the second iterator for over-read conditions
Security

Line: 105 Column: 1 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

              inline std::pair<
    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
mismatch(SinglePassRange1& rng1, SinglePassRange2 & rng2)
{
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));

    return ::boost::range_detail::mismatch_impl(

            

Reported by FlawFinder.

mismatch - Function does not check the second iterator for over-read conditions
Security

Line: 120 Column: 1 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

              inline std::pair<
    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2)
{
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));

    return ::boost::range_detail::mismatch_impl(

            

Reported by FlawFinder.

mismatch - Function does not check the second iterator for over-read conditions
Security

Line: 136 Column: 1 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

              inline std::pair<
    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred)
{
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));

    return ::boost::range_detail::mismatch_impl(

            

Reported by FlawFinder.

mismatch - Function does not check the second iterator for over-read conditions
Security

Line: 151 Column: 1 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

              inline std::pair<
    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred)
{
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));

    return ::boost::range_detail::mismatch_impl(

            

Reported by FlawFinder.

mismatch - Function does not check the second iterator for over-read conditions
Security

Line: 166 Column: 1 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

              inline std::pair<
    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred)
{
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));

    return ::boost::range_detail::mismatch_impl(

            

Reported by FlawFinder.

mismatch - Function does not check the second iterator for over-read conditions
Security

Line: 181 Column: 1 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

              inline std::pair<
    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred)
{
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));

    return ::boost::range_detail::mismatch_impl(

            

Reported by FlawFinder.

mismatch - Function does not check the second iterator for over-read conditions
Security

Line: 192 Column: 18 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

              }

    } // namespace range
    using range::mismatch;
} // namespace boost

#endif // include guard

            

Reported by FlawFinder.

jstests/ssl/tls_enumerator.py
9 issues
Catching too general exception Exception
Error

Line: 31 Column: 24

                          with context.wrap_socket(sock, server_hostname=host) as conn:
                try:
                    conn.connect((host, port))
                except Exception as e:
                    continue
                accepted_ciphers.append(cipher_name)

    return sorted(accepted_ciphers)


            

Reported by Pylint.

Unused variable 'e'
Error

Line: 31 Column: 17

                          with context.wrap_socket(sock, server_hostname=host) as conn:
                try:
                    conn.connect((host, port))
                except Exception as e:
                    continue
                accepted_ciphers.append(cipher_name)

    return sorted(accepted_ciphers)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import ssl
import socket
import json
import argparse

exception_ciphers = {}

def enumerate_tls_ciphers(protocol_options, host, port, cert, cafile):
    root_context = ssl.SSLContext(ssl.PROTOCOL_TLS)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              
exception_ciphers = {}

def enumerate_tls_ciphers(protocol_options, host, port, cert, cafile):
    root_context = ssl.SSLContext(ssl.PROTOCOL_TLS)
    root_context.options |= protocol_options
    root_context.set_ciphers('ALL:COMPLEMENTOFALL:-PSK:-SRP')

    ciphers = {cipher['name'] for cipher in root_context.get_ciphers()}

            

Reported by Pylint.

Try, Except, Continue detected.
Security

Line: 31
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b112_try_except_continue.html

                          with context.wrap_socket(sock, server_hostname=host) as conn:
                try:
                    conn.connect((host, port))
                except Exception as e:
                    continue
                accepted_ciphers.append(cipher_name)

    return sorted(accepted_ciphers)


            

Reported by Bandit.

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

Line: 31 Column: 17

                          with context.wrap_socket(sock, server_hostname=host) as conn:
                try:
                    conn.connect((host, port))
                except Exception as e:
                    continue
                accepted_ciphers.append(cipher_name)

    return sorted(accepted_ciphers)


            

Reported by Pylint.

Line too long (120/100)
Error

Line: 48 Column: 1

                  parser.add_argument('--cert', type=str, help='Path to client certificate')
    args = parser.parse_args()

    # MacOS version of the toolchain does not have python linked with OpenSSL 1.1.1 yet, so we monkey patch this in here
    if not hasattr(ssl, 'OP_NO_TLSv1_3'):
        ssl.OP_NO_TLSv1_3 = 0

    exclude_ops = {
        ssl.OP_NO_SSLv2,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 61 Column: 5

                      ssl.OP_NO_TLSv1_3,
    }

    def exclude_except(op):
        option = 0
        for other_op in exclude_ops - {op}:
            option |= other_op
        return option


            

Reported by Pylint.

Argument name "op" doesn't conform to snake_case naming style
Error

Line: 61 Column: 5

                      ssl.OP_NO_TLSv1_3,
    }

    def exclude_except(op):
        option = 0
        for other_op in exclude_ops - {op}:
            option |= other_op
        return option


            

Reported by Pylint.