The following issues were found

src/mongo/db/exec/sbe/stages/union.h
3 issues
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: 62 Column: 10 CWE codes: 362

              
    void prepare(CompileCtx& ctx) final;
    value::SlotAccessor* getAccessor(CompileCtx& ctx, value::SlotId slot) final;
    void open(bool reOpen) final;
    PlanState getNext() final;
    void close() final;

    std::unique_ptr<PlanStageStats> getStats(bool includeDebugInfo) const final;
    const SpecificStats* getSpecificStats() const final;

            

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: 76 Column: 14 CWE codes: 362

                      const bool reOpen{false};
        bool isOpen{false};

        void open() {
            if (!isOpen) {
                stage->open(reOpen);
                isOpen = true;
            }
        }

            

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: 78 Column: 24 CWE codes: 362

              
        void open() {
            if (!isOpen) {
                stage->open(reOpen);
                isOpen = true;
            }
        }

        void close() {

            

Reported by FlawFinder.

buildscripts/make_vcxproj.py
3 issues
Using xml.etree.ElementTree.parse to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree.parse with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
Security blacklist

Line: 98
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b313-b320-xml-bad-elementtree

                  if not os.path.exists(file_name):
        return None

    tree = ET.parse(file_name)

    interesting_tags = ['{%s}%s' % (VCXPROJ_NAMESPACE, tag) for tag in VCXPROJ_FIELDS_TO_PRESERVE]

    save_elements = {}


            

Reported by Bandit.

Using xml.etree.ElementTree.parse to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree.parse with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
Security blacklist

Line: 119
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b313-b320-xml-bad-elementtree

                  if not restore_elements:
        return

    tree = ET.parse(file_name)

    interesting_tags = ['{%s}%s' % (VCXPROJ_NAMESPACE, tag) for tag in VCXPROJ_FIELDS_TO_PRESERVE]

    for parent in tree.getroot():
        for child in parent:

            

Reported by Bandit.

Using xml.etree.ElementTree to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree with the equivalent defusedxml package, or make sure defusedxml.defuse_stdlib() is called.
Security blacklist

Line: 23
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b405-import-xml-etree

              import sys
import uuid
import argparse
import xml.etree.ElementTree as ET

VCXPROJ_FOOTER = r"""

  <ItemGroup>
    <None Include="src\mongo\db\mongo.ico" />

            

Reported by Bandit.

src/third_party/unwind/dist/src/coredump/_UCD_access_mem.c
3 issues
read - Check buffer boundaries if used in a loop including recursive loops
Security

Line: 72 Column: 12 CWE codes: 120 20

                    filename = phdr->backing_filename;
      fileofs = addr - phdr->p_vaddr;
      fd = phdr->backing_fd;
      goto read;
    }

  filename = ui->coredump_filename;
  fileofs = phdr->p_offset + (addr - phdr->p_vaddr);
  fd = ui->coredump_fd;

            

Reported by FlawFinder.

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

Line: 78 Column: 2 CWE codes: 120 20

                filename = ui->coredump_filename;
  fileofs = phdr->p_offset + (addr - phdr->p_vaddr);
  fd = ui->coredump_fd;
 read:
  if (lseek(fd, fileofs, SEEK_SET) != fileofs)
    goto read_error;
  if (read(fd, val, sizeof(*val)) != sizeof(*val))
    goto read_error;


            

Reported by FlawFinder.

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

Line: 81 Column: 7 CWE codes: 120 20

               read:
  if (lseek(fd, fileofs, SEEK_SET) != fileofs)
    goto read_error;
  if (read(fd, val, sizeof(*val)) != sizeof(*val))
    goto read_error;

  Debug(1, "0x%llx <- [addr:0x%llx fileofs:0x%llx]\n",
        (unsigned long long)(*val),
        (unsigned long long)addr,

            

Reported by FlawFinder.

src/mongo/db/exec/sbe/stages/union.cpp
3 issues
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: 100 Column: 18 CWE codes: 362

                  return ctx.getAccessor(slot);
}

void UnionStage::open(bool reOpen) {
    auto optTimer(getOptTimer(_opCtx));

    _commonStats.opens++;
    if (reOpen) {
        // If we are re-opening, it is important to close() any active branches. If kept open, one

            

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: 115 Column: 39 CWE codes: 362

                      _remainingBranchesToDrain.push({child.get(), reOpen});
    }

    _remainingBranchesToDrain.front().open();
    _currentStage = _remainingBranchesToDrain.front().stage;
    _currentStageIndex = 0;

    for (auto& outAccesor : _outValueAccessors) {
        outAccesor.setIndex(_currentStageIndex);

            

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: 132 Column: 20 CWE codes: 362

                  while (!_remainingBranchesToDrain.empty() && state != PlanState::ADVANCED) {
        if (!_currentStage) {
            auto& branch = _remainingBranchesToDrain.front();
            branch.open();
            _currentStage = branch.stage;
            ++_currentStageIndex;

            for (auto& outAccesor : _outValueAccessors) {
                outAccesor.setIndex(_currentStageIndex);

            

Reported by FlawFinder.

src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Tool/sunf95.py
3 issues
Attempted relative import beyond top-level package
Error

Line: 38 Column: 1

              
import SCons.Util

from .FortranCommon import add_all_to_env

compilers = ['sunf95', 'f95']

def generate(env):
    """Add Builders and construction variables for sunf95 to an

            

Reported by Pylint.

Line too long (117/100)
Error

Line: 34 Column: 1

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

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

import SCons.Util

from .FortranCommon import add_all_to_env


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 57 Column: 1

                  env['SHFORTRANFLAGS'] = SCons.Util.CLVar('$FORTRANFLAGS -KPIC')
    env['SHF95FLAGS'] = SCons.Util.CLVar('$F95FLAGS -KPIC')

def exists(env):
    return env.Detect(compilers)

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil

            

Reported by Pylint.

src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Tool/sunf90.py
3 issues
Attempted relative import beyond top-level package
Error

Line: 38 Column: 1

              
import SCons.Util

from .FortranCommon import add_all_to_env

compilers = ['sunf90', 'f90']

def generate(env):
    """Add Builders and construction variables for sun f90 compiler to an

            

Reported by Pylint.

Line too long (117/100)
Error

Line: 34 Column: 1

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

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

import SCons.Util

from .FortranCommon import add_all_to_env


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 57 Column: 1

                  env['SHFORTRANFLAGS'] = SCons.Util.CLVar('$FORTRANFLAGS -KPIC')
    env['SHF90FLAGS'] = SCons.Util.CLVar('$F90FLAGS -KPIC')

def exists(env):
    return env.Detect(compilers)

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil

            

Reported by Pylint.

src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Tool/suncc.py
3 issues
Attempted relative import beyond top-level package
Error

Line: 37 Column: 1

              
import SCons.Util

from . import cc

def generate(env):
    """
    Add Builders and construction variables for Forte C and C++ compilers
    to an Environment.

            

Reported by Pylint.

Line too long (116/100)
Error

Line: 33 Column: 1

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

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

import SCons.Util

from . import cc


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 51 Column: 1

                  env['SHOBJPREFIX']  = 'so_'
    env['SHOBJSUFFIX']  = '.o'

def exists(env):
    return env.Detect('CC')

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil

            

Reported by Pylint.

src/mongo/db/exec/sbe/stages/traverse.cpp
3 issues
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: 126 Column: 21 CWE codes: 362

                  }
}

