mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Add generalized identifier resolution for AndroidManifest
Since more than one attribute can hold an identifier, refactor identifier resolution into a separate method.
This commit is contained in:
@@ -261,19 +261,30 @@ class AndroidComponentXmlElement extends XmlElement {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of an identifier attribute, and tries to resolve it into a fully qualified identifier.
|
||||
*/
|
||||
string getResolvedIdentifier(AndroidIdentifierXmlAttribute identifier) {
|
||||
exists(string name | name = identifier.getValue() |
|
||||
if name.matches(".%")
|
||||
then
|
||||
result =
|
||||
this.getParent()
|
||||
.(XmlElement)
|
||||
.getParent()
|
||||
.(AndroidManifestXmlElement)
|
||||
.getPackageAttributeValue() + name
|
||||
else result = name
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the resolved value of the `android:name` attribute of this component element.
|
||||
*/
|
||||
string getResolvedComponentName() {
|
||||
if this.getComponentName().matches(".%")
|
||||
then
|
||||
result =
|
||||
this.getParent()
|
||||
.(XmlElement)
|
||||
.getParent()
|
||||
.(AndroidManifestXmlElement)
|
||||
.getPackageAttributeValue() + this.getComponentName()
|
||||
else result = this.getComponentName()
|
||||
exists(AndroidXmlAttribute attr | attr = this.getAnAttribute() and attr.getName() = "name" |
|
||||
result = getResolvedIdentifier(attr)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user