-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathAndroidIdPrefix.ql
More file actions
32 lines (29 loc) · 1.1 KB
/
AndroidIdPrefix.ql
File metadata and controls
32 lines (29 loc) · 1.1 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
/**
* @name Android query without android @id prefix
* @description Android queries should include the `android/` prefix in their `@id`.
* @kind problem
* @problem.severity warning
* @id ql/android-id-prefix
* @precision high
*/
import ql
/** Holds if `t` transitively imports an Android module. */
predicate importsAndroidModule(TopLevel t) {
t.getFile() =
any(YAML::QLPack pack | pack.getADependency*().getExtractor() = "java").getAFileInPack() and
exists(Import i | t.getAnImport() = i |
i.getImportString().toLowerCase().matches("%android%")
or
exists(TopLevel t2 |
t2.getAModule() = i.getResolvedModule().asModule() and
importsAndroidModule(t2)
)
)
}
from QueryDoc d
where
d.getLocation().getFile().getRelativePath().matches("%src/Security/%") and
not d.getQueryId().matches("android/%") and
not d.getQueryId() = ["improper-intent-verification", "improper-webview-certificate-validation"] and // known badly identified queries that sadly we can't fix
importsAndroidModule(d.getParent())
select d, "This Android query is missing the `android/` prefix in its `@id`."