<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:23:49 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-10695] Redact pipeline: Subobject without security markings causes aggregate to fail</title>
                <link>https://jira.mongodb.org/browse/SERVER-10695</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;If a subobject, whether or not it is in an array does not contain the field that we are checking for in a $redact using the $any operator, the aggregate command returns an error.&lt;/p&gt;

&lt;p&gt;To see the problem, uncomment lines from the &quot;Steps To Reproduce sections&quot;&lt;/p&gt;


&lt;p&gt;Error: Printing Stack Trace&lt;br/&gt;
    at printStackTrace (src/mongo/shell/utils.js:37:15)&lt;br/&gt;
    at DBCollection.aggregate (src/mongo/shell/collection.js:927:9)&lt;br/&gt;
    at (shell):1:3&lt;br/&gt;
2013-09-06T11:49:43.683-0400 aggregate failed: {&lt;br/&gt;
	&quot;errmsg&quot; : &quot;exception: $any&apos;s argument must be an array, but is NULL&quot;,&lt;br/&gt;
	&quot;code&quot; : 17041,&lt;br/&gt;
	&quot;ok&quot; : 0&lt;br/&gt;
} at src/mongo/shell/collection.js:928&lt;/p&gt;


&lt;p&gt;This is contrary to the behavior implied in the jstests where there are subobjects without the &quot;level&quot; key  (see the f: in the subobject).  Probably because that $redact doesn&apos;t use $any in its condition&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/blob/master/jstests/aggregation/bugs/server8581.js&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/master/jstests/aggregation/bugs/server8581.js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d: [ &lt;/p&gt;
{level: 1, e: 4}
&lt;p&gt;,&lt;br/&gt;
                   &lt;/p&gt;
{f: 6}
&lt;p&gt;,&lt;br/&gt;
                   &lt;/p&gt;
{level: 5, g: 9}
&lt;p&gt;,&lt;br/&gt;
                   &quot;NOT AN OBJECT!!11!&quot; // always included when b is included&lt;br/&gt;
                 ]&lt;/p&gt;


</description>
                <environment>Mac OS X, MongoDB 2.5.2</environment>
        <key id="88798">SERVER-10695</key>
            <summary>Redact pipeline: Subobject without security markings causes aggregate to fail</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="matt.dannenberg">Matt Dannenberg</assignee>
                                    <reporter username="david.erickson">David Erickson</reporter>
                        <labels>
                    </labels>
                <created>Fri, 6 Sep 2013 15:56:17 +0000</created>
                <updated>Wed, 10 Dec 2014 23:11:39 +0000</updated>
                            <resolved>Fri, 13 Sep 2013 18:03:39 +0000</resolved>
                                    <version>2.5.2</version>
                                                    <component>Aggregation Framework</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="424629" author="david.erickson" created="Fri, 13 Sep 2013 17:59:24 +0000"  >&lt;p&gt;This does indeed work in the situation where not all subobjects in the data model have markings.  Thanks!&lt;/p&gt;</comment>
                            <comment id="423763" author="mattd@10gen.com" created="Thu, 12 Sep 2013 19:14:48 +0000"  >&lt;p&gt;I was able to get the command to work as expected by changing your aggregation command to handle the null and replace it with an empty array (using $ifNull), does this fix work for you as well?&lt;/p&gt;

&lt;p&gt;t.aggregate([&lt;br/&gt;
{$redact:{ $cond: [&lt;br/&gt;
{$any:[&lt;br/&gt;
{&lt;br/&gt;
$map: {&lt;br/&gt;
input: {$ifNull:[&quot;$sl&quot;,[[]]]},&lt;br/&gt;
as: &quot;setNeeded&quot;,&lt;br/&gt;
in: &lt;/p&gt;
{ $setIsSubset: [ &quot;$$setNeeded&quot;, [&quot;GroupA&quot;, &quot;GroupB&quot;]] }
&lt;p&gt;}&lt;br/&gt;
}&lt;br/&gt;
]},&lt;br/&gt;
&quot;$$CONTINUE&quot;,&lt;br/&gt;
&quot;$$PRUNE&quot;&lt;br/&gt;
]}}&lt;br/&gt;
]);&lt;/p&gt;

&lt;p&gt;I had to have $ifNull return an empty array containing an empty array instead of just an empty array. This is because $map expects an array and each entry of dollar map gets passed to $setIsSubset, which also expects an empty array.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 12 Sep 2013 19:14:48 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        10 years, 22 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            10 years, 22 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10021"><![CDATA[OS X]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>david.erickson</customfieldvalue>
            <customfieldvalue>matt.dannenberg</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrmhm7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrsq0n:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>81451</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;t = db.redact_tests;&lt;br/&gt;
t.drop();&lt;/p&gt;

&lt;p&gt;t.save({&lt;br/&gt;
	_id: 1,&lt;br/&gt;
	sl: [&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;GroupA&amp;quot;&amp;#93;&lt;/span&gt;, &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;GroupA&amp;quot;, &amp;quot;GroupB&amp;quot;&amp;#93;&lt;/span&gt;],&lt;/p&gt;

&lt;p&gt;	text: &quot;A or B Can see this&quot;,&lt;/p&gt;

&lt;p&gt;	subObjectWithSL: &lt;/p&gt;
{
		sl: [[&quot;GroupB&quot;]],
		text: &quot;Only B can see this&quot;
	}
&lt;p&gt;,&lt;/p&gt;

&lt;p&gt;	anotherSubObjectWithSL: &lt;/p&gt;
{
		sl: [[&quot;GroupA&quot;]],
		text: &quot;All users with doc access can see this&quot;
	}
&lt;p&gt;,&lt;/p&gt;

&lt;p&gt;/*	subObjectWithoutSL: &lt;/p&gt;
{
		text: &quot;This blows up the redactor when uncommented&quot;
	}
&lt;p&gt;*/&lt;/p&gt;

&lt;p&gt;	arrayWithUnMarkedSubObjects: [&lt;br/&gt;
		&lt;/p&gt;
{sl:[[&quot;GroupA&quot;]], text: &quot;I can see this&quot;}
&lt;p&gt;,&lt;br/&gt;
//		&lt;/p&gt;
{text: &quot;This blows up the redactor when uncommented&quot;}
&lt;p&gt;,&lt;br/&gt;
		&quot;Not an object&quot;&lt;br/&gt;
	]&lt;br/&gt;
});&lt;/p&gt;

&lt;p&gt;t.aggregate([&lt;br/&gt;
	{$redact:{ $cond: [&lt;br/&gt;
		{$any:[&lt;br/&gt;
			{&lt;br/&gt;
				$map: {&lt;br/&gt;
					input: &quot;$sl&quot;,&lt;br/&gt;
					as: &quot;setNeeded&quot;,&lt;br/&gt;
					in: &lt;/p&gt;
{ $setIsSubset: [&quot;$$setNeeded&quot;, [&quot;GroupA&quot;, &quot;GroupB&quot;]] }
&lt;p&gt;				}&lt;br/&gt;
			}&lt;br/&gt;
		]},&lt;br/&gt;
		&quot;$$CONTINUE&quot;,&lt;br/&gt;
		&quot;$$PRUNE&quot;&lt;br/&gt;
	]}}&lt;br/&gt;
]);&lt;/p&gt;</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrj4hz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>