@@ -125,39 +125,24 @@ class TokenValidationParametersProperty extends Property {
125
125
predicate callableHasAReturnStmtAndAlwaysReturnsTrue ( Callable c ) {
126
126
c .getReturnType ( ) instanceof BoolType and
127
127
not callableMayThrowException ( c ) and
128
- forall ( ReturnStmt rs | rs .getEnclosingCallable ( ) = c |
128
+ forex ( ReturnStmt rs | rs .getEnclosingCallable ( ) = c |
129
129
rs .getNumberOfChildren ( ) = 1 and
130
130
isExpressionAlwaysTrue ( rs .getChildExpr ( 0 ) )
131
- ) and
132
- exists ( ReturnStmt rs | rs .getEnclosingCallable ( ) = c )
131
+ )
133
132
}
134
133
135
134
/**
136
135
* Holds if the lambda expression `le` always returns true
137
136
*/
138
137
predicate lambdaExprReturnsOnlyLiteralTrue ( AnonymousFunctionExpr le ) {
139
- le .getExpressionBody ( ) .( BoolLiteral ) .getBoolValue ( ) = true
140
- or
141
- // special scenarios where the expression is not a `BoolLiteral`, but it will evaluatue to `true`
142
- exists ( Expr e | le .getExpressionBody ( ) = e |
143
- not e instanceof Call and
144
- not e instanceof Literal and
145
- e .getType ( ) instanceof BoolType and
146
- e .getValue ( ) = "true"
147
- )
138
+ isExpressionAlwaysTrue ( le .getExpressionBody ( ) )
148
139
}
149
140
150
141
class CallableAlwaysReturnsTrue extends Callable {
151
142
CallableAlwaysReturnsTrue ( ) {
152
143
callableHasAReturnStmtAndAlwaysReturnsTrue ( this )
153
144
or
154
145
lambdaExprReturnsOnlyLiteralTrue ( this )
155
- or
156
- exists ( AnonymousFunctionExpr le , Call call , Callable callable | this = le |
157
- callable .getACall ( ) = call and
158
- call = le .getExpressionBody ( ) and
159
- callableHasAReturnStmtAndAlwaysReturnsTrue ( callable )
160
- )
161
146
}
162
147
}
163
148
@@ -171,32 +156,6 @@ predicate callableOnlyThrowsArgumentNullException(Callable c) {
171
156
)
172
157
}
173
158
174
- /**
175
- * A specialization of `CallableAlwaysReturnsTrue` that takes into consideration exceptions being thrown for higher precision.
176
- */
177
- class CallableAlwaysReturnsTrueHigherPrecision extends CallableAlwaysReturnsTrue {
178
- CallableAlwaysReturnsTrueHigherPrecision ( ) {
179
- callableOnlyThrowsArgumentNullException ( this ) and
180
- (
181
- forall ( Call call , Callable callable | call .getEnclosingCallable ( ) = this |
182
- callable .getACall ( ) = call and
183
- callable instanceof CallableAlwaysReturnsTrueHigherPrecision
184
- )
185
- or
186
- exists ( AnonymousFunctionExpr le , Call call , CallableAlwaysReturnsTrueHigherPrecision cat |
187
- this = le
188
- |
189
- le .canReturn ( call ) and
190
- cat .getACall ( ) = call
191
- )
192
- or
193
- exists ( LambdaExpr le | le = this |
194
- le .getBody ( ) instanceof CallableAlwaysReturnsTrueHigherPrecision
195
- )
196
- )
197
- }
198
- }
199
-
200
159
/**
201
160
* A callable that returns a `string` and has a `string` as 1st argument
202
161
*/
0 commit comments