55import javascript
66private import semmle.javascript.security.dataflow.ServerSideUrlRedirectCustomizations
77private import semmle.javascript.dataflow.internal.PreCallGraphStep
8- private import semmle.javascript.internal.NameResolution
9- private import semmle.javascript.internal.TypeResolution
108
119/**
1210 * Provides classes and predicates for reasoning about [Nest](https://nestjs.com/).
@@ -137,7 +135,7 @@ module NestJS {
137135 hasSanitizingPipe ( this , true ) and
138136 // Note: we could consider types with class-validator decorators to be sanitized here, but instead we consider the root
139137 // object to be tainted, but omit taint steps for the individual properties names that have sanitizing decorators. See ClassValidator.qll.
140- TypeResolution :: isSanitizingPrimitiveType ( this .getParameter ( ) .getTypeAnnotation ( ) )
138+ this .getParameter ( ) .getTypeBinding ( ) . isSanitizingPrimitiveType ( )
141139 }
142140 }
143141
@@ -337,7 +335,11 @@ module NestJS {
337335 handler .isReturnValueReflected ( ) and
338336 this = handler .getAReturn ( ) and
339337 // Only returned strings are sinks. If we can find a type for the return value, it must be string-like.
340- this .asExpr ( ) .getTypeBinding ( ) .hasUnderlyingStringOrAnyType ( )
338+ (
339+ this .asExpr ( ) .getTypeBinding ( ) .hasUnderlyingStringOrAnyType ( )
340+ or
341+ not exists ( this .asExpr ( ) .getTypeBinding ( ) )
342+ )
341343 }
342344
343345 override Http:: RouteHandler getRouteHandler ( ) { result = handler }
@@ -472,7 +474,7 @@ module NestJS {
472474
473475 /** Gets the class being referenced at `node` without relying on the call graph. */
474476 private DataFlow:: ClassNode getClassFromNode ( DataFlow:: Node node ) {
475- NameResolution :: trackClassValue ( result . getAstNode ( ) ) = node .asExpr ( )
477+ result = node .asExpr ( ) . getNameBinding ( ) . getClassNode ( )
476478 }
477479
478480 private predicate providerClassPair (
@@ -488,8 +490,7 @@ module NestJS {
488490 private class DependencyInjectionStep extends PreCallGraphStep {
489491 override predicate classInstanceSource ( DataFlow:: ClassNode cls , DataFlow:: Node node ) {
490492 exists ( DataFlow:: ClassNode interfaceClass |
491- TypeResolution:: valueHasType ( node .asExpr ( ) ,
492- TypeResolution:: trackType ( interfaceClass .getAstNode ( ) ) ) and
493+ node .asExpr ( ) .getTypeBinding ( ) .getTypeDefinition ( ) = interfaceClass .getAstNode ( ) and
493494 providerClassPair ( interfaceClass , cls )
494495 )
495496 }
0 commit comments