File tree Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -6,21 +6,16 @@ import java
6
6
private import semmle.code.xml.AndroidManifest
7
7
8
8
/**
9
- * There is an android manifest file which defines an activity, service or
10
- * content provider (so it corresponds to an android application rather than a
11
- * library), and `file` is in a subfolder of the folder that contains it .
9
+ * Holds if in `file`'s directory or some parent directory there is an `AndroidManifestXmlFile`
10
+ * that defines at least one activity, service or contest provider, suggesting this file is
11
+ * part of an android application .
12
12
*/
13
13
predicate inAndroidApplication ( File file ) {
14
14
file .isSourceFile ( ) and
15
- exists ( AndroidComponentXmlElement acxe , AndroidManifestXmlFile amxf |
16
- amxf .getManifestElement ( ) .getApplicationElement ( ) .getAComponentElement ( ) = acxe and
17
- (
18
- acxe instanceof AndroidActivityXmlElement or
19
- acxe instanceof AndroidServiceXmlElement or
20
- acxe instanceof AndroidProviderXmlElement
21
- )
15
+ exists ( AndroidManifestXmlFile amxf , Folder amxfDir |
16
+ amxf .definesAndroidApplication ( ) and amxfDir = amxf .getParentContainer ( )
22
17
|
23
- file .getParentContainer + ( ) = amxf . getParentContainer ( )
18
+ file .getParentContainer + ( ) = amxfDir
24
19
)
25
20
}
26
21
Original file line number Diff line number Diff line change @@ -23,6 +23,21 @@ class AndroidManifestXmlFile extends XmlFile {
23
23
* Holds if this Android manifest file is located in a build directory.
24
24
*/
25
25
predicate isInBuildDirectory ( ) { this .getFile ( ) .getRelativePath ( ) .matches ( "%build%" ) }
26
+
27
+ /**
28
+ * Holds if `amxf` defines at least one activity, service or contest provider,
29
+ * and so it corresponds to an android application rather than a library.
30
+ */
31
+ predicate definesAndroidApplication ( ) {
32
+ exists ( AndroidComponentXmlElement acxe |
33
+ this .getManifestElement ( ) .getApplicationElement ( ) .getAComponentElement ( ) = acxe and
34
+ (
35
+ acxe instanceof AndroidActivityXmlElement or
36
+ acxe instanceof AndroidServiceXmlElement or
37
+ acxe instanceof AndroidProviderXmlElement
38
+ )
39
+ )
40
+ }
26
41
}
27
42
28
43
/**
You can’t perform that action at this time.
0 commit comments