Skip to content

Commit b50d88a

Browse files
committed
JS: Expose hasUnderlyingStringOrAnyType()
1 parent 38d017d commit b50d88a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

javascript/ql/lib/semmle/javascript/frameworks/Nest.qll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,7 @@ module NestJS {
337337
handler.isReturnValueReflected() and
338338
this = handler.getAReturn() and
339339
// Only returned strings are sinks. If we can find a type for the return value, it must be string-like.
340-
not exists(NameResolution::Node type |
341-
TypeResolution::valueHasType(this.asExpr(), type) and
342-
not TypeResolution::hasUnderlyingStringOrAnyType(type)
343-
)
340+
this.asExpr().getTypeBinding().hasUnderlyingStringOrAnyType()
344341
}
345342

346343
override Http::RouteHandler getRouteHandler() { result = handler }

javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ class TypeNameBindingNode extends NameResolution::Node {
119119
DataFlow::ClassNode getAnUnderlyingClass() {
120120
UnderlyingTypes::nodeHasUnderlyingClassType(this, result)
121121
}
122+
123+
/**
124+
* Holds if this type contains `string` or `any`, possibly wrapped in a promise.
125+
*/
126+
predicate hasUnderlyingStringOrAnyType() { TypeResolution::hasUnderlyingStringOrAnyType(this) }
122127
}
123128

124129
/**

0 commit comments

Comments
 (0)