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 {
318
318
}
319
319
}
320
320
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
-
329
321
/**
330
322
* A return value from a route handler, seen as an argument to `res.send()`.
331
323
*
@@ -344,10 +336,10 @@ module NestJS {
344
336
ReturnValueAsResponseSend ( ) {
345
337
handler .isReturnValueReflected ( ) and
346
338
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 )
351
343
)
352
344
}
353
345
Original file line number Diff line number Diff line change @@ -71,6 +71,9 @@ responseSendArgument
71
71
| local/customPipe.ts:37:16:37:31 | '' + unsanitized |
72
72
| local/customPipe.ts:42:16:42:31 | '' + unsanitized |
73
73
| 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' |
74
77
| local/routes.ts:32:31:32:31 | x |
75
78
| local/routes.ts:33:31:33:38 | queryObj |
76
79
| local/routes.ts:34:31:34:34 | name |
You can’t perform that action at this time.
0 commit comments