File tree Expand file tree Collapse file tree 1 file changed +4
-26
lines changed
javascript/ql/lib/semmle/javascript Expand file tree Collapse file tree 1 file changed +4
-26
lines changed Original file line number Diff line number Diff line change 3
3
*/
4
4
5
5
private import javascript
6
+ private import semmle.javascript.internal.TypeResolution
6
7
7
8
/**
8
9
* An input to a view component, such as React props.
@@ -14,34 +15,11 @@ abstract class ViewComponentInput extends DataFlow::Node {
14
15
15
16
private class ViewComponentInputAsThreatModelSource extends ThreatModelSource:: Range instanceof ViewComponentInput
16
17
{
17
- ViewComponentInputAsThreatModelSource ( ) { not isSafeType ( this .asExpr ( ) .getType ( ) ) }
18
+ ViewComponentInputAsThreatModelSource ( ) {
19
+ not TypeResolution:: valueHasSanitizingPrimitiveType ( this .asExpr ( ) )
20
+ }
18
21
19
22
final override string getThreatModel ( ) { result = "view-component-input" }
20
23
21
24
final override string getSourceType ( ) { result = ViewComponentInput .super .getSourceType ( ) }
22
25
}
23
-
24
- private predicate isSafeType ( Type t ) {
25
- t instanceof NumberLikeType
26
- or
27
- t instanceof BooleanLikeType
28
- or
29
- t instanceof UndefinedType
30
- or
31
- t instanceof NullType
32
- or
33
- t instanceof VoidType
34
- or
35
- hasSafeTypes ( t , t .( UnionType ) .getNumElementType ( ) )
36
- or
37
- isSafeType ( t .( IntersectionType ) .getAnElementType ( ) )
38
- }
39
-
40
- /** Hold if the first `n` components of `t` are safe types. */
41
- private predicate hasSafeTypes ( UnionType t , int n ) {
42
- isSafeType ( t .getElementType ( 0 ) ) and
43
- n = 1
44
- or
45
- isSafeType ( t .getElementType ( n - 1 ) ) and
46
- hasSafeTypes ( t , n - 1 )
47
- }
You can’t perform that action at this time.
0 commit comments