Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-90279

jstests/core/hostinfo.js doesn't correctly check for empty values

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0, 8.0.0-rc6
    • Affects Version/s: None
    • Component/s: None
    • None
    • Service Arch
    • Fully Compatible
    • ALL
    • v8.0
    • Programmability 2024-05-27

      The jstests/core/hostinfo.js test attempts to verify that various host info values are not omitted from the output of the hostInfo command. These checks follow a similar pattern:

      assert.neq(hostinfo.system.numLogicalCores, "" || null || 0, "Missing Number of Logical Cores");
      

      The intent of this line, for example, is to ensure that the number of logical cores reported isn't an empty string, or nonexistent, or zero. However, JavaScript evaluates the entirety of the expression "" || null || 0 first and then passes the result into the assert.neq function, so the effect of this line is to only verify that the value isn't zero. That is, it ends up accepting the empty string or null.

      Change these lines to properly check against all disallowed values, for example, by passing in lambda expressions to do the validation, or breaking up the checks into separate assert.neq calls.

            Assignee:
            james.bronsted@mongodb.com James Bronsted
            Reporter:
            james.bronsted@mongodb.com James Bronsted
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: