mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
Add support for android:allowBackup default value
The default value of `android:allowBackup` is `true`. Added support for detecting if the default value is used.
This commit is contained in:
@@ -74,13 +74,17 @@ class AndroidApplicationXmlElement extends XmlElement {
|
|||||||
predicate requiresPermissions() { this.getAnAttribute().(AndroidPermissionXmlAttribute).isFull() }
|
predicate requiresPermissions() { this.getAnAttribute().(AndroidPermissionXmlAttribute).isFull() }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds if this application element has the attribute `android:allowBackup` set to `true`.
|
* Holds if this application element enables the `android:allowBackup` attribute.
|
||||||
|
*
|
||||||
|
* https://developer.android.com/guide/topics/data/autobackup
|
||||||
*/
|
*/
|
||||||
predicate allowsBackup() {
|
predicate allowsBackup() {
|
||||||
exists(AndroidXmlAttribute attr |
|
// The default value for the attribute `android:allowBackup` is `true`.
|
||||||
|
// Therefore we also check if it is not present.
|
||||||
|
not exists(AndroidXmlAttribute attr |
|
||||||
this.getAnAttribute() = attr and
|
this.getAnAttribute() = attr and
|
||||||
attr.getName() = "allowBackup" and
|
attr.getName() = "allowBackup" and
|
||||||
attr.getValue() = "true"
|
attr.getValue() = "false"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ from AndroidApplicationXmlElement androidAppElem
|
|||||||
where
|
where
|
||||||
androidAppElem.allowsBackup() and
|
androidAppElem.allowsBackup() and
|
||||||
androidAppElem.getFile().(AndroidManifestXmlFile).isInBuildDirectory()
|
androidAppElem.getFile().(AndroidManifestXmlFile).isInBuildDirectory()
|
||||||
select androidAppElem.getAttribute("allowBackup"), "The 'android:allowBackup' attribute is enabled."
|
select androidAppElem, "The 'android:allowBackup' attribute is enabled."
|
||||||
|
|||||||
7
java/ql/src/Security/CWE/CWE-312/AllowBackupEmpty.xml
Normal file
7
java/ql/src/Security/CWE/CWE-312/AllowBackupEmpty.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<manifest ... >
|
||||||
|
<!-- BAD: no 'android:allowBackup' set, defaults to 'true' -->
|
||||||
|
<application>
|
||||||
|
<activity ... >
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
Reference in New Issue
Block a user