File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,6 @@ async function runFindTriggers(
34
34
options = { }
35
35
) {
36
36
const { isGet } = options ;
37
-
38
37
// Run beforeFind trigger - may modify query or return objects directly
39
38
const result = await triggers . maybeRunQueryTrigger (
40
39
triggers . Types . beforeFind ,
@@ -59,11 +58,18 @@ async function runFindTriggers(
59
58
60
59
// Security check: Re-filter objects if not master to ensure ACL/CLP compliance
61
60
if ( ! auth ?. isMaster && ! auth ?. isMaintenance ) {
62
- const ids = ( Array . isArray ( objectsFromBeforeFind ) ? objectsFromBeforeFind : [ objectsFromBeforeFind ] )
61
+ const inputArray = Array . isArray ( objectsFromBeforeFind )
62
+ ? objectsFromBeforeFind
63
+ : [ objectsFromBeforeFind ] ;
64
+
65
+ const ids = inputArray
63
66
. map ( o => ( o && ( o . id || o . objectId ) ) || null )
64
67
. filter ( Boolean ) ;
65
68
66
- if ( ids . length > 0 ) {
69
+ // If no valid ids are present, do not return unsanitized data
70
+ if ( ids . length === 0 ) {
71
+ objectsForAfterFind = [ ] ;
72
+ } else {
67
73
const refilterWhere = isGet ? { objectId : ids [ 0 ] } : { objectId : { $in : ids } } ;
68
74
69
75
// Re-query with proper security: no triggers to avoid infinite loops
You can’t perform that action at this time.
0 commit comments