File tree Expand file tree Collapse file tree 2 files changed +7
-12
lines changed
lib/semmle/javascript/frameworks
test/library-tests/frameworks/Nest Expand file tree Collapse file tree 2 files changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -318,14 +318,6 @@ module NestJS {
318318 }
319319 }
320320
321- private predicate isStringType ( Type type ) {
322- type instanceof StringType
323- or
324- type instanceof AnyType
325- or
326- isStringType ( type .( PromiseType ) .getElementType ( ) .unfold ( ) )
327- }
328-
329321 /**
330322 * A return value from a route handler, seen as an argument to `res.send()`.
331323 *
@@ -344,10 +336,10 @@ module NestJS {
344336 ReturnValueAsResponseSend ( ) {
345337 handler .isReturnValueReflected ( ) and
346338 this = handler .getAReturn ( ) and
347- // Only returned strings are sinks
348- not exists ( Type type |
349- type = this .asExpr ( ) . getType ( ) and
350- not isStringType ( type . unfold ( ) )
339+ // 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 )
351343 )
352344 }
353345
Original file line number Diff line number Diff line change @@ -71,6 +71,9 @@ responseSendArgument
7171| local/customPipe.ts:37:16:37:31 | '' + unsanitized |
7272| local/customPipe.ts:42:16:42:31 | '' + unsanitized |
7373| local/customPipe.ts:48:16:48:31 | '' + unsanitized |
74+ | local/routes.ts:7:12:7:16 | 'foo' |
75+ | local/routes.ts:12:12:12:16 | 'foo' |
76+ | local/routes.ts:17:12:17:16 | 'foo' |
7477| local/routes.ts:32:31:32:31 | x |
7578| local/routes.ts:33:31:33:38 | queryObj |
7679| local/routes.ts:34:31:34:34 | name |
You can’t perform that action at this time.
0 commit comments