File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * @name Android query without android @id prefix
3
+ * @description Android queries should include the `android` prefix in their `@id`.
4
+ * @kind problem
5
+ * @problem.severity warning
6
+ * @id ql/android-id-prefix
7
+ * @precision high
8
+ */
9
+
10
+ import ql
11
+
12
+ string getIdProperty ( QLDoc doc ) {
13
+ result = any ( string id | id = doc .getContents ( ) .splitAt ( "@" ) and id .matches ( "id %" ) )
14
+ }
15
+
16
+ predicate importsAndroidModule ( TopLevel t ) {
17
+ exists ( Import i | t .getAnImport ( ) = i |
18
+ i .getImportString ( ) .toLowerCase ( ) .matches ( "%android%" )
19
+ or
20
+ exists ( TopLevel t2 |
21
+ t2 .getAModule ( ) = i .getResolvedModule ( ) .asModule ( ) and
22
+ importsAndroidModule ( t2 )
23
+ )
24
+ )
25
+ }
26
+
27
+ from TopLevel t
28
+ where
29
+ t .getLocation ( ) .getFile ( ) .getRelativePath ( ) .matches ( "%src/Security/%.ql" ) and
30
+ not getIdProperty ( t .getQLDoc ( ) ) .matches ( "% java/android/%" ) and
31
+ importsAndroidModule ( t )
32
+ select t , "This Android query is missing the `android` prefix in its `@id`."
You can’t perform that action at this time.
0 commit comments