void TraverseStage::open(bool reOpen) {
    auto optTimer(getOptTimer(_opCtx));

    _commonStats.opens++;
    _children[0]->open(reOpen);
    // Do not open the inner child as we do not have values of correlated parameters yet.

            

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

                  auto optTimer(getOptTimer(_opCtx));

    _commonStats.opens++;
    _children[0]->open(reOpen);
    // Do not open the inner child as we do not have values of correlated parameters yet.
    // The values are available only after we call getNext on the outer side.
}

void TraverseStage::openInner(value::TypeTags tag, value::Value val) {

            

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

                  _correlatedAccessor.reset(tag, val);

    // And (re)open the inner side as it can see the correlated value now.
    _children[1]->open(_reOpenInner);
    _reOpenInner = true;
}

PlanState TraverseStage::getNext() {
    auto optTimer(getOptTimer(_opCtx));

            

Reported by FlawFinder.

src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Tool/sunar.py
3 issues
Line too long (116/100)
Error

Line: 35 Column: 1

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

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

import SCons.Defaults
import SCons.Tool
import SCons.Util


            

Reported by Pylint.

Trailing whitespace
Error

Line: 44 Column: 1

              def generate(env):
    """Add Builders and construction variables for ar to an Environment."""
    SCons.Tool.createStaticLibBuilder(env)
    
    if env.Detect('CC'):
        env['AR']          = 'CC'
        env['ARFLAGS']     = SCons.Util.CLVar('-xar')
        env['ARCOM']       = '$AR $ARFLAGS -o $TARGET $SOURCES'
    else:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 57 Column: 1

                  env['LIBPREFIX']   = 'lib'
    env['LIBSUFFIX']   = '.a'

def exists(env):
    return env.Detect('CC') or env.Detect('ar')

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil

            

Reported by Pylint.

src/third_party/scons-3.1.2/scons-local-3.1.2/SCons/Tool/sunf77.py
3 issues
Attempted relative import beyond top-level package
Error

Line: 38 Column: 1

              
import SCons.Util

from .FortranCommon import add_all_to_env

compilers = ['sunf77', 'f77']

def generate(env):
    """Add Builders and construction variables for sunf77 to an Environment."""

            

Reported by Pylint.

Line too long (117/100)
Error

Line: 34 Column: 1

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

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

import SCons.Util

from .FortranCommon import add_all_to_env


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 56 Column: 1

                  env['SHFORTRANFLAGS'] = SCons.Util.CLVar('$FORTRANFLAGS -KPIC')
    env['SHF77FLAGS'] = SCons.Util.CLVar('$F77FLAGS -KPIC')

def exists(env):
    return env.Detect(compilers)

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil

            

Reported by Pylint.