Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2805679

Browse files
committed
add .getALocalSource() when testing for lodash-members
1 parent a7c1c34 commit 2805679

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

javascript/ql/src/Statements/UseOfReturnlessFunction.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ DataFlow::SourceNode array(DataFlow::TypeTracker t) {
113113

114114
DataFlow::SourceNode array() { result = array(DataFlow::TypeTracker::end()) }
115115

116-
predicate voidArrayCallback(DataFlow::MethodCallNode call, Function func) {
117-
hasNonVoidCallbackMethod(call.getMethodName()) and
116+
predicate voidArrayCallback(DataFlow::CallNode call, Function func) {
117+
hasNonVoidCallbackMethod(call.getCalleeName()) and
118118
func = call.getAnArgument().getALocalSource().asExpr() and
119119
1 = count(DataFlow::Node arg | arg = call.getAnArgument() and arg.getALocalSource().asExpr() instanceof Function) and
120120
returnsVoid(func) and
@@ -123,7 +123,7 @@ predicate voidArrayCallback(DataFlow::MethodCallNode call, Function func) {
123123
(
124124
call.getReceiver().getALocalSource() = array()
125125
or
126-
call.getCalleeNode() instanceof LodashUnderscore::Member
126+
call.getCalleeNode().getALocalSource() instanceof LodashUnderscore::Member
127127
)
128128
}
129129

javascript/ql/test/query-tests/Statements/UseOfReturnlessFunction/UseOfReturnlessFunction.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
| tst.js:53:10:53:34 | bothOnl ... fects() | the $@ does not return anything, yet the return value is used. | tst.js:11:5:13:5 | functio ... )\\n } | function bothOnlyHaveSideEffects |
55
| tst.js:53:10:53:34 | bothOnl ... fects() | the $@ does not return anything, yet the return value is used. | tst.js:48:2:50:5 | functio ... )\\n } | function bothOnlyHaveSideEffects |
66
| tst.js:76:12:76:46 | [1,2,3] ... n, 3)}) | the $@ does not return anything, yet the return value from the call to filter() is used. | tst.js:76:27:76:45 | n => {equals(n, 3)} | callback function |
7+
| tst.js:80:12:80:50 | filter( ... 3) } ) | the $@ does not return anything, yet the return value from the call to filter() is used. | tst.js:80:28:80:48 | x => { ... x, 3) } | callback function |

javascript/ql/test/query-tests/Statements/UseOfReturnlessFunction/tst.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,8 @@
7575

7676
var foo = [1,2,3].filter(n => {equals(n, 3)}) // NOT OK!
7777
console.log(foo);
78+
79+
import { filter } from 'lodash'
80+
var bar = filter([1,2,4], x => { equals(x, 3) } ) // NOT OK!
81+
console.log(bar);
7882
})();

0 commit comments

Comments
 (0)