Skip to content

Commit

Permalink
JS: Use getUnderlyingValue() a few places in VariableCapture
Browse files Browse the repository at this point in the history
  • Loading branch information
asgerf committed Nov 19, 2024
1 parent d2daec4 commit 80a5a59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module VariableCaptureConfig implements InputSig<js::DbLocation> {
private js::Function getLambdaFromVariable(js::LocalVariable variable) {
result.getVariable() = variable
or
result = variable.getAnAssignedExpr()
result = variable.getAnAssignedExpr().getUnderlyingValue()
or
exists(js::ClassDeclStmt cls |
result = cls.getConstructor().getBody() and
Expand Down Expand Up @@ -148,9 +148,11 @@ module VariableCaptureConfig implements InputSig<js::DbLocation> {
predicate hasAliasedAccess(Expr e) {
e = this
or
e.(js::Expr).getUnderlyingValue() = this
or
exists(js::LocalVariable variable |
this = getLambdaFromVariable(variable) and
e = variable.getAnAccess()
e.(js::Expr).getUnderlyingValue() = variable.getAnAccess()
)
}
}
Expand Down
12 changes: 6 additions & 6 deletions javascript/ql/test/library-tests/TripleDot/iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function f2() {
})(x);
return y;
}
sink(inner(source("f2.1"))); // $ MISSING: hasValueFlow=f2.1
sink(inner(source("f2.2"))); // $ MISSING: hasValueFlow=f2.2
sink(inner(source("f2.1"))); // $ hasValueFlow=f2.1
sink(inner(source("f2.2"))); // $ hasValueFlow=f2.2
}

function f3() {
Expand Down Expand Up @@ -64,8 +64,8 @@ function f6() {
(nested)(x); // same as f5, except the callee is parenthesised here
return y;
}
sink(inner(source("f6.1"))); // $ MISSING: hasValueFlow=f6.1
sink(inner(source("f6.2"))); // $ MISSING: hasValueFlow=f6.2
sink(inner(source("f6.1"))); // $ hasValueFlow=f6.1
sink(inner(source("f6.2"))); // $ hasValueFlow=f6.2
}

function f7() {
Expand All @@ -77,6 +77,6 @@ function f7() {
nested(x); // same as f5, except the function definition is parenthesised
return y;
}
sink(inner(source("f7.1"))); // $ MISSING: hasValueFlow=f7.1
sink(inner(source("f7.2"))); // $ MISSING: hasValueFlow=f7.2
sink(inner(source("f7.1"))); // $ hasValueFlow=f7.1
sink(inner(source("f7.2"))); // $ hasValueFlow=f7.2
}

0 comments on commit 80a5a59

Please sign in to comment.