Simplify the query for subtype check

This commit is contained in:
luchua-bc
2020-06-30 11:15:18 +00:00
parent 382e5a5a7a
commit d978f28822

View File

@@ -23,11 +23,7 @@ private predicate catchesEx(TryStmt t, RefType exType) {
exists(CatchClause cc, LocalVariableDeclExpr v |
t.getACatchClause() = cc and
cc.getVariable() = v and
v
.getType()
.(RefType)
.getASubtype*()
.hasQualifiedName(exType.getPackage().getName(), exType.getName()) //Detect the case that a subclass exception is thrown but its parent class is declared in the catch clause.
v.getType().(RefType).getASubtype*() = exType //Detect the case that a subclass exception is thrown but its parent class is declared in the catch clause.
)
}
@@ -48,8 +44,8 @@ private predicate isServletMethod(Callable c) {
class UncaughtServletExceptionSink extends DataFlow::ExprNode {
UncaughtServletExceptionSink() {
exists(Method m, MethodAccess ma | ma.getMethod() = m |
isServletMethod(ma.getEnclosingCallable()) and
(
isServletMethod(ma.getEnclosingCallable()) and
(
m.getAThrownExceptionType().getASupertype*() instanceof IOException or
m
.getAThrownExceptionType()