mongos --help lists --noscripting as a valid parameter despite not being functional on a mongos. Tested with $where
--help output:
root@ip-10-0-8-21:/data/testCluster0_mongos_18# mongos --help | grep scr --noscripting disable scripting engine
running with --noscripting:
root@ip-10-0-8-21:/data/testCluster0_mongos_18# ps aux | grep -i mongos mongodb 5390 0.1 0.1 335616 24336 ? Sl 15:30 0:00 /var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.4.10-ent/bin/mongos --noscripting -f /var/lib/mongodb-mms-automation/workspace/mongos-testCluster0_mongos_18.conf
test with $where:
MongoDB Enterprise mongos> db.foo.find() { "_id" : 12378, "name" : "Steve", "username" : "steveisawesome", "first_login" : "2017-01-01" } { "_id" : 2, "name" : "Anya", "username" : "anya", "first_login" : "2001-02-02" } MongoDB Enterprise mongos> db.foo.find( { $where: function() { return (hex_md5(this.name) == "9b53e667f30cd329dca1ec9e6a83e994") } } ); { "_id" : 2, "name" : "Anya", "username" : "anya", "first_login" : "2001-02-02" }
If security.javascriptEnabled is in the configuration file for the mongos, the following error blocks startup.
Unrecognized option: security.javascriptEnabled
When security.javascriptEnabled is set on a shard, the option functions as expected.
MongoDB Enterprise mongos> db.foo.find( { $where: function() { return (hex_md5(this.name) == "9b53e667f30cd329dca1ec9e6a83e994") } } ); Error: error: { "ok" : 0, "errmsg" : "no globalScriptEngine in $where parsing", "code" : 2, "codeName" : "BadValue" }
Tested against 3.4.10 and 3.6.2. I will file a docs ticket if this option should not be allowed on a mongos.