Skip to content

Commit 58d3d89

Browse files
Jami CogswellJami Cogswell
authored andcommitted
resolved merge conflict in AndroidManifest
1 parent 825df21 commit 58d3d89

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** Provides a class to reason about Android implicitly exported components. */
2+
3+
private import semmle.code.xml.AndroidManifest
4+
5+
class ImplicitlyExportedAndroidComponent extends AndroidComponentXmlElement {
6+
//ImplicitlyExportedAndroidComponent() { }
7+
predicate isImplicitlyExported() {
8+
not this.hasExportedAttribute() and
9+
this.hasAnIntentFilterElement() and
10+
not this.requiresPermissions() and
11+
not this.getParent().(AndroidApplicationXmlElement).hasAttribute("permission") and
12+
not this.getAnIntentFilterElement().hasLauncherCategoryElement() and
13+
not this.getFile().(AndroidManifestXmlFile).isInBuildDirectory()
14+
}
15+
}

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class AndroidProviderXmlElement extends AndroidComponentXmlElement {
113113
* `android:permission` attribute or its `android:readPermission` and `android:writePermission`
114114
* attributes.
115115
*/
116-
predicate requiresPermissions() {
116+
override predicate requiresPermissions() {
117117
this.getAnAttribute().(AndroidPermissionXmlAttribute).isFull()
118118
or
119119
this.getAnAttribute().(AndroidPermissionXmlAttribute).isWrite() and
@@ -236,16 +236,10 @@ class AndroidComponentXmlElement extends XmlElement {
236236
*/
237237
predicate hasExportedAttribute() { this.hasAttribute("exported") }
238238

239-
// /** Holds if this component element has an attribute with the name `permission`. */
240-
// predicate hasPermissionAttribute() { exists(this.getAttribute("permission")) }
241-
predicate isImplicitlyExported() {
242-
not this.hasExportedAttribute() and
243-
this.hasAnIntentFilterElement() and // Note: did not use getAnIntentFilterElement since don't need a return value
244-
not this.hasAttribute("permission") and // not seeing how isFull() is any better than this..., this seems to more directly check what I want...
245-
not this.getParent().(AndroidApplicationXmlElement).hasAttribute("permission") and
246-
not this.getAnIntentFilterElement().hasLauncherCategoryElement() and
247-
not this.getFile().(AndroidManifestXmlFile).isInBuildDirectory()
248-
}
239+
/**
240+
* Holds if this component element has explicitly set a value for its `android:permission` attribute.
241+
*/
242+
predicate requiresPermissions() { this.getAnAttribute().(AndroidPermissionXmlAttribute).isFull() }
249243
}
250244

251245
/**
@@ -268,10 +262,10 @@ class AndroidIntentFilterXmlElement extends XmlElement {
268262

269263
/**
270264
* Holds if this `<intent-filter>` element has a `<category>` child element
271-
* named "android.intent.category.LAUNCHER".
265+
* named `android.intent.category.LAUNCHER`.
272266
*/
273267
predicate hasLauncherCategoryElement() {
274-
this.getACategoryElement().getAttributeValue("name") = "android.intent.category.LAUNCHER"
268+
this.getACategoryElement().getCategoryName() = "android.intent.category.LAUNCHER"
275269
}
276270
}
277271

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
*/
1212

1313
import java
14-
import semmle.code.xml.AndroidManifest
14+
import semmle.code.java.security.ImplicitlyExportedAndroidComponent
1515

16-
from AndroidComponentXmlElement compElement
17-
where compElement.isImplicitlyExported()
18-
select compElement, "This component is implicitly exported."
16+
from ImplicitlyExportedAndroidComponent impExpAndroidComp
17+
where impExpAndroidComp.isImplicitlyExported()
18+
select impExpAndroidComp, "This component is implicitly exported."

0 commit comments

Comments
 (0)