This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
generated from githubuniverseworkshops/template-workshop
-
Notifications
You must be signed in to change notification settings - Fork 5
/
CheckPoint1.ql
50 lines (42 loc) · 1.61 KB
/
CheckPoint1.ql
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
45
46
47
48
49
50
import java
// First find all the methods
// from Method m
// select m
// Find all the methods named getAverageRating
// from Method m
// where m.hasName("getAverageRating")
// select m
// Find all the methods named getAverageRating, accepts two parameters and where the first parameters is name fromSql
// from Method m
// where
// m.hasName("getAverageRating") and
// m.getNumberOfParameters() = 2 and
// m.getParameter(0).hasName("fromsql")
// select m, m.getFile().getAbsolutePath()
// Find all the methods named getAverageRatingFromQuery
// from Method m
// where m.hasName("getAverageRatingFromQuery")
// select m
// Find all the methods named getAverageRatingFromQuery with a definition
// from Method m
// where m.hasName("getAverageRatingFromQuery") and
// exists(m.getBody())
// select m
// Find all methods calls, named method accesses, named search
// from MethodAccess ma
// where ma.getMethod().hasName("search")
// select ma, ma.getMethod().getQualifiedName()
// Find the fully qualified name of declaring type of the method search that is called in `getAverageRatingFromQuery`
// from MethodAccess ma, Method m
// where
// ma.getMethod() = m and
// m.hasName("search") and
// ma.getEnclosingCallable().hasName("getAverageRatingFromQuery")
// select ma, m.getQualifiedName()
// Filter out the results with the qualified name of the method search
from MethodAccess ma, Method m
where
ma.getMethod() = m and
ma.getEnclosingCallable().hasName("getAverageRatingFromQuery") and
m.hasQualifiedName("com.xpn.xwiki.store", "XWikiStoreInterface", "search")
select ma, m.getQualifiedName()