[SERVER-10693] Redact pipeline not including non-object array members Created: 06/Sep/13  Updated: 11/Jul/16  Resolved: 06/Sep/13

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 2.5.2
Fix Version/s: 2.5.3

Type: Bug Priority: Major - P3
Reporter: David Erickson Assignee: Matt Dannenberg
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change
Operating System: ALL
Steps To Reproduce:

t = db.jstests_aggregation_redact;
t.drop();
t.save(
{
_id: 1,
level: 2,
subobj: {
level: 3,
text: "level 3 secret",
subarray: [

{ text: "I'm an object with no level" }

,

{ level: 1, text: "I'm an object with acceptable level"}

,

{ level: 100, text: "I'm an object with unacceptable level"}

,
"I'm not an object",
10
],
subobj:

{ level:1, text: "level 3 secret due to inheritance" }

},
secretLevel2: 9,
text: "level 2 secret"
}
);
t.aggregate({$redact: {$cond: [{$lte: ['$level', 3]}, "$$CONTINUE", "$$PRUNE"]}});

Participants:

 Description   

jstest example indicate that non-object members of arrays undergoing redaction should be included in field-level filtered results.
https://github.com/mongodb/mongo/blob/master/jstests/aggregation/bugs/server8581.js

Asserts in this test don't test for the inclusion of the:
"NOT AN OBJECT!!11!" // always included when b is included
line in the results of a level 3 redaction



 Comments   
Comment by auto [ 06/Sep/13 ]

Author:

{u'username': u'dannenberg', u'name': u'matt dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: SERVER-10693 added extra test case to ensure nest arrays function properly
Branch: master
https://github.com/mongodb/mongo/commit/1d12521aef13942080808d6e1ea36f961f8c964b

Comment by auto [ 06/Sep/13 ]

Author:

{u'username': u'dannenberg', u'name': u'matt dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: SERVER-10693 include non-object array members if an array is included in $redact
Branch: master
https://github.com/mongodb/mongo/commit/68a5d567d6c56a07a7875effaf2ac1dd37ad2b5d

Comment by David Erickson [ 06/Sep/13 ]

This is also affecting the results of subset based conditions

//the following

db.files.drop();
db.files.save(
{
_id: 1,
a:

{ data: "something secret", sl: [ [ "GroupB" ], [ "GroupD", "GroupA" ] ] }

,
comments: [

{ sl: [["GroupB"]], data: "Don't tell members of GroupA who are missing GroupB." }

,

{ sl: [["GroupA"]], data: "What's in this document?" }

],
common_field: "Anyone can see this if they can see this document at all.",
sl: [["GroupA"], ["GroupB"]]
}
);
db.files.aggregate([
{$redact:{$cond: [
{$any:[
{
$map: {
input: "$sl",
as: "setNeeded",
in:

{ $setIsSubset: ["$$setNeeded", ["GroupA", "GroupC"]] }

}
}
]},
"$$CONTINUE",
"$$PRUNE"
]}}
]);

//returns:

{
"result" : [
{
"_id" : 1,
"comments" : [

{ "sl" : [ [ ] ], "data" : "What's in this document?" }

],
"common_field" : "Anyone can see this if they can see this document at all.",
"sl" : [
[ ],
[ ]
]
}
],
"ok" : 1
}

//notice how it is stripping the values from the "sl" arrays in the result

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