[SERVER-12642] distinct command should validate input Created: 06/Feb/14  Updated: 03/Jul/14  Resolved: 17/Jun/14

Status: Closed
Project: Core Server
Component/s: Internal Code, Querying, Shell
Affects Version/s: None
Fix Version/s: 2.7.3

Type: Improvement Priority: Minor - P4
Reporter: Scott Hernandez (Inactive) Assignee: Esha Maharishi (Inactive)
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change
Participants:

 Description   

Currently if you mistakenly send a non-string as the key field no error is generated. Both the command and shell helper should be checking this.

> db.dbref.find({"ref.$ref":"extra"})
{ "_id" : 1, "ref" : DBRef("extra", 2) }
> db.dbref.distinct({"ref.$ref":"extra"}) // should generate an error
[ ]

The command turns this into the key spec {"":1} because of "cmdObj["key"].valuestrsafe();" returning "" for non strings.

In both places we just need to make sure the arg is a string, or error.

Likewise the query option should also be validated since anything other than embedded doc will result in the value being ignored and replaced by the empty query/doc.



 Comments   
Comment by Githook User [ 17/Jun/14 ]

Author:

{u'username': u'EshaMaharishi', u'name': u'eshamaharishi', u'email': u'em2852@columbia.edu'}

Message: SERVER-12642 validates input to the distinct command

Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
Branch: master
https://github.com/mongodb/mongo/commit/3947048e1f5fc567022af15c050d1b80160b25ce

Comment by Githook User [ 17/Jun/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: Revert "SERVER-12642 validates input to the distinct command"
Branch: master
https://github.com/mongodb/mongo/commit/c53548186925995375052ceae68c609449ec987b

Comment by Githook User [ 17/Jun/14 ]

Author:

{u'username': u'EshaMaharishi', u'name': u'eshamaharishi', u'email': u'em2852@columbia.edu'}

Message: SERVER-12642 validates input to the distinct command

Signed-off-by: Benety Goh <benety@mongodb.com>
Branch: master
https://github.com/mongodb/mongo/commit/6032e7c6403e03d32d4b911e5bbe67c89088701f

Generated at Thu Feb 08 03:29:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.