Skip to content

Commit 0934c1d

Browse files
Jami CogswellJami Cogswell
authored andcommitted
resolved merge conflict in AndroidManifest lib
1 parent 9968d5d commit 0934c1d

File tree

4 files changed

+34
-29
lines changed

4 files changed

+34
-29
lines changed

java/ql/lib/semmle/code/java/security/ImplicitlyExportedAndroidComponent.qll

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,26 @@ private import semmle.code.xml.AndroidManifest
44

55
/** Represents an implicitly exported Android component */
66
class ImplicitlyExportedAndroidComponent extends AndroidComponentXmlElement {
7-
// ImplicitlyExportedAndroidComponent() {
7+
ImplicitlyExportedAndroidComponent() {
8+
not this.hasExportedAttribute() and
9+
this.hasAnIntentFilterElement() and
10+
not this.getAnIntentFilterElement().getACategoryElement().getCategoryName() =
11+
"android.intent.category.LAUNCHER" and
12+
not this.requiresPermissions() and
13+
not this.getParent().(AndroidApplicationXmlElement).requiresPermissions() and
14+
//not this.getAnIntentFilterElement().hasLauncherCategoryElement() and
15+
not this.getFile().(AndroidManifestXmlFile).isInBuildDirectory()
16+
//this.getFile() instanceof SourceAndroidManifestXmlFile
17+
}
18+
// predicate isImplicitlyExported() {
819
// not this.hasExportedAttribute() and
920
// this.hasAnIntentFilterElement() and
1021
// not this.requiresPermissions() and
1122
// not this.getParent().(AndroidApplicationXmlElement).hasAttribute("permission") and
1223
// not this.getAnIntentFilterElement().hasLauncherCategoryElement() and
13-
// not this.getFile().(AndroidManifestXmlFile).isInBuildDirectory()
24+
// not this.getFile().(AndroidManifestXmlFile).isInBuildDirectory() //and
25+
// not this.getAnIntentFilterElement().getAnActionElement().getActionName().matches("%MEDIA%") and // try MEDIA exclusion -- MRVA returns 251 results, so only removed 13
26+
// not this.getAnIntentFilterElement().getAnActionElement().getActionName() =
27+
// "android.intent.action.MAIN" // try MAIN exclusion -- MRVA returns 193 results, so removed 251-193 = 58 results
1428
// }
15-
/**
16-
* Holds if this Android component is implicitly exported.
17-
*/
18-
predicate isImplicitlyExported() {
19-
not this.hasExportedAttribute() and
20-
this.hasAnIntentFilterElement() and
21-
not this.requiresPermissions() and
22-
not this.getParent().(AndroidApplicationXmlElement).hasAttribute("permission") and
23-
not this.getAnIntentFilterElement().hasLauncherCategoryElement() and
24-
not this.getFile().(AndroidManifestXmlFile).isInBuildDirectory()
25-
}
2629
}

java/ql/lib/semmle/code/xml/AndroidManifest.qll

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class AndroidManifestXmlFile extends XmlFile {
2525
predicate isInBuildDirectory() { this.getFile().getRelativePath().matches("%build%") }
2626
}
2727

28+
// class SourceAndroidManifestXmlFile extends AndroidManifestXmlFile {
29+
// SourceAndroidManifestXmlFile() { not this.getFile().getRelativePath().matches("%build%") }
30+
// }
2831
/**
2932
* A `<manifest>` element in an Android manifest file.
3033
*/
@@ -139,6 +142,7 @@ class AndroidPermissionXmlAttribute extends XmlAttribute {
139142
AndroidPermissionXmlAttribute() {
140143
this.getNamespace().getPrefix() = "android" and
141144
this.getName() = ["permission", "readPermission", "writePermission"]
145+
//this.getName() = ["permission"]
142146
}
143147

144148
/** Holds if this is an `android:permission` attribute. */
@@ -234,7 +238,8 @@ class AndroidComponentXmlElement extends XmlElement {
234238
/**
235239
* Holds if this component element has an `android:exported` attribute.
236240
*/
237-
predicate hasExportedAttribute() { this.hasAttribute("exported") }
241+
//predicate hasExportedAttribute() { this.hasAttribute("exported") }
242+
predicate hasExportedAttribute() { exists(this.getExportedAttributeValue()) }
238243

239244
/**
240245
* Holds if this component element has explicitly set a value for its `android:permission` attribute.
@@ -258,15 +263,14 @@ class AndroidIntentFilterXmlElement extends XmlElement {
258263
/**
259264
* Gets a `<category>` child element of this `<intent-filter>` element.
260265
*/
261-
AndroidCategoryXmlElement getACategoryElement() { result = this.getAChild("category") }
262-
263-
/**
264-
* Holds if this `<intent-filter>` element has a `<category>` child element
265-
* named `android.intent.category.LAUNCHER`.
266-
*/
267-
predicate hasLauncherCategoryElement() {
268-
this.getACategoryElement().getCategoryName() = "android.intent.category.LAUNCHER"
269-
}
266+
AndroidCategoryXmlElement getACategoryElement() { result = this.getAChild() }
267+
// /**
268+
// * Holds if this `<intent-filter>` element has a `<category>` child element
269+
// * named `android.intent.category.LAUNCHER`.
270+
// */
271+
// predicate hasLauncherCategoryElement() {
272+
// this.getACategoryElement().getCategoryName() = "android.intent.category.LAUNCHER"
273+
// }
270274
}
271275

272276
/**

java/ql/src/Security/CWE/CWE-926/ImplicitlyExportedAndroidComponent.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
import java
1414
import semmle.code.java.security.ImplicitlyExportedAndroidComponent
1515

16-
from ImplicitlyExportedAndroidComponent impExpAndroidComp
17-
where impExpAndroidComp.isImplicitlyExported()
18-
select impExpAndroidComp, "This component is implicitly exported."
1916
// from ImplicitlyExportedAndroidComponent impExpAndroidComp
20-
// where exists(impExpAndroidComp)
17+
// where impExpAndroidComp.isImplicitlyExported()
2118
// select impExpAndroidComp, "This component is implicitly exported."
19+
from ImplicitlyExportedAndroidComponent impExpAndroidComp
20+
//where exists(impExpAndroidComp)
21+
select impExpAndroidComp, "This component is implicitly exported."

java/ql/test/query-tests/security/CWE-926/ImplicitlyExportedAndroidComponentTest.ql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ class ImplicitlyExportedAndroidComponentTest extends InlineExpectationsTest {
1010
override predicate hasActualResult(Location location, string element, string tag, string value) {
1111
tag = "hasImplicitExport" and
1212
exists(ImplicitlyExportedAndroidComponent impExpAndroidComp |
13-
impExpAndroidComp.isImplicitlyExported()
14-
|
1513
impExpAndroidComp.getLocation() = location and
1614
element = impExpAndroidComp.toString() and
1715
value = ""

0 commit comments

Comments
 (0)