Skip to content

Commit 9446cad

Browse files
committed
add ql/unmentioned-guard class
1 parent e07e6c9 commit 9446cad

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @name Unmentioned guard class
3+
* @description A sanitizer guard should be included in the `isSanitizerGuard` predicate.
4+
* @kind problem
5+
* @problem.severity warning
6+
* @id ql/unmentioned-guard
7+
* @tags correctness
8+
* maintainability
9+
* @precision medium
10+
*/
11+
12+
import ql
13+
14+
class SanGuard extends Class {
15+
SanGuard() {
16+
exists(Class sup |
17+
sup = this.getASuperType().getResolvedType().(ClassType).getDeclaration() and
18+
sup.getName() = ["SanitizerGuardNode", "SanitizerGuard", "BarrierGuardNode", "BarrierGuard"] and
19+
sup.getLocation().getFile() != this.getLocation().getFile()
20+
)
21+
}
22+
}
23+
24+
from SanGuard guard
25+
where
26+
not exists(TypeExpr t | t.getResolvedType().(ClassType).getDeclaration() = guard) and
27+
not guard.hasAnnotation("deprecated")
28+
select guard, "Guard class is not mentioned anywhere"

0 commit comments

Comments
 (0)