@@ -125,39 +125,24 @@ class TokenValidationParametersProperty extends Property {
125125predicate callableHasAReturnStmtAndAlwaysReturnsTrue ( Callable c ) {
126126 c .getReturnType ( ) instanceof BoolType and
127127 not callableMayThrowException ( c ) and
128- forall ( ReturnStmt rs | rs .getEnclosingCallable ( ) = c |
128+ forex ( ReturnStmt rs | rs .getEnclosingCallable ( ) = c |
129129 rs .getNumberOfChildren ( ) = 1 and
130130 isExpressionAlwaysTrue ( rs .getChildExpr ( 0 ) )
131- ) and
132- exists ( ReturnStmt rs | rs .getEnclosingCallable ( ) = c )
131+ )
133132}
134133
135134/**
136135 * Holds if the lambda expression `le` always returns true
137136 */
138137predicate 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 ( ) )
148139}
149140
150141class CallableAlwaysReturnsTrue extends Callable {
151142 CallableAlwaysReturnsTrue ( ) {
152143 callableHasAReturnStmtAndAlwaysReturnsTrue ( this )
153144 or
154145 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- )
161146 }
162147}
163148
@@ -171,32 +156,6 @@ predicate callableOnlyThrowsArgumentNullException(Callable c) {
171156 )
172157}
173158
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-
200159/**
201160 * A callable that returns a `string` and has a `string` as 1st argument
202161 */
0 commit comments