diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2013-07-29 16:27:09 -0400 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2013-08-09 17:48:46 -0400 |
commit | cd81198d0280abc8144bd7fa291a15564c1c0ae4 (patch) | |
tree | 83ddb514572d6183a05bc47f5ed4c2804372e135 /jstests/aggregation/bugs/server5782.js | |
parent | af6828e05aaea88e181cad598cc1274e2838d25a (diff) | |
download | mongo-cd81198d0280abc8144bd7fa291a15564c1c0ae4.tar.gz |
SERVER-5782 $literal operator to help prevent injection attacks
Diffstat (limited to 'jstests/aggregation/bugs/server5782.js')
-rw-r--r-- | jstests/aggregation/bugs/server5782.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/jstests/aggregation/bugs/server5782.js b/jstests/aggregation/bugs/server5782.js new file mode 100644 index 00000000000..d4ac2eeb6f1 --- /dev/null +++ b/jstests/aggregation/bugs/server5782.js @@ -0,0 +1,18 @@ +load('jstests/aggregation/extras/utils.js'); + +db.server5782.drop(); +db.server5782.save({string: "foo"}); + +// check that without $literal we end up comparing a field with itself and the result is true +var result = db.runCommand({aggregate: "server5782", + pipeline:[{$project: + {stringis$string: {$eq:["$string", '$string']}} + }]}); +assert.eq(result.result[0].stringis$string, true); + +// check that with $literal we end up comparing a field with '$string' and the result is true +var result = db.runCommand({aggregate: "server5782", + pipeline:[{$project: + {stringis$string: {$eq:["$string", {$literal:'$string'}]}} + }]}); +assert.eq(result.result[0].stringis$string, false); |