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

Use prefix matching to detect system namespaces, not substring matching

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • 2.8.0-rc4
    • None
    • Internal Code
    • None
    • ALL

    Description

      There are places in the code where we do

      if ( strstr(ns, ".system.") )

      or

      if ( ns.find(".system.") != string::npos )

      to detect system namespaces. Such substring matching is incorrect, since it returns true for namespaces like "db.foo.system.bar", which are not usually considered system namespaces. Matching should be prefix-based, as is now done for writes, for example.

      This is along the same lines as SERVER-4558 and SERVER-8814, which refer to specific instances of this.

      The cases that seem to be present currently are:

      $ ag 'strstr *\(.* *"\.system\."'
      src/mongo/db/query/get_executor.cpp
      571:            if (strstr(ns, ".system.")) {
       
      $ ag '\.find *\( *"\.system\."'
      src/mongo/db/query/get_executor.cpp
      145:                          || (string::npos != ns.find(".system."))
       
      src/mongo/db/ops/insert.cpp
      188:        if ( coll.find( ".system." ) != string::npos ) {
       
      src/mongo/s/commands_admin.cpp
      526:                if ( ns.find( ".system." ) != string::npos ) {

      This ticket is to request that these occurrences in the code be updated to use prefix matches, not substring matches. Specifically:

      Probably somewhere there should be single isSystemNamespace()/isSystemCollection() function(s) for doing this detection consistently.

      Attachments

        Issue Links

          Activity

            People

              matt.kangas Matt Kangas
              kevin.pulo@mongodb.com Kevin Pulo
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: