Skip to content

Commit

Permalink
Prevent lookup of function object properties
Browse files Browse the repository at this point in the history
A lambda function is represented internally as a javascript object.  A check needs to be added to the `lookup` function to only expose properties if they are a non-function object.  Similar to the check that already exists in the `keys` function.

Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
  • Loading branch information
andrew-coleman authored and mattbaileyuk committed May 9, 2024
1 parent b2a637e commit 4446161
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ const functions = (() => {
});
});
result = keys(merge);
} else if (arg !== null && typeof arg === 'object' && !(isLambda(arg))) {
} else if (arg !== null && typeof arg === 'object' && !isFunction(arg)) {
Object.keys(arg).forEach(key => result.push(key));
}
return result;
Expand All @@ -1685,7 +1685,7 @@ const functions = (() => {
}
}
}
} else if (input !== null && typeof input === 'object') {
} else if (input !== null && typeof input === 'object' && !isFunction(input)) {
result = input[key];
}
return result;
Expand Down
6 changes: 6 additions & 0 deletions test/test-suite/groups/lambdas/case013.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"expr": "( $f := function(){1}; $f.environment )",
"dataset": null,
"bindings": {},
"undefinedResult": true
}

0 comments on commit 4446161

Please sign in to comment.