Skip to content

Commit 19de7cd

Browse files
authored
Merge pull request github#13507 from atorralba/atorralba/ql/android-ids-check
QL: Add query to find Android queries with improper ids
2 parents 2341c82 + 3c60f52 commit 19de7cd

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
/** Holds if `t` transitively imports an Android module. */
13+
predicate importsAndroidModule(TopLevel t) {
14+
t.getFile() =
15+
any(YAML::QLPack pack | pack.getADependency*().getExtractor() = "java").getAFileInPack() and
16+
exists(Import i | t.getAnImport() = i |
17+
i.getImportString().toLowerCase().matches("%android%")
18+
or
19+
exists(TopLevel t2 |
20+
t2.getAModule() = i.getResolvedModule().asModule() and
21+
importsAndroidModule(t2)
22+
)
23+
)
24+
}
25+
26+
from QueryDoc d
27+
where
28+
d.getLocation().getFile().getRelativePath().matches("%src/Security/%") and
29+
not d.getQueryId().matches("android/%") and
30+
not d.getQueryId() = ["improper-intent-verification", "improper-webview-certificate-validation"] and // known badly identified queries that sadly we can't fix
31+
importsAndroidModule(d.getParent())
32+
select d, "This Android query is missing the `android/` prefix in its `@id`."

0 commit comments

Comments
 (0)