Skip to content

Commit 6fdd7fe

Browse files
committed
JS: Use sanitizing primitive type in Nest model
1 parent 2d21074 commit 6fdd7fe

File tree

1 file changed

+5
-14
lines changed
  • javascript/ql/lib/semmle/javascript/frameworks

1 file changed

+5
-14
lines changed

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import javascript
66
private import semmle.javascript.security.dataflow.ServerSideUrlRedirectCustomizations
77
private import semmle.javascript.dataflow.internal.PreCallGraphStep
8+
private import semmle.javascript.internal.NameResolution
9+
private import semmle.javascript.internal.TypeResolution
810

911
/**
1012
* Provides classes and predicates for reasoning about [Nest](https://nestjs.com/).
@@ -133,7 +135,9 @@ module NestJS {
133135
hasSanitizingPipe(this, false)
134136
or
135137
hasSanitizingPipe(this, true) and
136-
isSanitizingType(this.getParameter().getType().unfold())
138+
// Note: we could consider types with class-validator decorators to be sanitized here, but instead we consider the root
139+
// 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())
137141
}
138142
}
139143

@@ -209,19 +213,6 @@ module NestJS {
209213
dependsOnType = true
210214
}
211215

212-
/**
213-
* Holds if a parameter of type `t` is considered sanitized, provided it has been checked by `ValidationPipe`
214-
* (which relies on metadata emitted by the TypeScript compiler).
215-
*/
216-
private predicate isSanitizingType(Type t) {
217-
t instanceof NumberType
218-
or
219-
t instanceof BooleanType
220-
//
221-
// Note: we could consider types with class-validator decorators to be sanitized here, but instead we consider the root
222-
// object to be tainted, but omit taint steps for the individual properties names that have sanitizing decorators. See ClassValidator.qll.
223-
}
224-
225216
/**
226217
* A user-defined pipe class, for example:
227218
* ```js

0 commit comments

Comments
 (0)