-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathPathProblemQueryQuery.qll
More file actions
44 lines (38 loc) · 1.19 KB
/
PathProblemQueryQuery.qll
File metadata and controls
44 lines (38 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import ql
private import codeql_ql.ast.internal.Module
FileOrModule hasQueryRelation(ClasslessPredicate pred) {
pred.hasAnnotation("query") and
(
result.asModule().getAMember() = pred
or
any(TopLevel top | top.getLocation().getFile() = result.asFile()).getAMember() = pred
)
}
FileOrModule importsQueryRelation(ClasslessPredicate pred) {
result = hasQueryRelation(pred)
or
exists(Import i |
not (i.hasAnnotation("private") and i.getLocation().getFile().getExtension() = "qll") and
importsQueryRelation(pred) = i.getResolvedModule()
|
i = result.asModule().getAMember()
or
i = any(TopLevel top | top.getLocation().getFile() = result.asFile()).getAMember()
)
}
class Query extends File {
Query() { this.getExtension() = "ql" }
predicate isPathProblem() {
exists(QLDoc doc | doc.getLocation().getFile() = this |
doc.getContents().matches("%@kind path-problem%")
)
}
predicate isProblem() {
exists(QLDoc doc | doc.getLocation().getFile() = this |
doc.getContents().matches("%@kind problem%")
)
}
predicate hasEdgesRelation(ClasslessPredicate pred) {
importsQueryRelation(pred).asFile() = this and pred.getName() = "edges"
}
}