rename all occurrences of XML to Xml

This commit is contained in:
erik-krogh
2022-08-16 22:19:14 +02:00
parent 72c204063d
commit ce9f69a639
49 changed files with 407 additions and 287 deletions

View File

@@ -8,7 +8,7 @@ private class TXmlLocatable =
@xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters; @xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters;
/** An XML element that has a location. */ /** An XML element that has a location. */
class XMLLocatable extends @xmllocatable, TXmlLocatable { class XmlLocatable extends @xmllocatable, TXmlLocatable {
/** Gets the source location for this element. */ /** Gets the source location for this element. */
Location getLocation() { xmllocations(this, result) } Location getLocation() { xmllocations(this, result) }
@@ -32,12 +32,15 @@ class XMLLocatable extends @xmllocatable, TXmlLocatable {
string toString() { none() } // overridden in subclasses string toString() { none() } // overridden in subclasses
} }
/** DEPRECATED: Alias for XmlLocatable */
deprecated class XMLLocatable = XmlLocatable;
/** /**
* An `XMLParent` is either an `XMLElement` or an `XMLFile`, * An `XMLParent` is either an `XMLElement` or an `XMLFile`,
* both of which can contain other elements. * both of which can contain other elements.
*/ */
class XMLParent extends @xmlparent { class XmlParent extends @xmlparent {
XMLParent() { XmlParent() {
// explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`; // explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`;
// the type `@xmlparent` currently also includes non-XML files // the type `@xmlparent` currently also includes non-XML files
this instanceof @xmlelement or xmlEncoding(this, _) this instanceof @xmlelement or xmlEncoding(this, _)
@@ -50,28 +53,28 @@ class XMLParent extends @xmlparent {
string getName() { none() } // overridden in subclasses string getName() { none() } // overridden in subclasses
/** Gets the file to which this XML parent belongs. */ /** Gets the file to which this XML parent belongs. */
XMLFile getFile() { result = this or xmlElements(this, _, _, _, result) } XmlFile getFile() { result = this or xmlElements(this, _, _, _, result) }
/** Gets the child element at a specified index of this XML parent. */ /** Gets the child element at a specified index of this XML parent. */
XMLElement getChild(int index) { xmlElements(result, _, this, index, _) } XmlElement getChild(int index) { xmlElements(result, _, this, index, _) }
/** Gets a child element of this XML parent. */ /** Gets a child element of this XML parent. */
XMLElement getAChild() { xmlElements(result, _, this, _, _) } XmlElement getAChild() { xmlElements(result, _, this, _, _) }
/** Gets a child element of this XML parent with the given `name`. */ /** Gets a child element of this XML parent with the given `name`. */
XMLElement getAChild(string name) { xmlElements(result, _, this, _, _) and result.hasName(name) } XmlElement getAChild(string name) { xmlElements(result, _, this, _, _) and result.hasName(name) }
/** Gets a comment that is a child of this XML parent. */ /** Gets a comment that is a child of this XML parent. */
XMLComment getAComment() { xmlComments(result, _, this, _) } XmlComment getAComment() { xmlComments(result, _, this, _) }
/** Gets a character sequence that is a child of this XML parent. */ /** Gets a character sequence that is a child of this XML parent. */
XMLCharacters getACharactersSet() { xmlChars(result, _, this, _, _, _) } XmlCharacters getACharactersSet() { xmlChars(result, _, this, _, _, _) }
/** Gets the depth in the tree. (Overridden in XMLElement.) */ /** Gets the depth in the tree. (Overridden in XmlElement.) */
int getDepth() { result = 0 } int getDepth() { result = 0 }
/** Gets the number of child XML elements of this XML parent. */ /** Gets the number of child XML elements of this XML parent. */
int getNumberOfChildren() { result = count(XMLElement e | xmlElements(e, _, this, _, _)) } int getNumberOfChildren() { result = count(XmlElement e | xmlElements(e, _, this, _, _)) }
/** Gets the number of places in the body of this XML parent where text occurs. */ /** Gets the number of places in the body of this XML parent where text occurs. */
int getNumberOfCharacterSets() { result = count(int pos | xmlChars(_, _, this, pos, _, _)) } int getNumberOfCharacterSets() { result = count(int pos | xmlChars(_, _, this, pos, _, _)) }
@@ -92,9 +95,12 @@ class XMLParent extends @xmlparent {
string toString() { result = this.getName() } string toString() { result = this.getName() }
} }
/** DEPRECATED: Alias for XmlParent */
deprecated class XMLParent = XmlParent;
/** An XML file. */ /** An XML file. */
class XMLFile extends XMLParent, File { class XmlFile extends XmlParent, File {
XMLFile() { xmlEncoding(this, _) } XmlFile() { xmlEncoding(this, _) }
/** Gets a printable representation of this XML file. */ /** Gets a printable representation of this XML file. */
override string toString() { result = this.getName() } override string toString() { result = this.getName() }
@@ -120,15 +126,18 @@ class XMLFile extends XMLParent, File {
string getEncoding() { xmlEncoding(this, result) } string getEncoding() { xmlEncoding(this, result) }
/** Gets the XML file itself. */ /** Gets the XML file itself. */
override XMLFile getFile() { result = this } override XmlFile getFile() { result = this }
/** Gets a top-most element in an XML file. */ /** Gets a top-most element in an XML file. */
XMLElement getARootElement() { result = this.getAChild() } XmlElement getARootElement() { result = this.getAChild() }
/** Gets a DTD associated with this XML file. */ /** Gets a DTD associated with this XML file. */
XMLDTD getADTD() { xmlDTDs(result, _, _, _, this) } XMLDTD getADTD() { xmlDTDs(result, _, _, _, this) }
} }
/** DEPRECATED: Alias for XmlFile */
deprecated class XMLFile = XmlFile;
/** /**
* An XML document type definition (DTD). * An XML document type definition (DTD).
* *
@@ -140,7 +149,7 @@ class XMLFile extends XMLParent, File {
* <!ELEMENT lastName (#PCDATA)> * <!ELEMENT lastName (#PCDATA)>
* ``` * ```
*/ */
class XMLDTD extends XMLLocatable, @xmldtd { class XMLDTD extends XmlLocatable, @xmldtd {
/** Gets the name of the root element of this DTD. */ /** Gets the name of the root element of this DTD. */
string getRoot() { xmlDTDs(this, result, _, _, _) } string getRoot() { xmlDTDs(this, result, _, _, _) }
@@ -154,7 +163,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
predicate isPublic() { not xmlDTDs(this, _, "", _, _) } predicate isPublic() { not xmlDTDs(this, _, "", _, _) }
/** Gets the parent of this DTD. */ /** Gets the parent of this DTD. */
XMLParent getParent() { xmlDTDs(this, _, _, _, result) } XmlParent getParent() { xmlDTDs(this, _, _, _, result) }
override string toString() { override string toString() {
this.isPublic() and this.isPublic() and
@@ -176,7 +185,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
* </manifest> * </manifest>
* ``` * ```
*/ */
class XMLElement extends @xmlelement, XMLParent, XMLLocatable { class XmlElement extends @xmlelement, XmlParent, XmlLocatable {
/** Holds if this XML element has the given `name`. */ /** Holds if this XML element has the given `name`. */
predicate hasName(string name) { name = this.getName() } predicate hasName(string name) { name = this.getName() }
@@ -184,10 +193,10 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override string getName() { xmlElements(this, result, _, _, _) } override string getName() { xmlElements(this, result, _, _, _) }
/** Gets the XML file in which this XML element occurs. */ /** Gets the XML file in which this XML element occurs. */
override XMLFile getFile() { xmlElements(this, _, _, _, result) } override XmlFile getFile() { xmlElements(this, _, _, _, result) }
/** Gets the parent of this XML element. */ /** Gets the parent of this XML element. */
XMLParent getParent() { xmlElements(this, _, result, _, _) } XmlParent getParent() { xmlElements(this, _, result, _, _) }
/** Gets the index of this XML element among its parent's children. */ /** Gets the index of this XML element among its parent's children. */
int getIndex() { xmlElements(this, _, _, result, _) } int getIndex() { xmlElements(this, _, _, result, _) }
@@ -196,7 +205,7 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
predicate hasNamespace() { xmlHasNs(this, _, _) } predicate hasNamespace() { xmlHasNs(this, _, _) }
/** Gets the namespace of this XML element, if any. */ /** Gets the namespace of this XML element, if any. */
XMLNamespace getNamespace() { xmlHasNs(this, result, _) } XmlNamespace getNamespace() { xmlHasNs(this, result, _) }
/** Gets the index of this XML element among its parent's children. */ /** Gets the index of this XML element among its parent's children. */
int getElementPositionIndex() { xmlElements(this, _, _, result, _) } int getElementPositionIndex() { xmlElements(this, _, _, result, _) }
@@ -205,10 +214,10 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override int getDepth() { result = this.getParent().getDepth() + 1 } override int getDepth() { result = this.getParent().getDepth() + 1 }
/** Gets an XML attribute of this XML element. */ /** Gets an XML attribute of this XML element. */
XMLAttribute getAnAttribute() { result.getElement() = this } XmlAttribute getAnAttribute() { result.getElement() = this }
/** Gets the attribute with the specified `name`, if any. */ /** Gets the attribute with the specified `name`, if any. */
XMLAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name } XmlAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name }
/** Holds if this XML element has an attribute with the specified `name`. */ /** Holds if this XML element has an attribute with the specified `name`. */
predicate hasAttribute(string name) { exists(this.getAttribute(name)) } predicate hasAttribute(string name) { exists(this.getAttribute(name)) }
@@ -220,6 +229,9 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override string toString() { result = this.getName() } override string toString() { result = this.getName() }
} }
/** DEPRECATED: Alias for XmlElement */
deprecated class XMLElement = XmlElement;
/** /**
* An attribute that occurs inside an XML element. * An attribute that occurs inside an XML element.
* *
@@ -230,18 +242,18 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
* android:versionCode="1" * android:versionCode="1"
* ``` * ```
*/ */
class XMLAttribute extends @xmlattribute, XMLLocatable { class XmlAttribute extends @xmlattribute, XmlLocatable {
/** Gets the name of this attribute. */ /** Gets the name of this attribute. */
string getName() { xmlAttrs(this, _, result, _, _, _) } string getName() { xmlAttrs(this, _, result, _, _, _) }
/** Gets the XML element to which this attribute belongs. */ /** Gets the XML element to which this attribute belongs. */
XMLElement getElement() { xmlAttrs(this, result, _, _, _, _) } XmlElement getElement() { xmlAttrs(this, result, _, _, _, _) }
/** Holds if this attribute has a namespace. */ /** Holds if this attribute has a namespace. */
predicate hasNamespace() { xmlHasNs(this, _, _) } predicate hasNamespace() { xmlHasNs(this, _, _) }
/** Gets the namespace of this attribute, if any. */ /** Gets the namespace of this attribute, if any. */
XMLNamespace getNamespace() { xmlHasNs(this, result, _) } XmlNamespace getNamespace() { xmlHasNs(this, result, _) }
/** Gets the value of this attribute. */ /** Gets the value of this attribute. */
string getValue() { xmlAttrs(this, _, _, result, _, _) } string getValue() { xmlAttrs(this, _, _, result, _, _) }
@@ -250,6 +262,9 @@ class XMLAttribute extends @xmlattribute, XMLLocatable {
override string toString() { result = this.getName() + "=" + this.getValue() } override string toString() { result = this.getName() + "=" + this.getValue() }
} }
/** DEPRECATED: Alias for XmlAttribute */
deprecated class XMLAttribute = XmlAttribute;
/** /**
* A namespace used in an XML file. * A namespace used in an XML file.
* *
@@ -259,7 +274,7 @@ class XMLAttribute extends @xmlattribute, XMLLocatable {
* xmlns:android="http://schemas.android.com/apk/res/android" * xmlns:android="http://schemas.android.com/apk/res/android"
* ``` * ```
*/ */
class XMLNamespace extends XMLLocatable, @xmlnamespace { class XmlNamespace extends XmlLocatable, @xmlnamespace {
/** Gets the prefix of this namespace. */ /** Gets the prefix of this namespace. */
string getPrefix() { xmlNs(this, result, _, _) } string getPrefix() { xmlNs(this, result, _, _) }
@@ -276,6 +291,9 @@ class XMLNamespace extends XMLLocatable, @xmlnamespace {
} }
} }
/** DEPRECATED: Alias for XmlNamespace */
deprecated class XMLNamespace = XmlNamespace;
/** /**
* A comment in an XML file. * A comment in an XML file.
* *
@@ -285,17 +303,20 @@ class XMLNamespace extends XMLLocatable, @xmlnamespace {
* <!-- This is a comment. --> * <!-- This is a comment. -->
* ``` * ```
*/ */
class XMLComment extends @xmlcomment, XMLLocatable { class XmlComment extends @xmlcomment, XmlLocatable {
/** Gets the text content of this XML comment. */ /** Gets the text content of this XML comment. */
string getText() { xmlComments(this, result, _, _) } string getText() { xmlComments(this, result, _, _) }
/** Gets the parent of this XML comment. */ /** Gets the parent of this XML comment. */
XMLParent getParent() { xmlComments(this, _, result, _) } XmlParent getParent() { xmlComments(this, _, result, _) }
/** Gets a printable representation of this XML comment. */ /** Gets a printable representation of this XML comment. */
override string toString() { result = this.getText() } override string toString() { result = this.getText() }
} }
/** DEPRECATED: Alias for XmlComment */
deprecated class XMLComment = XmlComment;
/** /**
* A sequence of characters that occurs between opening and * A sequence of characters that occurs between opening and
* closing tags of an XML element, excluding other elements. * closing tags of an XML element, excluding other elements.
@@ -306,12 +327,12 @@ class XMLComment extends @xmlcomment, XMLLocatable {
* <content>This is a sequence of characters.</content> * <content>This is a sequence of characters.</content>
* ``` * ```
*/ */
class XMLCharacters extends @xmlcharacters, XMLLocatable { class XmlCharacters extends @xmlcharacters, XmlLocatable {
/** Gets the content of this character sequence. */ /** Gets the content of this character sequence. */
string getCharacters() { xmlChars(this, result, _, _, _, _) } string getCharacters() { xmlChars(this, result, _, _, _, _) }
/** Gets the parent of this character sequence. */ /** Gets the parent of this character sequence. */
XMLParent getParent() { xmlChars(this, _, result, _, _, _) } XmlParent getParent() { xmlChars(this, _, result, _, _, _) }
/** Holds if this character sequence is CDATA. */ /** Holds if this character sequence is CDATA. */
predicate isCDATA() { xmlChars(this, _, _, _, 1, _) } predicate isCDATA() { xmlChars(this, _, _, _, 1, _) }
@@ -319,3 +340,6 @@ class XMLCharacters extends @xmlcharacters, XMLLocatable {
/** Gets a printable representation of this XML character sequence. */ /** Gets a printable representation of this XML character sequence. */
override string toString() { result = this.getCharacters() } override string toString() { result = this.getCharacters() }
} }
/** DEPRECATED: Alias for XmlCharacters */
deprecated class XMLCharacters = XmlCharacters;

View File

@@ -7,7 +7,7 @@ string describe(File f) {
f.compiledAsCpp() and f.compiledAsCpp() and
result = "C++" result = "C++"
or or
f instanceof XMLParent and f instanceof XmlParent and
result = "XMLParent" // regression tests a bug in the characteristic predicate of XMLParent result = "XMLParent" // regression tests a bug in the characteristic predicate of XMLParent
} }

View File

@@ -7,7 +7,7 @@ import csharp
/** /**
* A `Web.config` file. * A `Web.config` file.
*/ */
class WebConfigXml extends XMLFile { class WebConfigXml extends XmlFile {
WebConfigXml() { this.getName().matches("%Web.config") } WebConfigXml() { this.getName().matches("%Web.config") }
} }
@@ -15,7 +15,7 @@ class WebConfigXml extends XMLFile {
deprecated class WebConfigXML = WebConfigXml; deprecated class WebConfigXML = WebConfigXml;
/** A `<configuration>` tag in an ASP.NET configuration file. */ /** A `<configuration>` tag in an ASP.NET configuration file. */
class ConfigurationXmlElement extends XMLElement { class ConfigurationXmlElement extends XmlElement {
ConfigurationXmlElement() { this.getName().toLowerCase() = "configuration" } ConfigurationXmlElement() { this.getName().toLowerCase() = "configuration" }
} }
@@ -23,7 +23,7 @@ class ConfigurationXmlElement extends XMLElement {
deprecated class ConfigurationXMLElement = ConfigurationXmlElement; deprecated class ConfigurationXMLElement = ConfigurationXmlElement;
/** A `<location>` tag in an ASP.NET configuration file. */ /** A `<location>` tag in an ASP.NET configuration file. */
class LocationXmlElement extends XMLElement { class LocationXmlElement extends XmlElement {
LocationXmlElement() { LocationXmlElement() {
this.getParent() instanceof ConfigurationXmlElement and this.getParent() instanceof ConfigurationXmlElement and
this.getName().toLowerCase() = "location" this.getName().toLowerCase() = "location"
@@ -34,7 +34,7 @@ class LocationXmlElement extends XMLElement {
deprecated class LocationXMLElement = LocationXmlElement; deprecated class LocationXMLElement = LocationXmlElement;
/** A `<system.web>` tag in an ASP.NET configuration file. */ /** A `<system.web>` tag in an ASP.NET configuration file. */
class SystemWebXmlElement extends XMLElement { class SystemWebXmlElement extends XmlElement {
SystemWebXmlElement() { SystemWebXmlElement() {
( (
this.getParent() instanceof ConfigurationXmlElement this.getParent() instanceof ConfigurationXmlElement
@@ -49,7 +49,7 @@ class SystemWebXmlElement extends XMLElement {
deprecated class SystemWebXMLElement = SystemWebXmlElement; deprecated class SystemWebXMLElement = SystemWebXmlElement;
/** A `<system.webServer>` tag in an ASP.NET configuration file. */ /** A `<system.webServer>` tag in an ASP.NET configuration file. */
class SystemWebServerXmlElement extends XMLElement { class SystemWebServerXmlElement extends XmlElement {
SystemWebServerXmlElement() { SystemWebServerXmlElement() {
( (
this.getParent() instanceof ConfigurationXmlElement this.getParent() instanceof ConfigurationXmlElement
@@ -64,7 +64,7 @@ class SystemWebServerXmlElement extends XMLElement {
deprecated class SystemWebServerXMLElement = SystemWebServerXmlElement; deprecated class SystemWebServerXMLElement = SystemWebServerXmlElement;
/** A `<customErrors>` tag in an ASP.NET configuration file. */ /** A `<customErrors>` tag in an ASP.NET configuration file. */
class CustomErrorsXmlElement extends XMLElement { class CustomErrorsXmlElement extends XmlElement {
CustomErrorsXmlElement() { CustomErrorsXmlElement() {
this.getParent() instanceof SystemWebXmlElement and this.getParent() instanceof SystemWebXmlElement and
this.getName().toLowerCase() = "customerrors" this.getName().toLowerCase() = "customerrors"
@@ -75,7 +75,7 @@ class CustomErrorsXmlElement extends XMLElement {
deprecated class CustomErrorsXMLElement = CustomErrorsXmlElement; deprecated class CustomErrorsXMLElement = CustomErrorsXmlElement;
/** A `<httpRuntime>` tag in an ASP.NET configuration file. */ /** A `<httpRuntime>` tag in an ASP.NET configuration file. */
class HttpRuntimeXmlElement extends XMLElement { class HttpRuntimeXmlElement extends XmlElement {
HttpRuntimeXmlElement() { HttpRuntimeXmlElement() {
this.getParent() instanceof SystemWebXmlElement and this.getParent() instanceof SystemWebXmlElement and
this.getName().toLowerCase() = "httpruntime" this.getName().toLowerCase() = "httpruntime"
@@ -86,7 +86,7 @@ class HttpRuntimeXmlElement extends XMLElement {
deprecated class HttpRuntimeXMLElement = HttpRuntimeXmlElement; deprecated class HttpRuntimeXMLElement = HttpRuntimeXmlElement;
/** A `<forms>` tag under `<system.web><authentication>` in an ASP.NET configuration file. */ /** A `<forms>` tag under `<system.web><authentication>` in an ASP.NET configuration file. */
class FormsElement extends XMLElement { class FormsElement extends XmlElement {
FormsElement() { FormsElement() {
this = any(SystemWebXmlElement sw).getAChild("authentication").getAChild("forms") this = any(SystemWebXmlElement sw).getAChild("authentication").getAChild("forms")
} }
@@ -105,7 +105,7 @@ class FormsElement extends XMLElement {
} }
/** A `<httpCookies>` tag in an ASP.NET configuration file. */ /** A `<httpCookies>` tag in an ASP.NET configuration file. */
class HttpCookiesElement extends XMLElement { class HttpCookiesElement extends XmlElement {
HttpCookiesElement() { this = any(SystemWebXmlElement sw).getAChild("httpCookies") } HttpCookiesElement() { this = any(SystemWebXmlElement sw).getAChild("httpCookies") }
/** /**

View File

@@ -8,7 +8,7 @@ private class TXmlLocatable =
@xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters; @xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters;
/** An XML element that has a location. */ /** An XML element that has a location. */
class XMLLocatable extends @xmllocatable, TXmlLocatable { class XmlLocatable extends @xmllocatable, TXmlLocatable {
/** Gets the source location for this element. */ /** Gets the source location for this element. */
Location getLocation() { xmllocations(this, result) } Location getLocation() { xmllocations(this, result) }
@@ -32,12 +32,15 @@ class XMLLocatable extends @xmllocatable, TXmlLocatable {
string toString() { none() } // overridden in subclasses string toString() { none() } // overridden in subclasses
} }
/** DEPRECATED: Alias for XmlLocatable */
deprecated class XMLLocatable = XmlLocatable;
/** /**
* An `XMLParent` is either an `XMLElement` or an `XMLFile`, * An `XMLParent` is either an `XMLElement` or an `XMLFile`,
* both of which can contain other elements. * both of which can contain other elements.
*/ */
class XMLParent extends @xmlparent { class XmlParent extends @xmlparent {
XMLParent() { XmlParent() {
// explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`; // explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`;
// the type `@xmlparent` currently also includes non-XML files // the type `@xmlparent` currently also includes non-XML files
this instanceof @xmlelement or xmlEncoding(this, _) this instanceof @xmlelement or xmlEncoding(this, _)
@@ -50,28 +53,28 @@ class XMLParent extends @xmlparent {
string getName() { none() } // overridden in subclasses string getName() { none() } // overridden in subclasses
/** Gets the file to which this XML parent belongs. */ /** Gets the file to which this XML parent belongs. */
XMLFile getFile() { result = this or xmlElements(this, _, _, _, result) } XmlFile getFile() { result = this or xmlElements(this, _, _, _, result) }
/** Gets the child element at a specified index of this XML parent. */ /** Gets the child element at a specified index of this XML parent. */
XMLElement getChild(int index) { xmlElements(result, _, this, index, _) } XmlElement getChild(int index) { xmlElements(result, _, this, index, _) }
/** Gets a child element of this XML parent. */ /** Gets a child element of this XML parent. */
XMLElement getAChild() { xmlElements(result, _, this, _, _) } XmlElement getAChild() { xmlElements(result, _, this, _, _) }
/** Gets a child element of this XML parent with the given `name`. */ /** Gets a child element of this XML parent with the given `name`. */
XMLElement getAChild(string name) { xmlElements(result, _, this, _, _) and result.hasName(name) } XmlElement getAChild(string name) { xmlElements(result, _, this, _, _) and result.hasName(name) }
/** Gets a comment that is a child of this XML parent. */ /** Gets a comment that is a child of this XML parent. */
XMLComment getAComment() { xmlComments(result, _, this, _) } XmlComment getAComment() { xmlComments(result, _, this, _) }
/** Gets a character sequence that is a child of this XML parent. */ /** Gets a character sequence that is a child of this XML parent. */
XMLCharacters getACharactersSet() { xmlChars(result, _, this, _, _, _) } XmlCharacters getACharactersSet() { xmlChars(result, _, this, _, _, _) }
/** Gets the depth in the tree. (Overridden in XMLElement.) */ /** Gets the depth in the tree. (Overridden in XmlElement.) */
int getDepth() { result = 0 } int getDepth() { result = 0 }
/** Gets the number of child XML elements of this XML parent. */ /** Gets the number of child XML elements of this XML parent. */
int getNumberOfChildren() { result = count(XMLElement e | xmlElements(e, _, this, _, _)) } int getNumberOfChildren() { result = count(XmlElement e | xmlElements(e, _, this, _, _)) }
/** Gets the number of places in the body of this XML parent where text occurs. */ /** Gets the number of places in the body of this XML parent where text occurs. */
int getNumberOfCharacterSets() { result = count(int pos | xmlChars(_, _, this, pos, _, _)) } int getNumberOfCharacterSets() { result = count(int pos | xmlChars(_, _, this, pos, _, _)) }
@@ -92,9 +95,12 @@ class XMLParent extends @xmlparent {
string toString() { result = this.getName() } string toString() { result = this.getName() }
} }
/** DEPRECATED: Alias for XmlParent */
deprecated class XMLParent = XmlParent;
/** An XML file. */ /** An XML file. */
class XMLFile extends XMLParent, File { class XmlFile extends XmlParent, File {
XMLFile() { xmlEncoding(this, _) } XmlFile() { xmlEncoding(this, _) }
/** Gets a printable representation of this XML file. */ /** Gets a printable representation of this XML file. */
override string toString() { result = this.getName() } override string toString() { result = this.getName() }
@@ -120,15 +126,18 @@ class XMLFile extends XMLParent, File {
string getEncoding() { xmlEncoding(this, result) } string getEncoding() { xmlEncoding(this, result) }
/** Gets the XML file itself. */ /** Gets the XML file itself. */
override XMLFile getFile() { result = this } override XmlFile getFile() { result = this }
/** Gets a top-most element in an XML file. */ /** Gets a top-most element in an XML file. */
XMLElement getARootElement() { result = this.getAChild() } XmlElement getARootElement() { result = this.getAChild() }
/** Gets a DTD associated with this XML file. */ /** Gets a DTD associated with this XML file. */
XMLDTD getADTD() { xmlDTDs(result, _, _, _, this) } XMLDTD getADTD() { xmlDTDs(result, _, _, _, this) }
} }
/** DEPRECATED: Alias for XmlFile */
deprecated class XMLFile = XmlFile;
/** /**
* An XML document type definition (DTD). * An XML document type definition (DTD).
* *
@@ -140,7 +149,7 @@ class XMLFile extends XMLParent, File {
* <!ELEMENT lastName (#PCDATA)> * <!ELEMENT lastName (#PCDATA)>
* ``` * ```
*/ */
class XMLDTD extends XMLLocatable, @xmldtd { class XMLDTD extends XmlLocatable, @xmldtd {
/** Gets the name of the root element of this DTD. */ /** Gets the name of the root element of this DTD. */
string getRoot() { xmlDTDs(this, result, _, _, _) } string getRoot() { xmlDTDs(this, result, _, _, _) }
@@ -154,7 +163,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
predicate isPublic() { not xmlDTDs(this, _, "", _, _) } predicate isPublic() { not xmlDTDs(this, _, "", _, _) }
/** Gets the parent of this DTD. */ /** Gets the parent of this DTD. */
XMLParent getParent() { xmlDTDs(this, _, _, _, result) } XmlParent getParent() { xmlDTDs(this, _, _, _, result) }
override string toString() { override string toString() {
this.isPublic() and this.isPublic() and
@@ -176,7 +185,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
* </manifest> * </manifest>
* ``` * ```
*/ */
class XMLElement extends @xmlelement, XMLParent, XMLLocatable { class XmlElement extends @xmlelement, XmlParent, XmlLocatable {
/** Holds if this XML element has the given `name`. */ /** Holds if this XML element has the given `name`. */
predicate hasName(string name) { name = this.getName() } predicate hasName(string name) { name = this.getName() }
@@ -184,10 +193,10 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override string getName() { xmlElements(this, result, _, _, _) } override string getName() { xmlElements(this, result, _, _, _) }
/** Gets the XML file in which this XML element occurs. */ /** Gets the XML file in which this XML element occurs. */
override XMLFile getFile() { xmlElements(this, _, _, _, result) } override XmlFile getFile() { xmlElements(this, _, _, _, result) }
/** Gets the parent of this XML element. */ /** Gets the parent of this XML element. */
XMLParent getParent() { xmlElements(this, _, result, _, _) } XmlParent getParent() { xmlElements(this, _, result, _, _) }
/** Gets the index of this XML element among its parent's children. */ /** Gets the index of this XML element among its parent's children. */
int getIndex() { xmlElements(this, _, _, result, _) } int getIndex() { xmlElements(this, _, _, result, _) }
@@ -196,7 +205,7 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
predicate hasNamespace() { xmlHasNs(this, _, _) } predicate hasNamespace() { xmlHasNs(this, _, _) }
/** Gets the namespace of this XML element, if any. */ /** Gets the namespace of this XML element, if any. */
XMLNamespace getNamespace() { xmlHasNs(this, result, _) } XmlNamespace getNamespace() { xmlHasNs(this, result, _) }
/** Gets the index of this XML element among its parent's children. */ /** Gets the index of this XML element among its parent's children. */
int getElementPositionIndex() { xmlElements(this, _, _, result, _) } int getElementPositionIndex() { xmlElements(this, _, _, result, _) }
@@ -205,10 +214,10 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override int getDepth() { result = this.getParent().getDepth() + 1 } override int getDepth() { result = this.getParent().getDepth() + 1 }
/** Gets an XML attribute of this XML element. */ /** Gets an XML attribute of this XML element. */
XMLAttribute getAnAttribute() { result.getElement() = this } XmlAttribute getAnAttribute() { result.getElement() = this }
/** Gets the attribute with the specified `name`, if any. */ /** Gets the attribute with the specified `name`, if any. */
XMLAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name } XmlAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name }
/** Holds if this XML element has an attribute with the specified `name`. */ /** Holds if this XML element has an attribute with the specified `name`. */
predicate hasAttribute(string name) { exists(this.getAttribute(name)) } predicate hasAttribute(string name) { exists(this.getAttribute(name)) }
@@ -220,6 +229,9 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override string toString() { result = this.getName() } override string toString() { result = this.getName() }
} }
/** DEPRECATED: Alias for XmlElement */
deprecated class XMLElement = XmlElement;
/** /**
* An attribute that occurs inside an XML element. * An attribute that occurs inside an XML element.
* *
@@ -230,18 +242,18 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
* android:versionCode="1" * android:versionCode="1"
* ``` * ```
*/ */
class XMLAttribute extends @xmlattribute, XMLLocatable { class XmlAttribute extends @xmlattribute, XmlLocatable {
/** Gets the name of this attribute. */ /** Gets the name of this attribute. */
string getName() { xmlAttrs(this, _, result, _, _, _) } string getName() { xmlAttrs(this, _, result, _, _, _) }
/** Gets the XML element to which this attribute belongs. */ /** Gets the XML element to which this attribute belongs. */
XMLElement getElement() { xmlAttrs(this, result, _, _, _, _) } XmlElement getElement() { xmlAttrs(this, result, _, _, _, _) }
/** Holds if this attribute has a namespace. */ /** Holds if this attribute has a namespace. */
predicate hasNamespace() { xmlHasNs(this, _, _) } predicate hasNamespace() { xmlHasNs(this, _, _) }
/** Gets the namespace of this attribute, if any. */ /** Gets the namespace of this attribute, if any. */
XMLNamespace getNamespace() { xmlHasNs(this, result, _) } XmlNamespace getNamespace() { xmlHasNs(this, result, _) }
/** Gets the value of this attribute. */ /** Gets the value of this attribute. */
string getValue() { xmlAttrs(this, _, _, result, _, _) } string getValue() { xmlAttrs(this, _, _, result, _, _) }
@@ -250,6 +262,9 @@ class XMLAttribute extends @xmlattribute, XMLLocatable {
override string toString() { result = this.getName() + "=" + this.getValue() } override string toString() { result = this.getName() + "=" + this.getValue() }
} }
/** DEPRECATED: Alias for XmlAttribute */
deprecated class XMLAttribute = XmlAttribute;
/** /**
* A namespace used in an XML file. * A namespace used in an XML file.
* *
@@ -259,7 +274,7 @@ class XMLAttribute extends @xmlattribute, XMLLocatable {
* xmlns:android="http://schemas.android.com/apk/res/android" * xmlns:android="http://schemas.android.com/apk/res/android"
* ``` * ```
*/ */
class XMLNamespace extends XMLLocatable, @xmlnamespace { class XmlNamespace extends XmlLocatable, @xmlnamespace {
/** Gets the prefix of this namespace. */ /** Gets the prefix of this namespace. */
string getPrefix() { xmlNs(this, result, _, _) } string getPrefix() { xmlNs(this, result, _, _) }
@@ -276,6 +291,9 @@ class XMLNamespace extends XMLLocatable, @xmlnamespace {
} }
} }
/** DEPRECATED: Alias for XmlNamespace */
deprecated class XMLNamespace = XmlNamespace;
/** /**
* A comment in an XML file. * A comment in an XML file.
* *
@@ -285,17 +303,20 @@ class XMLNamespace extends XMLLocatable, @xmlnamespace {
* <!-- This is a comment. --> * <!-- This is a comment. -->
* ``` * ```
*/ */
class XMLComment extends @xmlcomment, XMLLocatable { class XmlComment extends @xmlcomment, XmlLocatable {
/** Gets the text content of this XML comment. */ /** Gets the text content of this XML comment. */
string getText() { xmlComments(this, result, _, _) } string getText() { xmlComments(this, result, _, _) }
/** Gets the parent of this XML comment. */ /** Gets the parent of this XML comment. */
XMLParent getParent() { xmlComments(this, _, result, _) } XmlParent getParent() { xmlComments(this, _, result, _) }
/** Gets a printable representation of this XML comment. */ /** Gets a printable representation of this XML comment. */
override string toString() { result = this.getText() } override string toString() { result = this.getText() }
} }
/** DEPRECATED: Alias for XmlComment */
deprecated class XMLComment = XmlComment;
/** /**
* A sequence of characters that occurs between opening and * A sequence of characters that occurs between opening and
* closing tags of an XML element, excluding other elements. * closing tags of an XML element, excluding other elements.
@@ -306,12 +327,12 @@ class XMLComment extends @xmlcomment, XMLLocatable {
* <content>This is a sequence of characters.</content> * <content>This is a sequence of characters.</content>
* ``` * ```
*/ */
class XMLCharacters extends @xmlcharacters, XMLLocatable { class XmlCharacters extends @xmlcharacters, XmlLocatable {
/** Gets the content of this character sequence. */ /** Gets the content of this character sequence. */
string getCharacters() { xmlChars(this, result, _, _, _, _) } string getCharacters() { xmlChars(this, result, _, _, _, _) }
/** Gets the parent of this character sequence. */ /** Gets the parent of this character sequence. */
XMLParent getParent() { xmlChars(this, _, result, _, _, _) } XmlParent getParent() { xmlChars(this, _, result, _, _, _) }
/** Holds if this character sequence is CDATA. */ /** Holds if this character sequence is CDATA. */
predicate isCDATA() { xmlChars(this, _, _, _, 1, _) } predicate isCDATA() { xmlChars(this, _, _, _, 1, _) }
@@ -319,3 +340,6 @@ class XMLCharacters extends @xmlcharacters, XMLLocatable {
/** Gets a printable representation of this XML character sequence. */ /** Gets a printable representation of this XML character sequence. */
override string toString() { result = this.getCharacters() } override string toString() { result = this.getCharacters() }
} }
/** DEPRECATED: Alias for XmlCharacters */
deprecated class XMLCharacters = XmlCharacters;

View File

@@ -6,7 +6,7 @@ import csharp
private import semmle.code.csharp.security.dataflow.flowsources.Remote private import semmle.code.csharp.security.dataflow.flowsources.Remote
private import semmle.code.csharp.frameworks.System private import semmle.code.csharp.frameworks.System
private import semmle.code.csharp.frameworks.system.text.RegularExpressions private import semmle.code.csharp.frameworks.system.text.RegularExpressions
private import semmle.code.csharp.security.xml.InsecureXMLQuery as InsecureXML private import semmle.code.csharp.security.xml.InsecureXMLQuery as InsecureXml
private import semmle.code.csharp.security.Sanitizers private import semmle.code.csharp.security.Sanitizers
/** /**
@@ -32,7 +32,7 @@ private class InsecureXmlSink extends Sink {
private string reason; private string reason;
InsecureXmlSink() { InsecureXmlSink() {
exists(InsecureXML::InsecureXmlProcessing r | r.isUnsafe(reason) | exists(InsecureXml::InsecureXmlProcessing r | r.isUnsafe(reason) |
this.getExpr() = r.getAnArgument() this.getExpr() = r.getAnArgument()
) )
} }

View File

@@ -13,7 +13,7 @@
import csharp import csharp
from XMLAttribute a from XmlAttribute a
where where
a.getName().toLowerCase() = "password" and a.getValue() = "" a.getName().toLowerCase() = "password" and a.getValue() = ""
or or

View File

@@ -14,7 +14,7 @@
import csharp import csharp
from XMLAttribute a from XmlAttribute a
where where
a.getName().toLowerCase() = "password" and not a.getValue() = "" a.getName().toLowerCase() = "password" and not a.getValue() = ""
or or

View File

@@ -17,7 +17,7 @@
import csharp import csharp
import semmle.code.asp.WebConfig import semmle.code.asp.WebConfig
from SystemWebXmlElement web, XMLAttribute debugAttribute from SystemWebXmlElement web, XmlAttribute debugAttribute
where where
debugAttribute = web.getAChild("compilation").getAttribute("debug") and debugAttribute = web.getAChild("compilation").getAttribute("debug") and
not debugAttribute.getValue().toLowerCase() = "false" not debugAttribute.getValue().toLowerCase() = "false"

View File

@@ -14,7 +14,7 @@
import csharp import csharp
import semmle.code.asp.WebConfig import semmle.code.asp.WebConfig
from SystemWebXmlElement web, XMLAttribute maxReqLength from SystemWebXmlElement web, XmlAttribute maxReqLength
where where
maxReqLength = maxReqLength =
web.getAChild(any(string s | s.toLowerCase() = "httpruntime")) web.getAChild(any(string s | s.toLowerCase() = "httpruntime"))

View File

@@ -13,7 +13,7 @@
import csharp import csharp
import semmle.code.asp.WebConfig import semmle.code.asp.WebConfig
from SystemWebXmlElement web, XMLAttribute requestvalidateAttribute from SystemWebXmlElement web, XmlAttribute requestvalidateAttribute
where where
requestvalidateAttribute = web.getAChild("pages").getAttribute("validateRequest") and requestvalidateAttribute = web.getAChild("pages").getAttribute("validateRequest") and
requestvalidateAttribute.getValue().toLowerCase() = "false" requestvalidateAttribute.getValue().toLowerCase() = "false"

View File

@@ -13,7 +13,7 @@
import csharp import csharp
from XMLAttribute reqValidationMode from XmlAttribute reqValidationMode
where where
reqValidationMode.getName().toLowerCase() = "requestvalidationmode" and reqValidationMode.getName().toLowerCase() = "requestvalidationmode" and
reqValidationMode.getValue().toFloat() < 4.5 reqValidationMode.getValue().toFloat() < 4.5

View File

@@ -13,7 +13,7 @@
import csharp import csharp
import semmle.code.asp.WebConfig import semmle.code.asp.WebConfig
from SystemWebServerXmlElement ws, XMLAttribute a from SystemWebServerXmlElement ws, XmlAttribute a
where where
ws.getAChild("directoryBrowse").getAttribute("enabled") = a and ws.getAChild("directoryBrowse").getAttribute("enabled") = a and
a.getValue() = "true" a.getValue() = "true"

View File

@@ -19,7 +19,7 @@ import semmle.code.csharp.frameworks.system.Web
// the query is a subset of `cs/web/cookie-secure-not-set` and // the query is a subset of `cs/web/cookie-secure-not-set` and
// should be removed once it is promoted from experimental // should be removed once it is promoted from experimental
from XMLElement element from XmlElement element
where where
element instanceof FormsElement and element instanceof FormsElement and
not element.(FormsElement).isRequireSSL() not element.(FormsElement).isRequireSSL()

View File

@@ -27,7 +27,7 @@ where
) )
or or
// header checking is disabled in a configuration file // header checking is disabled in a configuration file
exists(HttpRuntimeXmlElement e, XMLAttribute a | exists(HttpRuntimeXmlElement e, XmlAttribute a |
a = e.getAttribute("enableHeaderChecking") and a = e.getAttribute("enableHeaderChecking") and
a.getValue().toLowerCase() = "false" and a.getValue().toLowerCase() = "false" and
a = l a = l

View File

@@ -109,7 +109,7 @@ where
// the property wasn't explicitly set, so a default value from config is used // the property wasn't explicitly set, so a default value from config is used
not isPropertySet(oc, "HttpOnly") and not isPropertySet(oc, "HttpOnly") and
// the default in config is not set to `true` // the default in config is not set to `true`
not exists(XMLElement element | not exists(XmlElement element |
element instanceof HttpCookiesElement and element instanceof HttpCookiesElement and
element.(HttpCookiesElement).isHttpOnlyCookies() element.(HttpCookiesElement).isHttpOnlyCookies()
) )

View File

@@ -64,7 +64,7 @@ where
not isPropertySet(oc, "Secure") and not isPropertySet(oc, "Secure") and
// the default in config is not set to `true` // the default in config is not set to `true`
// the `exists` below covers the `cs/web/requiressl-not-set` // the `exists` below covers the `cs/web/requiressl-not-set`
not exists(XMLElement element | not exists(XmlElement element |
element instanceof FormsElement and element instanceof FormsElement and
element.(FormsElement).isRequireSSL() element.(FormsElement).isRequireSSL()
or or

View File

@@ -6,5 +6,5 @@ where
// TypeBound doesn't extend Top (but probably should); part of Kotlin #6 // TypeBound doesn't extend Top (but probably should); part of Kotlin #6
not t instanceof TypeBound and not t instanceof TypeBound and
// XMLLocatable doesn't extend Top (but probably should); part of Kotlin #6 // XMLLocatable doesn't extend Top (but probably should); part of Kotlin #6
not t instanceof XMLLocatable not t instanceof XmlLocatable
select t, concat(t.getAPrimaryQlClass(), ",") select t, concat(t.getAPrimaryQlClass(), ",")

View File

@@ -26,7 +26,7 @@ Location backwardsLocation() {
// least to locate a `File`, so such a location does end up with a single use. // least to locate a `File`, so such a location does end up with a single use.
Location unusedLocation() { Location unusedLocation() {
not exists(Top t | t.getLocation() = result) and not exists(Top t | t.getLocation() = result) and
not exists(XMLLocatable x | x.getLocation() = result) and not exists(XmlLocatable x | x.getLocation() = result) and
not exists(ConfigLocatable c | c.getLocation() = result) and not exists(ConfigLocatable c | c.getLocation() = result) and
not exists(Diagnostic d | d.getLocation() = result) and not exists(Diagnostic d | d.getLocation() = result) and
not ( not (

View File

@@ -7,7 +7,7 @@ string topToString(Top t) {
result = t.(TypeBound).toString() result = t.(TypeBound).toString()
or or
// XMLLocatable doesn't extend Top (but probably should); part of Kotlin #6 // XMLLocatable doesn't extend Top (but probably should); part of Kotlin #6
result = t.(XMLLocatable).toString() result = t.(XmlLocatable).toString()
or or
// Java #142 // Java #142
t instanceof FieldDeclaration and not exists(t.toString()) and result = "<FieldDeclaration>" t instanceof FieldDeclaration and not exists(t.toString()) and result = "<FieldDeclaration>"

View File

@@ -33,7 +33,7 @@ predicate referencedInXmlFile(Field f) {
* Gets an XML element with an attribute whose value is the name of `f`, * Gets an XML element with an attribute whose value is the name of `f`,
* suggesting that it might reference `f`. * suggesting that it might reference `f`.
*/ */
private XMLElement elementReferencingField(Field f) { private XmlElement elementReferencingField(Field f) {
exists(elementReferencingType(f.getDeclaringType())) and exists(elementReferencingType(f.getDeclaringType())) and
result.getAnAttribute().getValue() = f.getName() result.getAnAttribute().getValue() = f.getName()
} }
@@ -42,7 +42,7 @@ private XMLElement elementReferencingField(Field f) {
* Gets an XML element with an attribute whose value is the fully qualified * Gets an XML element with an attribute whose value is the fully qualified
* name of `rt`, suggesting that it might reference `rt`. * name of `rt`, suggesting that it might reference `rt`.
*/ */
private XMLElement elementReferencingType(RefType rt) { private XmlElement elementReferencingType(RefType rt) {
result.getAnAttribute().getValue() = rt.getSourceDeclaration().getQualifiedName() result.getAnAttribute().getValue() = rt.getSourceDeclaration().getQualifiedName()
} }

View File

@@ -430,7 +430,7 @@ class PersistenceCallbackMethod extends CallableEntryPoint {
class ArbitraryXmlEntryPoint extends ReflectivelyConstructedClass { class ArbitraryXmlEntryPoint extends ReflectivelyConstructedClass {
ArbitraryXmlEntryPoint() { ArbitraryXmlEntryPoint() {
this.fromSource() and this.fromSource() and
exists(XMLAttribute attribute | exists(XmlAttribute attribute |
attribute.getName() = "className" or attribute.getName() = "className" or
attribute.getName().matches("%ClassName") or attribute.getName().matches("%ClassName") or
attribute.getName() = "class" or attribute.getName() = "class" or

View File

@@ -5,7 +5,7 @@
import java import java
/** A GWT UiBinder XML template file with a `.ui.xml` suffix. */ /** A GWT UiBinder XML template file with a `.ui.xml` suffix. */
class GwtUiTemplateXmlFile extends XMLFile { class GwtUiTemplateXmlFile extends XmlFile {
GwtUiTemplateXmlFile() { this.getBaseName().matches("%.ui.xml") } GwtUiTemplateXmlFile() { this.getBaseName().matches("%.ui.xml") }
/** Gets the top-level UiBinder element. */ /** Gets the top-level UiBinder element. */
@@ -13,7 +13,7 @@ class GwtUiTemplateXmlFile extends XMLFile {
} }
/** The top-level `<ui:UiBinder>` element of a GWT UiBinder template XML file. */ /** The top-level `<ui:UiBinder>` element of a GWT UiBinder template XML file. */
class GwtUiBinderTemplateElement extends XMLElement { class GwtUiBinderTemplateElement extends XmlElement {
GwtUiBinderTemplateElement() { GwtUiBinderTemplateElement() {
this.getParent() instanceof GwtUiTemplateXmlFile and this.getParent() instanceof GwtUiTemplateXmlFile and
this.getName() = "UiBinder" and this.getName() = "UiBinder" and
@@ -24,7 +24,7 @@ class GwtUiBinderTemplateElement extends XMLElement {
/** /**
* A component reference within a GWT UiBinder template. * A component reference within a GWT UiBinder template.
*/ */
class GwtComponentTemplateElement extends XMLElement { class GwtComponentTemplateElement extends XmlElement {
GwtComponentTemplateElement() { GwtComponentTemplateElement() {
exists(GwtUiBinderTemplateElement templateElement | this = templateElement.getAChild*() | exists(GwtUiBinderTemplateElement templateElement | this = templateElement.getAChild*() |
this.getNamespace().getURI().substring(0, 10) = "urn:import" this.getNamespace().getURI().substring(0, 10) = "urn:import"

View File

@@ -8,7 +8,7 @@ import semmle.code.xml.XML
predicate isGwtXmlIncluded() { exists(GwtXmlFile webXml) } predicate isGwtXmlIncluded() { exists(GwtXmlFile webXml) }
/** A GWT module XML file with a `.gwt.xml` suffix. */ /** A GWT module XML file with a `.gwt.xml` suffix. */
class GwtXmlFile extends XMLFile { class GwtXmlFile extends XmlFile {
GwtXmlFile() { this.getBaseName().matches("%.gwt.xml") } GwtXmlFile() { this.getBaseName().matches("%.gwt.xml") }
/** Gets the top-level module element of a GWT module XML file. */ /** Gets the top-level module element of a GWT module XML file. */
@@ -57,7 +57,7 @@ class GwtXmlFile extends XMLFile {
} }
/** The top-level `<module>` element of a GWT module XML file. */ /** The top-level `<module>` element of a GWT module XML file. */
class GwtModuleElement extends XMLElement { class GwtModuleElement extends XmlElement {
GwtModuleElement() { GwtModuleElement() {
this.getParent() instanceof GwtXmlFile and this.getParent() instanceof GwtXmlFile and
this.getName() = "module" this.getName() = "module"
@@ -74,7 +74,7 @@ class GwtModuleElement extends XMLElement {
} }
/** An `<inherits>` element within a GWT module XML file. */ /** An `<inherits>` element within a GWT module XML file. */
class GwtInheritsElement extends XMLElement { class GwtInheritsElement extends XmlElement {
GwtInheritsElement() { GwtInheritsElement() {
this.getParent() instanceof GwtModuleElement and this.getParent() instanceof GwtModuleElement and
this.getName() = "inherits" this.getName() = "inherits"
@@ -85,7 +85,7 @@ class GwtInheritsElement extends XMLElement {
} }
/** An `<entry-point>` element within a GWT module XML file. */ /** An `<entry-point>` element within a GWT module XML file. */
class GwtEntryPointElement extends XMLElement { class GwtEntryPointElement extends XmlElement {
GwtEntryPointElement() { GwtEntryPointElement() {
this.getParent() instanceof GwtModuleElement and this.getParent() instanceof GwtModuleElement and
this.getName() = "entry-point" this.getName() = "entry-point"
@@ -96,7 +96,7 @@ class GwtEntryPointElement extends XMLElement {
} }
/** A `<source>` element within a GWT module XML file. */ /** A `<source>` element within a GWT module XML file. */
class GwtSourceElement extends XMLElement { class GwtSourceElement extends XmlElement {
GwtSourceElement() { GwtSourceElement() {
this.getParent() instanceof GwtModuleElement and this.getParent() instanceof GwtModuleElement and
this.getName() = "source" this.getName() = "source"
@@ -113,7 +113,7 @@ class GwtSourceElement extends XMLElement {
} }
/** A `<servlet>` element within a GWT module XML file. */ /** A `<servlet>` element within a GWT module XML file. */
class GwtServletElement extends XMLElement { class GwtServletElement extends XmlElement {
GwtServletElement() { GwtServletElement() {
this.getParent() instanceof GwtModuleElement and this.getParent() instanceof GwtModuleElement and
this.getName() = "servlet" this.getName() = "servlet"

View File

@@ -8,7 +8,7 @@ import java
/** /**
* A JavaEE persistence configuration XML file (persistence.xml). * A JavaEE persistence configuration XML file (persistence.xml).
*/ */
class PersistenceXmlFile extends XMLFile { class PersistenceXmlFile extends XmlFile {
PersistenceXmlFile() { this.getStem() = "persistence" } PersistenceXmlFile() { this.getStem() = "persistence" }
/** Gets the root XML element in this `persistence.xml` file. */ /** Gets the root XML element in this `persistence.xml` file. */
@@ -30,7 +30,7 @@ class PersistenceXmlFile extends XMLFile {
deprecated class PersistenceXMLFile = PersistenceXmlFile; deprecated class PersistenceXMLFile = PersistenceXmlFile;
/** The root `persistence` XML element in a `persistence.xml` file. */ /** The root `persistence` XML element in a `persistence.xml` file. */
class PersistenceXmlRoot extends XMLElement { class PersistenceXmlRoot extends XmlElement {
PersistenceXmlRoot() { PersistenceXmlRoot() {
this.getParent() instanceof PersistenceXmlFile and this.getParent() instanceof PersistenceXmlFile and
this.getName() = "persistence" this.getName() = "persistence"
@@ -44,7 +44,7 @@ class PersistenceXmlRoot extends XMLElement {
* A `persistence-unit` child XML element of the root * A `persistence-unit` child XML element of the root
* `persistence` XML element in a `persistence.xml` file. * `persistence` XML element in a `persistence.xml` file.
*/ */
class PersistenceUnitElement extends XMLElement { class PersistenceUnitElement extends XmlElement {
PersistenceUnitElement() { PersistenceUnitElement() {
this.getParent() instanceof PersistenceXmlRoot and this.getParent() instanceof PersistenceXmlRoot and
this.getName() = "persistence-unit" this.getName() = "persistence-unit"
@@ -61,7 +61,7 @@ class PersistenceUnitElement extends XMLElement {
* A `shared-cache-mode` child XML element of a `persistence-unit` * A `shared-cache-mode` child XML element of a `persistence-unit`
* XML element in a `persistence.xml` file. * XML element in a `persistence.xml` file.
*/ */
class SharedCacheModeElement extends XMLElement { class SharedCacheModeElement extends XmlElement {
SharedCacheModeElement() { SharedCacheModeElement() {
this.getParent() instanceof PersistenceUnitElement and this.getParent() instanceof PersistenceUnitElement and
this.getName() = "shared-cache-mode" this.getName() = "shared-cache-mode"
@@ -78,7 +78,7 @@ class SharedCacheModeElement extends XMLElement {
* A `properties` child XML element of a `persistence-unit` * A `properties` child XML element of a `persistence-unit`
* XML element in a `persistence.xml` file. * XML element in a `persistence.xml` file.
*/ */
class PersistencePropertiesElement extends XMLElement { class PersistencePropertiesElement extends XmlElement {
PersistencePropertiesElement() { PersistencePropertiesElement() {
this.getParent() instanceof PersistenceUnitElement and this.getParent() instanceof PersistenceUnitElement and
this.getName() = "properties" this.getName() = "properties"
@@ -92,7 +92,7 @@ class PersistencePropertiesElement extends XMLElement {
* A `property` child XML element of a `properties` * A `property` child XML element of a `properties`
* XML element in a `persistence.xml` file. * XML element in a `persistence.xml` file.
*/ */
class PersistencePropertyElement extends XMLElement { class PersistencePropertyElement extends XmlElement {
PersistencePropertyElement() { PersistencePropertyElement() {
this.getParent() instanceof PersistencePropertiesElement and this.getParent() instanceof PersistencePropertiesElement and
this.getName() = "property" this.getName() = "property"

View File

@@ -8,7 +8,7 @@ import java
/** /**
* An EJB deployment descriptor XML file named `ejb-jar.xml`. * An EJB deployment descriptor XML file named `ejb-jar.xml`.
*/ */
class EjbJarXmlFile extends XMLFile { class EjbJarXmlFile extends XmlFile {
EjbJarXmlFile() { this.getStem() = "ejb-jar" } EjbJarXmlFile() { this.getStem() = "ejb-jar" }
/** Gets the root `ejb-jar` XML element of this `ejb-jar.xml` file. */ /** Gets the root `ejb-jar` XML element of this `ejb-jar.xml` file. */
@@ -39,7 +39,7 @@ class EjbJarXmlFile extends XMLFile {
deprecated class EjbJarXMLFile = EjbJarXmlFile; deprecated class EjbJarXMLFile = EjbJarXmlFile;
/** The root `ejb-jar` XML element in an `ejb-jar.xml` file. */ /** The root `ejb-jar` XML element in an `ejb-jar.xml` file. */
class EjbJarRootElement extends XMLElement { class EjbJarRootElement extends XmlElement {
EjbJarRootElement() { EjbJarRootElement() {
this.getParent() instanceof EjbJarXmlFile and this.getParent() instanceof EjbJarXmlFile and
this.getName() = "ejb-jar" this.getName() = "ejb-jar"
@@ -53,7 +53,7 @@ class EjbJarRootElement extends XMLElement {
* An `enterprise-beans` child XML element of the root * An `enterprise-beans` child XML element of the root
* `ejb-jar` XML element in an `ejb-jar.xml` file. * `ejb-jar` XML element in an `ejb-jar.xml` file.
*/ */
class EjbJarEnterpriseBeansElement extends XMLElement { class EjbJarEnterpriseBeansElement extends XmlElement {
EjbJarEnterpriseBeansElement() { EjbJarEnterpriseBeansElement() {
this.getParent() instanceof EjbJarRootElement and this.getParent() instanceof EjbJarRootElement and
this.getName() = "enterprise-beans" this.getName() = "enterprise-beans"
@@ -83,11 +83,11 @@ class EjbJarEnterpriseBeansElement extends XMLElement {
* *
* This is either a `message-driven` element, a `session` element, or an `entity` element. * This is either a `message-driven` element, a `session` element, or an `entity` element.
*/ */
abstract class EjbJarBeanTypeElement extends XMLElement { abstract class EjbJarBeanTypeElement extends XmlElement {
EjbJarBeanTypeElement() { this.getParent() instanceof EjbJarEnterpriseBeansElement } EjbJarBeanTypeElement() { this.getParent() instanceof EjbJarEnterpriseBeansElement }
/** Gets an `ejb-class` child XML element of this bean type element. */ /** Gets an `ejb-class` child XML element of this bean type element. */
XMLElement getAnEjbClassElement() { XmlElement getAnEjbClassElement() {
result = this.getAChild() and result = this.getAChild() and
result.getName() = "ejb-class" result.getName() = "ejb-class"
} }
@@ -100,13 +100,13 @@ class EjbJarSessionElement extends EjbJarBeanTypeElement {
EjbJarSessionElement() { this.getName() = "session" } EjbJarSessionElement() { this.getName() = "session" }
/** Gets a `business-local` child XML element of this `session` XML element. */ /** Gets a `business-local` child XML element of this `session` XML element. */
XMLElement getABusinessLocalElement() { XmlElement getABusinessLocalElement() {
result = this.getAChild() and result = this.getAChild() and
result.getName() = "business-local" result.getName() = "business-local"
} }
/** Gets a `business-remote` child XML element of this `session` XML element. */ /** Gets a `business-remote` child XML element of this `session` XML element. */
XMLElement getABusinessRemoteElement() { XmlElement getABusinessRemoteElement() {
result = this.getAChild() and result = this.getAChild() and
result.getName() = "business-remote" result.getName() = "business-remote"
} }
@@ -116,31 +116,31 @@ class EjbJarSessionElement extends EjbJarBeanTypeElement {
* *
* This is either a `business-local` or `business-remote` element. * This is either a `business-local` or `business-remote` element.
*/ */
XMLElement getABusinessElement() { XmlElement getABusinessElement() {
result = this.getABusinessLocalElement() or result = this.getABusinessLocalElement() or
result = this.getABusinessRemoteElement() result = this.getABusinessRemoteElement()
} }
/** Gets a `remote` child XML element of this `session` XML element. */ /** Gets a `remote` child XML element of this `session` XML element. */
XMLElement getARemoteElement() { XmlElement getARemoteElement() {
result = this.getAChild() and result = this.getAChild() and
result.getName() = "remote" result.getName() = "remote"
} }
/** Gets a `home` child XML element of this `session` XML element. */ /** Gets a `home` child XML element of this `session` XML element. */
XMLElement getARemoteHomeElement() { XmlElement getARemoteHomeElement() {
result = this.getAChild() and result = this.getAChild() and
result.getName() = "home" result.getName() = "home"
} }
/** Gets a `local` child XML element of this `session` XML element. */ /** Gets a `local` child XML element of this `session` XML element. */
XMLElement getALocalElement() { XmlElement getALocalElement() {
result = this.getAChild() and result = this.getAChild() and
result.getName() = "local" result.getName() = "local"
} }
/** Gets a `local-home` child XML element of this `session` XML element. */ /** Gets a `local-home` child XML element of this `session` XML element. */
XMLElement getALocalHomeElement() { XmlElement getALocalHomeElement() {
result = this.getAChild() and result = this.getAChild() and
result.getName() = "local-home" result.getName() = "local-home"
} }
@@ -155,7 +155,7 @@ class EjbJarSessionElement extends EjbJarBeanTypeElement {
* Gets a `method-name` child XML element of a `create-method` * Gets a `method-name` child XML element of a `create-method`
* XML element nested within this `session` XML element. * XML element nested within this `session` XML element.
*/ */
XMLElement getACreateMethodNameElement() { XmlElement getACreateMethodNameElement() {
result = this.getAnInitMethodElement().getACreateMethodElement().getAMethodNameElement() result = this.getAnInitMethodElement().getACreateMethodElement().getAMethodNameElement()
} }
@@ -163,7 +163,7 @@ class EjbJarSessionElement extends EjbJarBeanTypeElement {
* Gets a `method-name` child XML element of a `bean-method` * Gets a `method-name` child XML element of a `bean-method`
* XML element nested within this `session` XML element. * XML element nested within this `session` XML element.
*/ */
XMLElement getABeanMethodNameElement() { XmlElement getABeanMethodNameElement() {
result = this.getAnInitMethodElement().getABeanMethodElement().getAMethodNameElement() result = this.getAnInitMethodElement().getABeanMethodElement().getAMethodNameElement()
} }
} }
@@ -183,7 +183,7 @@ class EjbJarEntityElement extends EjbJarBeanTypeElement {
} }
/** A `session-type` child XML element of a `session` element in an `ejb-jar.xml` file. */ /** A `session-type` child XML element of a `session` element in an `ejb-jar.xml` file. */
class EjbJarSessionTypeElement extends XMLElement { class EjbJarSessionTypeElement extends XmlElement {
EjbJarSessionTypeElement() { EjbJarSessionTypeElement() {
this.getParent() instanceof EjbJarSessionElement and this.getParent() instanceof EjbJarSessionElement and
this.getName() = "session-type" this.getName() = "session-type"
@@ -197,7 +197,7 @@ class EjbJarSessionTypeElement extends XMLElement {
} }
/** An `init-method` child XML element of a `session` element in an `ejb-jar.xml` file. */ /** An `init-method` child XML element of a `session` element in an `ejb-jar.xml` file. */
class EjbJarInitMethodElement extends XMLElement { class EjbJarInitMethodElement extends XmlElement {
EjbJarInitMethodElement() { EjbJarInitMethodElement() {
this.getParent() instanceof EjbJarSessionElement and this.getParent() instanceof EjbJarSessionElement and
this.getName() = "init-method" this.getName() = "init-method"
@@ -221,9 +221,9 @@ class EjbJarInitMethodElement extends XMLElement {
* *
* This is either a `create-method` element, or a `bean-method` element. * This is either a `create-method` element, or a `bean-method` element.
*/ */
abstract class EjbJarInitMethodChildElement extends XMLElement { abstract class EjbJarInitMethodChildElement extends XmlElement {
/** Gets a `method-name` child XML element of this `create-method` or `bean-method` XML element. */ /** Gets a `method-name` child XML element of this `create-method` or `bean-method` XML element. */
XMLElement getAMethodNameElement() { XmlElement getAMethodNameElement() {
result = this.getAChild() and result = this.getAChild() and
result.getName() = "method-name" result.getName() = "method-name"
} }

View File

@@ -8,10 +8,10 @@ import default
* A JSF "application configuration resources file", typically called `faces-config.xml`, which * A JSF "application configuration resources file", typically called `faces-config.xml`, which
* contains the configuration for a JSF application * contains the configuration for a JSF application
*/ */
class FacesConfigXmlFile extends XMLFile { class FacesConfigXmlFile extends XmlFile {
FacesConfigXmlFile() { FacesConfigXmlFile() {
// Contains a single top-level XML node named "faces-Config". // Contains a single top-level XML node named "faces-Config".
count(XMLElement e | e = this.getAChild()) = 1 and count(XmlElement e | e = this.getAChild()) = 1 and
this.getAChild().getName() = "faces-config" this.getAChild().getName() = "faces-config"
} }
} }
@@ -22,7 +22,7 @@ deprecated class FacesConfigXMLFile = FacesConfigXmlFile;
/** /**
* An XML element in a `FacesConfigXMLFile`. * An XML element in a `FacesConfigXMLFile`.
*/ */
class FacesConfigXmlElement extends XMLElement { class FacesConfigXmlElement extends XmlElement {
FacesConfigXmlElement() { this.getFile() instanceof FacesConfigXmlFile } FacesConfigXmlElement() { this.getFile() instanceof FacesConfigXmlFile }
/** /**

View File

@@ -57,7 +57,7 @@ class SpringBean extends SpringXmlElement {
/** Holds if the bean is abstract. */ /** Holds if the bean is abstract. */
predicate isAbstract() { predicate isAbstract() {
exists(XMLAttribute a | exists(XmlAttribute a |
a = this.getAttribute("abstract") and a = this.getAttribute("abstract") and
a.getValue() = "true" a.getValue() = "true"
) )
@@ -255,7 +255,7 @@ class SpringBean extends SpringXmlElement {
/** Holds if the bean has been declared to be a `primary` bean for autowiring. */ /** Holds if the bean has been declared to be a `primary` bean for autowiring. */
predicate isPrimary() { predicate isPrimary() {
exists(XMLAttribute a | a = this.getAttribute("primary") and a.getValue() = "true") exists(XmlAttribute a | a = this.getAttribute("primary") and a.getValue() = "true")
} }
/** Gets the scope of the bean. */ /** Gets the scope of the bean. */

View File

@@ -6,9 +6,9 @@ import semmle.code.java.frameworks.spring.SpringBean
* *
* This class includes methods to access attributes of the `<beans>` element. * This class includes methods to access attributes of the `<beans>` element.
*/ */
class SpringBeanFile extends XMLFile { class SpringBeanFile extends XmlFile {
SpringBeanFile() { SpringBeanFile() {
count(XMLElement e | e = this.getAChild()) = 1 and count(XmlElement e | e = this.getAChild()) = 1 and
this.getAChild().getName() = "beans" this.getAChild().getName() = "beans"
} }
@@ -24,7 +24,7 @@ class SpringBeanFile extends XMLFile {
SpringBean getABean() { exists(SpringBean b | b.getFile() = this and result = b) } SpringBean getABean() { exists(SpringBean b | b.getFile() = this and result = b) }
/** Gets the `<beans>` element of the file. */ /** Gets the `<beans>` element of the file. */
XMLElement getBeansElement() { XmlElement getBeansElement() {
result = this.getAChild() and result = this.getAChild() and
result.getName() = "beans" result.getName() = "beans"
} }
@@ -85,7 +85,7 @@ class SpringBeanFile extends XMLFile {
/** Holds if `default-lazy-init` is specified to be `true` for this file. */ /** Holds if `default-lazy-init` is specified to be `true` for this file. */
predicate isDefaultLazyInit() { predicate isDefaultLazyInit() {
exists(XMLAttribute a | exists(XmlAttribute a |
this.getBeansElement().getAttribute("default-lazy-init") = a and this.getBeansElement().getAttribute("default-lazy-init") = a and
a.getValue() = "true" a.getValue() = "true"
) )
@@ -93,7 +93,7 @@ class SpringBeanFile extends XMLFile {
/** Holds if `default-merge` is specified to be `true` for this file. */ /** Holds if `default-merge` is specified to be `true` for this file. */
predicate isDefaultMerge() { predicate isDefaultMerge() {
exists(XMLAttribute a | exists(XmlAttribute a |
this.getBeansElement().getAttribute("default-merge") = a and this.getBeansElement().getAttribute("default-merge") = a and
a.getValue() = "true" a.getValue() = "true"
) )

View File

@@ -3,7 +3,7 @@ import semmle.code.java.frameworks.spring.SpringBeanFile
import semmle.code.java.frameworks.spring.SpringBean import semmle.code.java.frameworks.spring.SpringBean
/** A common superclass for all Spring XML elements. */ /** A common superclass for all Spring XML elements. */
class SpringXmlElement extends XMLElement { class SpringXmlElement extends XmlElement {
SpringXmlElement() { this.getFile() instanceof SpringBeanFile } SpringXmlElement() { this.getFile() instanceof SpringBeanFile }
/** Gets a child of this Spring XML element. */ /** Gets a child of this Spring XML element. */

View File

@@ -16,7 +16,7 @@ class Struts2ActionClass extends Class {
Struts2ActionClass() { Struts2ActionClass() {
// If there are no XML files present, then we assume we any class that extends a struts 2 // If there are no XML files present, then we assume we any class that extends a struts 2
// action must be reflectively constructed, as we have no better indication. // action must be reflectively constructed, as we have no better indication.
not exists(XMLFile xmlFile) and not exists(XmlFile xmlFile) and
this.getAnAncestor().hasQualifiedName("com.opensymphony.xwork2", "Action") this.getAnAncestor().hasQualifiedName("com.opensymphony.xwork2", "Action")
or or
// If there is a struts.xml file, then any class that is specified as an action is considered // If there is a struts.xml file, then any class that is specified as an action is considered
@@ -72,7 +72,7 @@ class Struts2ActionClass extends Class {
result = this.(Struts2ConventionActionClass).getAnActionMethod() result = this.(Struts2ConventionActionClass).getAnActionMethod()
or or
// In the fall-back case, use both the "execute" and any annotated methods // In the fall-back case, use both the "execute" and any annotated methods
not exists(XMLFile xmlFile) and not exists(XmlFile xmlFile) and
( (
result.hasName("executes") or result.hasName("executes") or
exists(StrutsActionAnnotation actionAnnotation | exists(StrutsActionAnnotation actionAnnotation |

View File

@@ -11,10 +11,10 @@ deprecated predicate isStrutsXMLIncluded = isStrutsXmlIncluded/0;
/** /**
* A struts 2 configuration file. * A struts 2 configuration file.
*/ */
abstract class StrutsXmlFile extends XMLFile { abstract class StrutsXmlFile extends XmlFile {
StrutsXmlFile() { StrutsXmlFile() {
// Contains a single top-level XML node named "struts". // Contains a single top-level XML node named "struts".
count(XMLElement e | e = this.getAChild()) = 1 and count(XmlElement e | e = this.getAChild()) = 1 and
this.getAChild().getName() = "struts" this.getAChild().getName() = "struts"
} }
@@ -107,7 +107,7 @@ class StrutsFolder extends Folder {
/** /**
* An XML element in a `StrutsXMLFile`. * An XML element in a `StrutsXMLFile`.
*/ */
class StrutsXmlElement extends XMLElement { class StrutsXmlElement extends XmlElement {
StrutsXmlElement() { this.getFile() instanceof StrutsXmlFile } StrutsXmlElement() { this.getFile() instanceof StrutsXmlFile }
/** /**
@@ -134,7 +134,7 @@ class StrutsXmlInclude extends StrutsXmlElement {
* We have no notion of classpath, so we assume that any file that matches the path could * We have no notion of classpath, so we assume that any file that matches the path could
* potentially be included. * potentially be included.
*/ */
XMLFile getIncludedFile() { XmlFile getIncludedFile() {
exists(string file | file = this.getAttribute("file").getValue() | exists(string file | file = this.getAttribute("file").getValue() |
result.getAbsolutePath().matches("%" + escapeForMatch(file)) result.getAbsolutePath().matches("%" + escapeForMatch(file))
) )

View File

@@ -7,10 +7,10 @@ import XML
/** /**
* An Android manifest file, named `AndroidManifest.xml`. * An Android manifest file, named `AndroidManifest.xml`.
*/ */
class AndroidManifestXmlFile extends XMLFile { class AndroidManifestXmlFile extends XmlFile {
AndroidManifestXmlFile() { AndroidManifestXmlFile() {
this.getBaseName() = "AndroidManifest.xml" and this.getBaseName() = "AndroidManifest.xml" and
count(XMLElement e | e = this.getAChild()) = 1 and count(XmlElement e | e = this.getAChild()) = 1 and
this.getAChild().getName() = "manifest" this.getAChild().getName() = "manifest"
} }
@@ -28,7 +28,7 @@ class AndroidManifestXmlFile extends XMLFile {
/** /**
* A `<manifest>` element in an Android manifest file. * A `<manifest>` element in an Android manifest file.
*/ */
class AndroidManifestXmlElement extends XMLElement { class AndroidManifestXmlElement extends XmlElement {
AndroidManifestXmlElement() { AndroidManifestXmlElement() {
this.getParent() instanceof AndroidManifestXmlFile and this.getName() = "manifest" this.getParent() instanceof AndroidManifestXmlFile and this.getName() = "manifest"
} }
@@ -47,7 +47,7 @@ class AndroidManifestXmlElement extends XMLElement {
/** /**
* An `<application>` element in an Android manifest file. * An `<application>` element in an Android manifest file.
*/ */
class AndroidApplicationXmlElement extends XMLElement { class AndroidApplicationXmlElement extends XmlElement {
AndroidApplicationXmlElement() { AndroidApplicationXmlElement() {
this.getParent() instanceof AndroidManifestXmlElement and this.getName() = "application" this.getParent() instanceof AndroidManifestXmlElement and this.getName() = "application"
} }
@@ -93,7 +93,7 @@ class AndroidReceiverXmlElement extends AndroidComponentXmlElement {
/** /**
* An XML attribute with the `android:` prefix. * An XML attribute with the `android:` prefix.
*/ */
class AndroidXmlAttribute extends XMLAttribute { class AndroidXmlAttribute extends XmlAttribute {
AndroidXmlAttribute() { this.getNamespace().getPrefix() = "android" } AndroidXmlAttribute() { this.getNamespace().getPrefix() = "android" }
} }
@@ -130,7 +130,7 @@ class AndroidProviderXmlElement extends AndroidComponentXmlElement {
/** /**
* The attribute `android:perrmission`, `android:readPermission`, or `android:writePermission`. * The attribute `android:perrmission`, `android:readPermission`, or `android:writePermission`.
*/ */
class AndroidPermissionXmlAttribute extends XMLAttribute { class AndroidPermissionXmlAttribute extends XmlAttribute {
AndroidPermissionXmlAttribute() { AndroidPermissionXmlAttribute() {
this.getNamespace().getPrefix() = "android" and this.getNamespace().getPrefix() = "android" and
this.getName() = ["permission", "readPermission", "writePermission"] this.getName() = ["permission", "readPermission", "writePermission"]
@@ -149,7 +149,7 @@ class AndroidPermissionXmlAttribute extends XMLAttribute {
/** /**
* The `<path-permission`> element of a `<provider>` in an Android manifest file. * The `<path-permission`> element of a `<provider>` in an Android manifest file.
*/ */
class AndroidPathPermissionXmlElement extends XMLElement { class AndroidPathPermissionXmlElement extends XmlElement {
AndroidPathPermissionXmlElement() { AndroidPathPermissionXmlElement() {
this.getParent() instanceof AndroidProviderXmlElement and this.getParent() instanceof AndroidProviderXmlElement and
this.hasName("path-permission") this.hasName("path-permission")
@@ -159,7 +159,7 @@ class AndroidPathPermissionXmlElement extends XMLElement {
/** /**
* An Android component element in an Android manifest file. * An Android component element in an Android manifest file.
*/ */
class AndroidComponentXmlElement extends XMLElement { class AndroidComponentXmlElement extends XmlElement {
AndroidComponentXmlElement() { AndroidComponentXmlElement() {
this.getParent() instanceof AndroidApplicationXmlElement and this.getParent() instanceof AndroidApplicationXmlElement and
this.getName().regexpMatch("(activity|service|receiver|provider)") this.getName().regexpMatch("(activity|service|receiver|provider)")
@@ -174,7 +174,7 @@ class AndroidComponentXmlElement extends XMLElement {
* Gets the value of the `android:name` attribute of this component element. * Gets the value of the `android:name` attribute of this component element.
*/ */
string getComponentName() { string getComponentName() {
exists(XMLAttribute attr | exists(XmlAttribute attr |
attr = this.getAnAttribute() and attr = this.getAnAttribute() and
attr.getNamespace().getPrefix() = "android" and attr.getNamespace().getPrefix() = "android" and
attr.getName() = "name" attr.getName() = "name"
@@ -191,7 +191,7 @@ class AndroidComponentXmlElement extends XMLElement {
then then
result = result =
this.getParent() this.getParent()
.(XMLElement) .(XmlElement)
.getParent() .getParent()
.(AndroidManifestXmlElement) .(AndroidManifestXmlElement)
.getPackageAttributeValue() + this.getComponentName() .getPackageAttributeValue() + this.getComponentName()
@@ -202,7 +202,7 @@ class AndroidComponentXmlElement extends XMLElement {
* Gets the value of the `android:exported` attribute of this component element. * Gets the value of the `android:exported` attribute of this component element.
*/ */
string getExportedAttributeValue() { string getExportedAttributeValue() {
exists(XMLAttribute attr | exists(XmlAttribute attr |
attr = this.getAnAttribute() and attr = this.getAnAttribute() and
attr.getNamespace().getPrefix() = "android" and attr.getNamespace().getPrefix() = "android" and
attr.getName() = "exported" attr.getName() = "exported"
@@ -225,7 +225,7 @@ class AndroidComponentXmlElement extends XMLElement {
/** /**
* An `<intent-filter>` element in an Android manifest file. * An `<intent-filter>` element in an Android manifest file.
*/ */
class AndroidIntentFilterXmlElement extends XMLElement { class AndroidIntentFilterXmlElement extends XmlElement {
AndroidIntentFilterXmlElement() { AndroidIntentFilterXmlElement() {
this.getFile() instanceof AndroidManifestXmlFile and this.getName() = "intent-filter" this.getFile() instanceof AndroidManifestXmlFile and this.getName() = "intent-filter"
} }
@@ -239,7 +239,7 @@ class AndroidIntentFilterXmlElement extends XMLElement {
/** /**
* An `<action>` element in an Android manifest file. * An `<action>` element in an Android manifest file.
*/ */
class AndroidActionXmlElement extends XMLElement { class AndroidActionXmlElement extends XmlElement {
AndroidActionXmlElement() { AndroidActionXmlElement() {
this.getFile() instanceof AndroidManifestXmlFile and this.getName() = "action" this.getFile() instanceof AndroidManifestXmlFile and this.getName() = "action"
} }
@@ -248,7 +248,7 @@ class AndroidActionXmlElement extends XMLElement {
* Gets the name of this action. * Gets the name of this action.
*/ */
string getActionName() { string getActionName() {
exists(XMLAttribute attr | exists(XmlAttribute attr |
attr = this.getAnAttribute() and attr = this.getAnAttribute() and
attr.getNamespace().getPrefix() = "android" and attr.getNamespace().getPrefix() = "android" and
attr.getName() = "name" attr.getName() = "name"

View File

@@ -5,7 +5,7 @@
import XML import XML
/** An XML element that represents an Ant target. */ /** An XML element that represents an Ant target. */
class AntTarget extends XMLElement { class AntTarget extends XmlElement {
AntTarget() { super.getName() = "target" } AntTarget() { super.getName() = "target" }
/** Gets the name of this Ant target. */ /** Gets the name of this Ant target. */

View File

@@ -17,7 +17,7 @@ private string normalize(string path) {
* to retrieve child XML elements named "groupId", "artifactId" * to retrieve child XML elements named "groupId", "artifactId"
* and "version", typically contained in Maven POM XML files. * and "version", typically contained in Maven POM XML files.
*/ */
class ProtoPom extends XMLElement { class ProtoPom extends XmlElement {
/** Gets a child XML element named "groupId". */ /** Gets a child XML element named "groupId". */
Group getGroup() { result = this.getAChild() } Group getGroup() { result = this.getAChild() }
@@ -280,7 +280,7 @@ class PomDependency extends Dependency {
* An XML element that provides access to its value string * An XML element that provides access to its value string
* in the context of Maven POM XML files. * in the context of Maven POM XML files.
*/ */
class PomElement extends XMLElement { class PomElement extends XmlElement {
/** /**
* Gets the value associated with this element. If the value contains a placeholder only, it will be resolved. * Gets the value associated with this element. If the value contains a placeholder only, it will be resolved.
*/ */

View File

@@ -11,9 +11,9 @@ deprecated predicate isWebXMLIncluded = isWebXmlIncluded/0;
/** /**
* A deployment descriptor file, typically called `web.xml`. * A deployment descriptor file, typically called `web.xml`.
*/ */
class WebXmlFile extends XMLFile { class WebXmlFile extends XmlFile {
WebXmlFile() { WebXmlFile() {
count(XMLElement e | e = this.getAChild()) = 1 and count(XmlElement e | e = this.getAChild()) = 1 and
this.getAChild().getName() = "web-app" this.getAChild().getName() = "web-app"
} }
@@ -37,7 +37,7 @@ deprecated class WebXMLFile = WebXmlFile;
/** /**
* An XML element in a `WebXMLFile`. * An XML element in a `WebXMLFile`.
*/ */
class WebXmlElement extends XMLElement { class WebXmlElement extends XmlElement {
WebXmlElement() { this.getFile() instanceof WebXmlFile } WebXmlElement() { this.getFile() instanceof WebXmlFile }
/** /**

View File

@@ -8,7 +8,7 @@ private class TXmlLocatable =
@xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters; @xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters;
/** An XML element that has a location. */ /** An XML element that has a location. */
class XMLLocatable extends @xmllocatable, TXmlLocatable { class XmlLocatable extends @xmllocatable, TXmlLocatable {
/** Gets the source location for this element. */ /** Gets the source location for this element. */
Location getLocation() { xmllocations(this, result) } Location getLocation() { xmllocations(this, result) }
@@ -32,12 +32,15 @@ class XMLLocatable extends @xmllocatable, TXmlLocatable {
string toString() { none() } // overridden in subclasses string toString() { none() } // overridden in subclasses
} }
/** DEPRECATED: Alias for XmlLocatable */
deprecated class XMLLocatable = XmlLocatable;
/** /**
* An `XMLParent` is either an `XMLElement` or an `XMLFile`, * An `XMLParent` is either an `XMLElement` or an `XMLFile`,
* both of which can contain other elements. * both of which can contain other elements.
*/ */
class XMLParent extends @xmlparent { class XmlParent extends @xmlparent {
XMLParent() { XmlParent() {
// explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`; // explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`;
// the type `@xmlparent` currently also includes non-XML files // the type `@xmlparent` currently also includes non-XML files
this instanceof @xmlelement or xmlEncoding(this, _) this instanceof @xmlelement or xmlEncoding(this, _)
@@ -50,28 +53,28 @@ class XMLParent extends @xmlparent {
string getName() { none() } // overridden in subclasses string getName() { none() } // overridden in subclasses
/** Gets the file to which this XML parent belongs. */ /** Gets the file to which this XML parent belongs. */
XMLFile getFile() { result = this or xmlElements(this, _, _, _, result) } XmlFile getFile() { result = this or xmlElements(this, _, _, _, result) }
/** Gets the child element at a specified index of this XML parent. */ /** Gets the child element at a specified index of this XML parent. */
XMLElement getChild(int index) { xmlElements(result, _, this, index, _) } XmlElement getChild(int index) { xmlElements(result, _, this, index, _) }
/** Gets a child element of this XML parent. */ /** Gets a child element of this XML parent. */
XMLElement getAChild() { xmlElements(result, _, this, _, _) } XmlElement getAChild() { xmlElements(result, _, this, _, _) }
/** Gets a child element of this XML parent with the given `name`. */ /** Gets a child element of this XML parent with the given `name`. */
XMLElement getAChild(string name) { xmlElements(result, _, this, _, _) and result.hasName(name) } XmlElement getAChild(string name) { xmlElements(result, _, this, _, _) and result.hasName(name) }
/** Gets a comment that is a child of this XML parent. */ /** Gets a comment that is a child of this XML parent. */
XMLComment getAComment() { xmlComments(result, _, this, _) } XmlComment getAComment() { xmlComments(result, _, this, _) }
/** Gets a character sequence that is a child of this XML parent. */ /** Gets a character sequence that is a child of this XML parent. */
XMLCharacters getACharactersSet() { xmlChars(result, _, this, _, _, _) } XmlCharacters getACharactersSet() { xmlChars(result, _, this, _, _, _) }
/** Gets the depth in the tree. (Overridden in XMLElement.) */ /** Gets the depth in the tree. (Overridden in XmlElement.) */
int getDepth() { result = 0 } int getDepth() { result = 0 }
/** Gets the number of child XML elements of this XML parent. */ /** Gets the number of child XML elements of this XML parent. */
int getNumberOfChildren() { result = count(XMLElement e | xmlElements(e, _, this, _, _)) } int getNumberOfChildren() { result = count(XmlElement e | xmlElements(e, _, this, _, _)) }
/** Gets the number of places in the body of this XML parent where text occurs. */ /** Gets the number of places in the body of this XML parent where text occurs. */
int getNumberOfCharacterSets() { result = count(int pos | xmlChars(_, _, this, pos, _, _)) } int getNumberOfCharacterSets() { result = count(int pos | xmlChars(_, _, this, pos, _, _)) }
@@ -92,9 +95,12 @@ class XMLParent extends @xmlparent {
string toString() { result = this.getName() } string toString() { result = this.getName() }
} }
/** DEPRECATED: Alias for XmlParent */
deprecated class XMLParent = XmlParent;
/** An XML file. */ /** An XML file. */
class XMLFile extends XMLParent, File { class XmlFile extends XmlParent, File {
XMLFile() { xmlEncoding(this, _) } XmlFile() { xmlEncoding(this, _) }
/** Gets a printable representation of this XML file. */ /** Gets a printable representation of this XML file. */
override string toString() { result = this.getName() } override string toString() { result = this.getName() }
@@ -120,15 +126,18 @@ class XMLFile extends XMLParent, File {
string getEncoding() { xmlEncoding(this, result) } string getEncoding() { xmlEncoding(this, result) }
/** Gets the XML file itself. */ /** Gets the XML file itself. */
override XMLFile getFile() { result = this } override XmlFile getFile() { result = this }
/** Gets a top-most element in an XML file. */ /** Gets a top-most element in an XML file. */
XMLElement getARootElement() { result = this.getAChild() } XmlElement getARootElement() { result = this.getAChild() }
/** Gets a DTD associated with this XML file. */ /** Gets a DTD associated with this XML file. */
XMLDTD getADTD() { xmlDTDs(result, _, _, _, this) } XMLDTD getADTD() { xmlDTDs(result, _, _, _, this) }
} }
/** DEPRECATED: Alias for XmlFile */
deprecated class XMLFile = XmlFile;
/** /**
* An XML document type definition (DTD). * An XML document type definition (DTD).
* *
@@ -140,7 +149,7 @@ class XMLFile extends XMLParent, File {
* <!ELEMENT lastName (#PCDATA)> * <!ELEMENT lastName (#PCDATA)>
* ``` * ```
*/ */
class XMLDTD extends XMLLocatable, @xmldtd { class XMLDTD extends XmlLocatable, @xmldtd {
/** Gets the name of the root element of this DTD. */ /** Gets the name of the root element of this DTD. */
string getRoot() { xmlDTDs(this, result, _, _, _) } string getRoot() { xmlDTDs(this, result, _, _, _) }
@@ -154,7 +163,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
predicate isPublic() { not xmlDTDs(this, _, "", _, _) } predicate isPublic() { not xmlDTDs(this, _, "", _, _) }
/** Gets the parent of this DTD. */ /** Gets the parent of this DTD. */
XMLParent getParent() { xmlDTDs(this, _, _, _, result) } XmlParent getParent() { xmlDTDs(this, _, _, _, result) }
override string toString() { override string toString() {
this.isPublic() and this.isPublic() and
@@ -176,7 +185,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
* </manifest> * </manifest>
* ``` * ```
*/ */
class XMLElement extends @xmlelement, XMLParent, XMLLocatable { class XmlElement extends @xmlelement, XmlParent, XmlLocatable {
/** Holds if this XML element has the given `name`. */ /** Holds if this XML element has the given `name`. */
predicate hasName(string name) { name = this.getName() } predicate hasName(string name) { name = this.getName() }
@@ -184,10 +193,10 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override string getName() { xmlElements(this, result, _, _, _) } override string getName() { xmlElements(this, result, _, _, _) }
/** Gets the XML file in which this XML element occurs. */ /** Gets the XML file in which this XML element occurs. */
override XMLFile getFile() { xmlElements(this, _, _, _, result) } override XmlFile getFile() { xmlElements(this, _, _, _, result) }
/** Gets the parent of this XML element. */ /** Gets the parent of this XML element. */
XMLParent getParent() { xmlElements(this, _, result, _, _) } XmlParent getParent() { xmlElements(this, _, result, _, _) }
/** Gets the index of this XML element among its parent's children. */ /** Gets the index of this XML element among its parent's children. */
int getIndex() { xmlElements(this, _, _, result, _) } int getIndex() { xmlElements(this, _, _, result, _) }
@@ -196,7 +205,7 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
predicate hasNamespace() { xmlHasNs(this, _, _) } predicate hasNamespace() { xmlHasNs(this, _, _) }
/** Gets the namespace of this XML element, if any. */ /** Gets the namespace of this XML element, if any. */
XMLNamespace getNamespace() { xmlHasNs(this, result, _) } XmlNamespace getNamespace() { xmlHasNs(this, result, _) }
/** Gets the index of this XML element among its parent's children. */ /** Gets the index of this XML element among its parent's children. */
int getElementPositionIndex() { xmlElements(this, _, _, result, _) } int getElementPositionIndex() { xmlElements(this, _, _, result, _) }
@@ -205,10 +214,10 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override int getDepth() { result = this.getParent().getDepth() + 1 } override int getDepth() { result = this.getParent().getDepth() + 1 }
/** Gets an XML attribute of this XML element. */ /** Gets an XML attribute of this XML element. */
XMLAttribute getAnAttribute() { result.getElement() = this } XmlAttribute getAnAttribute() { result.getElement() = this }
/** Gets the attribute with the specified `name`, if any. */ /** Gets the attribute with the specified `name`, if any. */
XMLAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name } XmlAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name }
/** Holds if this XML element has an attribute with the specified `name`. */ /** Holds if this XML element has an attribute with the specified `name`. */
predicate hasAttribute(string name) { exists(this.getAttribute(name)) } predicate hasAttribute(string name) { exists(this.getAttribute(name)) }
@@ -220,6 +229,9 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override string toString() { result = this.getName() } override string toString() { result = this.getName() }
} }
/** DEPRECATED: Alias for XmlElement */
deprecated class XMLElement = XmlElement;
/** /**
* An attribute that occurs inside an XML element. * An attribute that occurs inside an XML element.
* *
@@ -230,18 +242,18 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
* android:versionCode="1" * android:versionCode="1"
* ``` * ```
*/ */
class XMLAttribute extends @xmlattribute, XMLLocatable { class XmlAttribute extends @xmlattribute, XmlLocatable {
/** Gets the name of this attribute. */ /** Gets the name of this attribute. */
string getName() { xmlAttrs(this, _, result, _, _, _) } string getName() { xmlAttrs(this, _, result, _, _, _) }
/** Gets the XML element to which this attribute belongs. */ /** Gets the XML element to which this attribute belongs. */
XMLElement getElement() { xmlAttrs(this, result, _, _, _, _) } XmlElement getElement() { xmlAttrs(this, result, _, _, _, _) }
/** Holds if this attribute has a namespace. */ /** Holds if this attribute has a namespace. */
predicate hasNamespace() { xmlHasNs(this, _, _) } predicate hasNamespace() { xmlHasNs(this, _, _) }
/** Gets the namespace of this attribute, if any. */ /** Gets the namespace of this attribute, if any. */
XMLNamespace getNamespace() { xmlHasNs(this, result, _) } XmlNamespace getNamespace() { xmlHasNs(this, result, _) }
/** Gets the value of this attribute. */ /** Gets the value of this attribute. */
string getValue() { xmlAttrs(this, _, _, result, _, _) } string getValue() { xmlAttrs(this, _, _, result, _, _) }
@@ -250,6 +262,9 @@ class XMLAttribute extends @xmlattribute, XMLLocatable {
override string toString() { result = this.getName() + "=" + this.getValue() } override string toString() { result = this.getName() + "=" + this.getValue() }
} }
/** DEPRECATED: Alias for XmlAttribute */
deprecated class XMLAttribute = XmlAttribute;
/** /**
* A namespace used in an XML file. * A namespace used in an XML file.
* *
@@ -259,7 +274,7 @@ class XMLAttribute extends @xmlattribute, XMLLocatable {
* xmlns:android="http://schemas.android.com/apk/res/android" * xmlns:android="http://schemas.android.com/apk/res/android"
* ``` * ```
*/ */
class XMLNamespace extends XMLLocatable, @xmlnamespace { class XmlNamespace extends XmlLocatable, @xmlnamespace {
/** Gets the prefix of this namespace. */ /** Gets the prefix of this namespace. */
string getPrefix() { xmlNs(this, result, _, _) } string getPrefix() { xmlNs(this, result, _, _) }
@@ -276,6 +291,9 @@ class XMLNamespace extends XMLLocatable, @xmlnamespace {
} }
} }
/** DEPRECATED: Alias for XmlNamespace */
deprecated class XMLNamespace = XmlNamespace;
/** /**
* A comment in an XML file. * A comment in an XML file.
* *
@@ -285,17 +303,20 @@ class XMLNamespace extends XMLLocatable, @xmlnamespace {
* <!-- This is a comment. --> * <!-- This is a comment. -->
* ``` * ```
*/ */
class XMLComment extends @xmlcomment, XMLLocatable { class XmlComment extends @xmlcomment, XmlLocatable {
/** Gets the text content of this XML comment. */ /** Gets the text content of this XML comment. */
string getText() { xmlComments(this, result, _, _) } string getText() { xmlComments(this, result, _, _) }
/** Gets the parent of this XML comment. */ /** Gets the parent of this XML comment. */
XMLParent getParent() { xmlComments(this, _, result, _) } XmlParent getParent() { xmlComments(this, _, result, _) }
/** Gets a printable representation of this XML comment. */ /** Gets a printable representation of this XML comment. */
override string toString() { result = this.getText() } override string toString() { result = this.getText() }
} }
/** DEPRECATED: Alias for XmlComment */
deprecated class XMLComment = XmlComment;
/** /**
* A sequence of characters that occurs between opening and * A sequence of characters that occurs between opening and
* closing tags of an XML element, excluding other elements. * closing tags of an XML element, excluding other elements.
@@ -306,12 +327,12 @@ class XMLComment extends @xmlcomment, XMLLocatable {
* <content>This is a sequence of characters.</content> * <content>This is a sequence of characters.</content>
* ``` * ```
*/ */
class XMLCharacters extends @xmlcharacters, XMLLocatable { class XmlCharacters extends @xmlcharacters, XmlLocatable {
/** Gets the content of this character sequence. */ /** Gets the content of this character sequence. */
string getCharacters() { xmlChars(this, result, _, _, _, _) } string getCharacters() { xmlChars(this, result, _, _, _, _) }
/** Gets the parent of this character sequence. */ /** Gets the parent of this character sequence. */
XMLParent getParent() { xmlChars(this, _, result, _, _, _) } XmlParent getParent() { xmlChars(this, _, result, _, _, _) }
/** Holds if this character sequence is CDATA. */ /** Holds if this character sequence is CDATA. */
predicate isCDATA() { xmlChars(this, _, _, _, 1, _) } predicate isCDATA() { xmlChars(this, _, _, _, 1, _) }
@@ -319,3 +340,6 @@ class XMLCharacters extends @xmlcharacters, XMLLocatable {
/** Gets a printable representation of this XML character sequence. */ /** Gets a printable representation of this XML character sequence. */
override string toString() { result = this.getCharacters() } override string toString() { result = this.getCharacters() }
} }
/** DEPRECATED: Alias for XmlCharacters */
deprecated class XMLCharacters = XmlCharacters;

View File

@@ -38,7 +38,7 @@ predicate dead(RefType dead) {
// Exclude results that have a `main` method. // Exclude results that have a `main` method.
not dead.getAMethod().hasName("main") and not dead.getAMethod().hasName("main") and
// Exclude results that are referenced in XML files. // Exclude results that are referenced in XML files.
not exists(XMLAttribute xla | xla.getValue() = dead.getQualifiedName()) and not exists(XmlAttribute xla | xla.getValue() = dead.getQualifiedName()) and
// Exclude type variables. // Exclude type variables.
not dead instanceof BoundedType and not dead instanceof BoundedType and
// Exclude JUnit tests. // Exclude JUnit tests.

View File

@@ -44,7 +44,7 @@ class ListType extends RefType {
} }
} }
/** Holds if the specified `method` uses MyBatis Mapper XMLElement `mmxx`. */ /** Holds if the specified `method` uses MyBatis Mapper XmlElement `mmxx`. */
predicate myBatisMapperXmlElementFromMethod(Method method, MyBatisMapperXmlElement mmxx) { predicate myBatisMapperXmlElementFromMethod(Method method, MyBatisMapperXmlElement mmxx) {
exists(MyBatisMapperSqlOperation mbmxe | mbmxe.getMapperMethod() = method | exists(MyBatisMapperSqlOperation mbmxe | mbmxe.getMapperMethod() = method |
mbmxe.getAChild*() = mmxx mbmxe.getAChild*() = mmxx
@@ -68,7 +68,7 @@ predicate myBatisSqlOperationAnnotationFromMethod(Method method, IbatisSqlOperat
} }
/** Gets a `#{...}` or `${...}` expression argument in XML element `xmle`. */ /** Gets a `#{...}` or `${...}` expression argument in XML element `xmle`. */
string getAMybatisXmlSetValue(XMLElement xmle) { string getAMybatisXmlSetValue(XmlElement xmle) {
result = xmle.getTextValue().regexpFind("(#|\\$)\\{[^\\}]*\\}", _, _) result = xmle.getTextValue().regexpFind("(#|\\$)\\{[^\\}]*\\}", _, _)
} }

View File

@@ -32,13 +32,13 @@ predicate hasEmbeddedPassword(string value) {
) )
} }
from XMLAttribute nameAttr from XmlAttribute nameAttr
where where
nameAttr.getName().toLowerCase() in ["password", "pwd"] and nameAttr.getName().toLowerCase() in ["password", "pwd"] and
not isNotPassword(nameAttr.getValue().trim()) // Attribute name "password" or "pwd" not isNotPassword(nameAttr.getValue().trim()) // Attribute name "password" or "pwd"
or or
exists( exists(
XMLAttribute valueAttr // name/value pair like <property name="password" value="mysecret"/> XmlAttribute valueAttr // name/value pair like <property name="password" value="mysecret"/>
| |
valueAttr.getElement() = nameAttr.getElement() and valueAttr.getElement() = nameAttr.getElement() and
nameAttr.getName().toLowerCase() = "name" and nameAttr.getName().toLowerCase() = "name" and

View File

@@ -3,9 +3,9 @@ import java
/** /**
* A deployment descriptor file, typically called `struts.xml`. * A deployment descriptor file, typically called `struts.xml`.
*/ */
class StrutsXmlFile extends XMLFile { class StrutsXmlFile extends XmlFile {
StrutsXmlFile() { StrutsXmlFile() {
count(XMLElement e | e = this.getAChild()) = 1 and count(XmlElement e | e = this.getAChild()) = 1 and
this.getAChild().getName() = "struts" this.getAChild().getName() = "struts"
} }
} }
@@ -16,7 +16,7 @@ deprecated class StrutsXMLFile = StrutsXmlFile;
/** /**
* An XML element in a `StrutsXMLFile`. * An XML element in a `StrutsXMLFile`.
*/ */
class StrutsXmlElement extends XMLElement { class StrutsXmlElement extends XmlElement {
StrutsXmlElement() { this.getFile() instanceof StrutsXmlFile } StrutsXmlElement() { this.getFile() instanceof StrutsXmlFile }
/** /**

View File

@@ -7,14 +7,14 @@ import java
* top-level children (usually, in fact, there is only one) is * top-level children (usually, in fact, there is only one) is
* a tag with the name "coverage". * a tag with the name "coverage".
*/ */
class CloverReport extends XMLFile { class CloverReport extends XmlFile {
CloverReport() { this.getAChild().getName() = "coverage" } CloverReport() { this.getAChild().getName() = "coverage" }
} }
/** /**
* The Clover "coverage" tag contains one or more "projects". * The Clover "coverage" tag contains one or more "projects".
*/ */
class CloverCoverage extends XMLElement { class CloverCoverage extends XmlElement {
CloverCoverage() { CloverCoverage() {
this.getParent() instanceof CloverReport and this.getParent() instanceof CloverReport and
this.getName() = "coverage" this.getName() = "coverage"
@@ -29,7 +29,7 @@ class CloverCoverage extends XMLElement {
* contains various numbers, aggregated to the different levels. They are * contains various numbers, aggregated to the different levels. They are
* all subclasses of this class, to share code. * all subclasses of this class, to share code.
*/ */
abstract class CloverMetricsContainer extends XMLElement { abstract class CloverMetricsContainer extends XmlElement {
/** Gets the Clover `metrics` child element for this element. */ /** Gets the Clover `metrics` child element for this element. */
CloverMetrics getMetrics() { result = this.getAChild() } CloverMetrics getMetrics() { result = this.getAChild() }
} }
@@ -38,7 +38,7 @@ abstract class CloverMetricsContainer extends XMLElement {
* A "metrics" element contains a range of numbers for the current * A "metrics" element contains a range of numbers for the current
* aggregation level. * aggregation level.
*/ */
class CloverMetrics extends XMLElement { class CloverMetrics extends XmlElement {
CloverMetrics() { CloverMetrics() {
this.getParent() instanceof CloverMetricsContainer and this.getParent() instanceof CloverMetricsContainer and
this.getName() = "metrics" this.getName() = "metrics"

View File

@@ -7,9 +7,9 @@ import java
/** /**
* MyBatis Mapper XML file. * MyBatis Mapper XML file.
*/ */
class MyBatisMapperXmlFile extends XMLFile { class MyBatisMapperXmlFile extends XmlFile {
MyBatisMapperXmlFile() { MyBatisMapperXmlFile() {
count(XMLElement e | e = this.getAChild()) = 1 and count(XmlElement e | e = this.getAChild()) = 1 and
this.getAChild().getName() = "mapper" this.getAChild().getName() = "mapper"
} }
} }
@@ -20,7 +20,7 @@ deprecated class MyBatisMapperXMLFile = MyBatisMapperXmlFile;
/** /**
* An XML element in a `MyBatisMapperXMLFile`. * An XML element in a `MyBatisMapperXMLFile`.
*/ */
class MyBatisMapperXmlElement extends XMLElement { class MyBatisMapperXmlElement extends XmlElement {
MyBatisMapperXmlElement() { this.getFile() instanceof MyBatisMapperXmlFile } MyBatisMapperXmlElement() { this.getFile() instanceof MyBatisMapperXmlFile }
/** /**

View File

@@ -21,14 +21,14 @@ private class KtExpectationComment extends KtComment, ExpectationComment {
override string getContents() { result = this.getText().suffix(2).trim() } override string getContents() { result = this.getText().suffix(2).trim() }
} }
private class XmlExpectationComment extends ExpectationComment instanceof XMLComment { private class XmlExpectationComment extends ExpectationComment instanceof XmlComment {
override string getContents() { result = this.(XMLComment).getText().trim() } override string getContents() { result = this.(XmlComment).getText().trim() }
override Location getLocation() { result = this.(XMLComment).getLocation() } override Location getLocation() { result = this.(XmlComment).getLocation() }
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) { override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
this.(XMLComment).hasLocationInfo(path, sl, sc, el, ec) this.(XmlComment).hasLocationInfo(path, sl, sc, el, ec)
} }
override string toString() { result = this.(XMLComment).toString() } override string toString() { result = this.(XmlComment).toString() }
} }

View File

@@ -8,7 +8,7 @@ class XmlTest extends InlineExpectationsTest {
override predicate hasActualResult(Location location, string element, string tag, string value) { override predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasXmlResult" and tag = "hasXmlResult" and
exists(XMLAttribute a | exists(XmlAttribute a |
a.getLocation() = location and a.getLocation() = location and
element = a.toString() and element = a.toString() and
value = "" value = ""

View File

@@ -8,7 +8,7 @@ private class TXmlLocatable =
@xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters; @xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters;
/** An XML element that has a location. */ /** An XML element that has a location. */
class XMLLocatable extends @xmllocatable, TXmlLocatable { class XmlLocatable extends @xmllocatable, TXmlLocatable {
/** Gets the source location for this element. */ /** Gets the source location for this element. */
Location getLocation() { xmllocations(this, result) } Location getLocation() { xmllocations(this, result) }
@@ -32,12 +32,15 @@ class XMLLocatable extends @xmllocatable, TXmlLocatable {
string toString() { none() } // overridden in subclasses string toString() { none() } // overridden in subclasses
} }
/** DEPRECATED: Alias for XmlLocatable */
deprecated class XMLLocatable = XmlLocatable;
/** /**
* An `XMLParent` is either an `XMLElement` or an `XMLFile`, * An `XMLParent` is either an `XMLElement` or an `XMLFile`,
* both of which can contain other elements. * both of which can contain other elements.
*/ */
class XMLParent extends @xmlparent { class XmlParent extends @xmlparent {
XMLParent() { XmlParent() {
// explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`; // explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`;
// the type `@xmlparent` currently also includes non-XML files // the type `@xmlparent` currently also includes non-XML files
this instanceof @xmlelement or xmlEncoding(this, _) this instanceof @xmlelement or xmlEncoding(this, _)
@@ -50,28 +53,28 @@ class XMLParent extends @xmlparent {
string getName() { none() } // overridden in subclasses string getName() { none() } // overridden in subclasses
/** Gets the file to which this XML parent belongs. */ /** Gets the file to which this XML parent belongs. */
XMLFile getFile() { result = this or xmlElements(this, _, _, _, result) } XmlFile getFile() { result = this or xmlElements(this, _, _, _, result) }
/** Gets the child element at a specified index of this XML parent. */ /** Gets the child element at a specified index of this XML parent. */
XMLElement getChild(int index) { xmlElements(result, _, this, index, _) } XmlElement getChild(int index) { xmlElements(result, _, this, index, _) }
/** Gets a child element of this XML parent. */ /** Gets a child element of this XML parent. */
XMLElement getAChild() { xmlElements(result, _, this, _, _) } XmlElement getAChild() { xmlElements(result, _, this, _, _) }
/** Gets a child element of this XML parent with the given `name`. */ /** Gets a child element of this XML parent with the given `name`. */
XMLElement getAChild(string name) { xmlElements(result, _, this, _, _) and result.hasName(name) } XmlElement getAChild(string name) { xmlElements(result, _, this, _, _) and result.hasName(name) }
/** Gets a comment that is a child of this XML parent. */ /** Gets a comment that is a child of this XML parent. */
XMLComment getAComment() { xmlComments(result, _, this, _) } XmlComment getAComment() { xmlComments(result, _, this, _) }
/** Gets a character sequence that is a child of this XML parent. */ /** Gets a character sequence that is a child of this XML parent. */
XMLCharacters getACharactersSet() { xmlChars(result, _, this, _, _, _) } XmlCharacters getACharactersSet() { xmlChars(result, _, this, _, _, _) }
/** Gets the depth in the tree. (Overridden in XMLElement.) */ /** Gets the depth in the tree. (Overridden in XmlElement.) */
int getDepth() { result = 0 } int getDepth() { result = 0 }
/** Gets the number of child XML elements of this XML parent. */ /** Gets the number of child XML elements of this XML parent. */
int getNumberOfChildren() { result = count(XMLElement e | xmlElements(e, _, this, _, _)) } int getNumberOfChildren() { result = count(XmlElement e | xmlElements(e, _, this, _, _)) }
/** Gets the number of places in the body of this XML parent where text occurs. */ /** Gets the number of places in the body of this XML parent where text occurs. */
int getNumberOfCharacterSets() { result = count(int pos | xmlChars(_, _, this, pos, _, _)) } int getNumberOfCharacterSets() { result = count(int pos | xmlChars(_, _, this, pos, _, _)) }
@@ -92,9 +95,12 @@ class XMLParent extends @xmlparent {
string toString() { result = this.getName() } string toString() { result = this.getName() }
} }
/** DEPRECATED: Alias for XmlParent */
deprecated class XMLParent = XmlParent;
/** An XML file. */ /** An XML file. */
class XMLFile extends XMLParent, File { class XmlFile extends XmlParent, File {
XMLFile() { xmlEncoding(this, _) } XmlFile() { xmlEncoding(this, _) }
/** Gets a printable representation of this XML file. */ /** Gets a printable representation of this XML file. */
override string toString() { result = this.getName() } override string toString() { result = this.getName() }
@@ -120,15 +126,18 @@ class XMLFile extends XMLParent, File {
string getEncoding() { xmlEncoding(this, result) } string getEncoding() { xmlEncoding(this, result) }
/** Gets the XML file itself. */ /** Gets the XML file itself. */
override XMLFile getFile() { result = this } override XmlFile getFile() { result = this }
/** Gets a top-most element in an XML file. */ /** Gets a top-most element in an XML file. */
XMLElement getARootElement() { result = this.getAChild() } XmlElement getARootElement() { result = this.getAChild() }
/** Gets a DTD associated with this XML file. */ /** Gets a DTD associated with this XML file. */
XMLDTD getADTD() { xmlDTDs(result, _, _, _, this) } XMLDTD getADTD() { xmlDTDs(result, _, _, _, this) }
} }
/** DEPRECATED: Alias for XmlFile */
deprecated class XMLFile = XmlFile;
/** /**
* An XML document type definition (DTD). * An XML document type definition (DTD).
* *
@@ -140,7 +149,7 @@ class XMLFile extends XMLParent, File {
* <!ELEMENT lastName (#PCDATA)> * <!ELEMENT lastName (#PCDATA)>
* ``` * ```
*/ */
class XMLDTD extends XMLLocatable, @xmldtd { class XMLDTD extends XmlLocatable, @xmldtd {
/** Gets the name of the root element of this DTD. */ /** Gets the name of the root element of this DTD. */
string getRoot() { xmlDTDs(this, result, _, _, _) } string getRoot() { xmlDTDs(this, result, _, _, _) }
@@ -154,7 +163,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
predicate isPublic() { not xmlDTDs(this, _, "", _, _) } predicate isPublic() { not xmlDTDs(this, _, "", _, _) }
/** Gets the parent of this DTD. */ /** Gets the parent of this DTD. */
XMLParent getParent() { xmlDTDs(this, _, _, _, result) } XmlParent getParent() { xmlDTDs(this, _, _, _, result) }
override string toString() { override string toString() {
this.isPublic() and this.isPublic() and
@@ -176,7 +185,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
* </manifest> * </manifest>
* ``` * ```
*/ */
class XMLElement extends @xmlelement, XMLParent, XMLLocatable { class XmlElement extends @xmlelement, XmlParent, XmlLocatable {
/** Holds if this XML element has the given `name`. */ /** Holds if this XML element has the given `name`. */
predicate hasName(string name) { name = this.getName() } predicate hasName(string name) { name = this.getName() }
@@ -184,10 +193,10 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override string getName() { xmlElements(this, result, _, _, _) } override string getName() { xmlElements(this, result, _, _, _) }
/** Gets the XML file in which this XML element occurs. */ /** Gets the XML file in which this XML element occurs. */
override XMLFile getFile() { xmlElements(this, _, _, _, result) } override XmlFile getFile() { xmlElements(this, _, _, _, result) }
/** Gets the parent of this XML element. */ /** Gets the parent of this XML element. */
XMLParent getParent() { xmlElements(this, _, result, _, _) } XmlParent getParent() { xmlElements(this, _, result, _, _) }
/** Gets the index of this XML element among its parent's children. */ /** Gets the index of this XML element among its parent's children. */
int getIndex() { xmlElements(this, _, _, result, _) } int getIndex() { xmlElements(this, _, _, result, _) }
@@ -196,7 +205,7 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
predicate hasNamespace() { xmlHasNs(this, _, _) } predicate hasNamespace() { xmlHasNs(this, _, _) }
/** Gets the namespace of this XML element, if any. */ /** Gets the namespace of this XML element, if any. */
XMLNamespace getNamespace() { xmlHasNs(this, result, _) } XmlNamespace getNamespace() { xmlHasNs(this, result, _) }
/** Gets the index of this XML element among its parent's children. */ /** Gets the index of this XML element among its parent's children. */
int getElementPositionIndex() { xmlElements(this, _, _, result, _) } int getElementPositionIndex() { xmlElements(this, _, _, result, _) }
@@ -205,10 +214,10 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override int getDepth() { result = this.getParent().getDepth() + 1 } override int getDepth() { result = this.getParent().getDepth() + 1 }
/** Gets an XML attribute of this XML element. */ /** Gets an XML attribute of this XML element. */
XMLAttribute getAnAttribute() { result.getElement() = this } XmlAttribute getAnAttribute() { result.getElement() = this }
/** Gets the attribute with the specified `name`, if any. */ /** Gets the attribute with the specified `name`, if any. */
XMLAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name } XmlAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name }
/** Holds if this XML element has an attribute with the specified `name`. */ /** Holds if this XML element has an attribute with the specified `name`. */
predicate hasAttribute(string name) { exists(this.getAttribute(name)) } predicate hasAttribute(string name) { exists(this.getAttribute(name)) }
@@ -220,6 +229,9 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override string toString() { result = this.getName() } override string toString() { result = this.getName() }
} }
/** DEPRECATED: Alias for XmlElement */
deprecated class XMLElement = XmlElement;
/** /**
* An attribute that occurs inside an XML element. * An attribute that occurs inside an XML element.
* *
@@ -230,18 +242,18 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
* android:versionCode="1" * android:versionCode="1"
* ``` * ```
*/ */
class XMLAttribute extends @xmlattribute, XMLLocatable { class XmlAttribute extends @xmlattribute, XmlLocatable {
/** Gets the name of this attribute. */ /** Gets the name of this attribute. */
string getName() { xmlAttrs(this, _, result, _, _, _) } string getName() { xmlAttrs(this, _, result, _, _, _) }
/** Gets the XML element to which this attribute belongs. */ /** Gets the XML element to which this attribute belongs. */
XMLElement getElement() { xmlAttrs(this, result, _, _, _, _) } XmlElement getElement() { xmlAttrs(this, result, _, _, _, _) }
/** Holds if this attribute has a namespace. */ /** Holds if this attribute has a namespace. */
predicate hasNamespace() { xmlHasNs(this, _, _) } predicate hasNamespace() { xmlHasNs(this, _, _) }
/** Gets the namespace of this attribute, if any. */ /** Gets the namespace of this attribute, if any. */
XMLNamespace getNamespace() { xmlHasNs(this, result, _) } XmlNamespace getNamespace() { xmlHasNs(this, result, _) }
/** Gets the value of this attribute. */ /** Gets the value of this attribute. */
string getValue() { xmlAttrs(this, _, _, result, _, _) } string getValue() { xmlAttrs(this, _, _, result, _, _) }
@@ -250,6 +262,9 @@ class XMLAttribute extends @xmlattribute, XMLLocatable {
override string toString() { result = this.getName() + "=" + this.getValue() } override string toString() { result = this.getName() + "=" + this.getValue() }
} }
/** DEPRECATED: Alias for XmlAttribute */
deprecated class XMLAttribute = XmlAttribute;
/** /**
* A namespace used in an XML file. * A namespace used in an XML file.
* *
@@ -259,7 +274,7 @@ class XMLAttribute extends @xmlattribute, XMLLocatable {
* xmlns:android="http://schemas.android.com/apk/res/android" * xmlns:android="http://schemas.android.com/apk/res/android"
* ``` * ```
*/ */
class XMLNamespace extends XMLLocatable, @xmlnamespace { class XmlNamespace extends XmlLocatable, @xmlnamespace {
/** Gets the prefix of this namespace. */ /** Gets the prefix of this namespace. */
string getPrefix() { xmlNs(this, result, _, _) } string getPrefix() { xmlNs(this, result, _, _) }
@@ -276,6 +291,9 @@ class XMLNamespace extends XMLLocatable, @xmlnamespace {
} }
} }
/** DEPRECATED: Alias for XmlNamespace */
deprecated class XMLNamespace = XmlNamespace;
/** /**
* A comment in an XML file. * A comment in an XML file.
* *
@@ -285,17 +303,20 @@ class XMLNamespace extends XMLLocatable, @xmlnamespace {
* <!-- This is a comment. --> * <!-- This is a comment. -->
* ``` * ```
*/ */
class XMLComment extends @xmlcomment, XMLLocatable { class XmlComment extends @xmlcomment, XmlLocatable {
/** Gets the text content of this XML comment. */ /** Gets the text content of this XML comment. */
string getText() { xmlComments(this, result, _, _) } string getText() { xmlComments(this, result, _, _) }
/** Gets the parent of this XML comment. */ /** Gets the parent of this XML comment. */
XMLParent getParent() { xmlComments(this, _, result, _) } XmlParent getParent() { xmlComments(this, _, result, _) }
/** Gets a printable representation of this XML comment. */ /** Gets a printable representation of this XML comment. */
override string toString() { result = this.getText() } override string toString() { result = this.getText() }
} }
/** DEPRECATED: Alias for XmlComment */
deprecated class XMLComment = XmlComment;
/** /**
* A sequence of characters that occurs between opening and * A sequence of characters that occurs between opening and
* closing tags of an XML element, excluding other elements. * closing tags of an XML element, excluding other elements.
@@ -306,12 +327,12 @@ class XMLComment extends @xmlcomment, XMLLocatable {
* <content>This is a sequence of characters.</content> * <content>This is a sequence of characters.</content>
* ``` * ```
*/ */
class XMLCharacters extends @xmlcharacters, XMLLocatable { class XmlCharacters extends @xmlcharacters, XmlLocatable {
/** Gets the content of this character sequence. */ /** Gets the content of this character sequence. */
string getCharacters() { xmlChars(this, result, _, _, _, _) } string getCharacters() { xmlChars(this, result, _, _, _, _) }
/** Gets the parent of this character sequence. */ /** Gets the parent of this character sequence. */
XMLParent getParent() { xmlChars(this, _, result, _, _, _) } XmlParent getParent() { xmlChars(this, _, result, _, _, _) }
/** Holds if this character sequence is CDATA. */ /** Holds if this character sequence is CDATA. */
predicate isCDATA() { xmlChars(this, _, _, _, 1, _) } predicate isCDATA() { xmlChars(this, _, _, _, 1, _) }
@@ -319,3 +340,6 @@ class XMLCharacters extends @xmlcharacters, XMLLocatable {
/** Gets a printable representation of this XML character sequence. */ /** Gets a printable representation of this XML character sequence. */
override string toString() { result = this.getCharacters() } override string toString() { result = this.getCharacters() }
} }
/** DEPRECATED: Alias for XmlCharacters */
deprecated class XMLCharacters = XmlCharacters;

View File

@@ -1,28 +1,28 @@
import javascript import javascript
query predicate xmlAttribute(XMLAttribute attr, XMLElement element, string name, string value) { query predicate xmlAttribute(XmlAttribute attr, XmlElement element, string name, string value) {
attr.getElement() = element and attr.getElement() = element and
attr.getName() = name and attr.getName() = name and
attr.getValue() = value attr.getValue() = value
} }
query predicate xmlComment(XMLComment c, string text) { text = c.getText() } query predicate xmlComment(XmlComment c, string text) { text = c.getText() }
query predicate xmlElement_getAnAttribute(XMLElement e, XMLAttribute attr) { query predicate xmlElement_getAnAttribute(XmlElement e, XmlAttribute attr) {
attr = e.getAnAttribute() attr = e.getAnAttribute()
} }
query predicate xmlElement(XMLElement elt, string name, XMLParent parent, int index, XMLFile file) { query predicate xmlElement(XmlElement elt, string name, XmlParent parent, int index, XmlFile file) {
name = elt.getName() and name = elt.getName() and
parent = elt.getParent() and parent = elt.getParent() and
index = elt.getIndex() and index = elt.getIndex() and
file = elt.getFile() file = elt.getFile()
} }
query predicate xmlFile(XMLFile f) { any() } query predicate xmlFile(XmlFile f) { any() }
query predicate xmlLocatable(XMLLocatable x) { any() } query predicate xmlLocatable(XmlLocatable x) { any() }
query predicate xmlParent_getChild(XMLParent p, int i, XMLElement child) { child = p.getChild(i) } query predicate xmlParent_getChild(XmlParent p, int i, XmlElement child) { child = p.getChild(i) }
query predicate xmlParent_getTextValue(XMLParent p, string text) { p.getTextValue() = text } query predicate xmlParent_getTextValue(XmlParent p, string text) { p.getTextValue() = text }

View File

@@ -8,7 +8,7 @@ private class TXmlLocatable =
@xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters; @xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters;
/** An XML element that has a location. */ /** An XML element that has a location. */
class XMLLocatable extends @xmllocatable, TXmlLocatable { class XmlLocatable extends @xmllocatable, TXmlLocatable {
/** Gets the source location for this element. */ /** Gets the source location for this element. */
Location getLocation() { xmllocations(this, result) } Location getLocation() { xmllocations(this, result) }
@@ -32,12 +32,15 @@ class XMLLocatable extends @xmllocatable, TXmlLocatable {
string toString() { none() } // overridden in subclasses string toString() { none() } // overridden in subclasses
} }
/** DEPRECATED: Alias for XmlLocatable */
deprecated class XMLLocatable = XmlLocatable;
/** /**
* An `XMLParent` is either an `XMLElement` or an `XMLFile`, * An `XMLParent` is either an `XMLElement` or an `XMLFile`,
* both of which can contain other elements. * both of which can contain other elements.
*/ */
class XMLParent extends @xmlparent { class XmlParent extends @xmlparent {
XMLParent() { XmlParent() {
// explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`; // explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`;
// the type `@xmlparent` currently also includes non-XML files // the type `@xmlparent` currently also includes non-XML files
this instanceof @xmlelement or xmlEncoding(this, _) this instanceof @xmlelement or xmlEncoding(this, _)
@@ -50,28 +53,28 @@ class XMLParent extends @xmlparent {
string getName() { none() } // overridden in subclasses string getName() { none() } // overridden in subclasses
/** Gets the file to which this XML parent belongs. */ /** Gets the file to which this XML parent belongs. */
XMLFile getFile() { result = this or xmlElements(this, _, _, _, result) } XmlFile getFile() { result = this or xmlElements(this, _, _, _, result) }
/** Gets the child element at a specified index of this XML parent. */ /** Gets the child element at a specified index of this XML parent. */
XMLElement getChild(int index) { xmlElements(result, _, this, index, _) } XmlElement getChild(int index) { xmlElements(result, _, this, index, _) }
/** Gets a child element of this XML parent. */ /** Gets a child element of this XML parent. */
XMLElement getAChild() { xmlElements(result, _, this, _, _) } XmlElement getAChild() { xmlElements(result, _, this, _, _) }
/** Gets a child element of this XML parent with the given `name`. */ /** Gets a child element of this XML parent with the given `name`. */
XMLElement getAChild(string name) { xmlElements(result, _, this, _, _) and result.hasName(name) } XmlElement getAChild(string name) { xmlElements(result, _, this, _, _) and result.hasName(name) }
/** Gets a comment that is a child of this XML parent. */ /** Gets a comment that is a child of this XML parent. */
XMLComment getAComment() { xmlComments(result, _, this, _) } XmlComment getAComment() { xmlComments(result, _, this, _) }
/** Gets a character sequence that is a child of this XML parent. */ /** Gets a character sequence that is a child of this XML parent. */
XMLCharacters getACharactersSet() { xmlChars(result, _, this, _, _, _) } XmlCharacters getACharactersSet() { xmlChars(result, _, this, _, _, _) }
/** Gets the depth in the tree. (Overridden in XMLElement.) */ /** Gets the depth in the tree. (Overridden in XmlElement.) */
int getDepth() { result = 0 } int getDepth() { result = 0 }
/** Gets the number of child XML elements of this XML parent. */ /** Gets the number of child XML elements of this XML parent. */
int getNumberOfChildren() { result = count(XMLElement e | xmlElements(e, _, this, _, _)) } int getNumberOfChildren() { result = count(XmlElement e | xmlElements(e, _, this, _, _)) }
/** Gets the number of places in the body of this XML parent where text occurs. */ /** Gets the number of places in the body of this XML parent where text occurs. */
int getNumberOfCharacterSets() { result = count(int pos | xmlChars(_, _, this, pos, _, _)) } int getNumberOfCharacterSets() { result = count(int pos | xmlChars(_, _, this, pos, _, _)) }
@@ -92,9 +95,12 @@ class XMLParent extends @xmlparent {
string toString() { result = this.getName() } string toString() { result = this.getName() }
} }
/** DEPRECATED: Alias for XmlParent */
deprecated class XMLParent = XmlParent;
/** An XML file. */ /** An XML file. */
class XMLFile extends XMLParent, File { class XmlFile extends XmlParent, File {
XMLFile() { xmlEncoding(this, _) } XmlFile() { xmlEncoding(this, _) }
/** Gets a printable representation of this XML file. */ /** Gets a printable representation of this XML file. */
override string toString() { result = this.getName() } override string toString() { result = this.getName() }
@@ -120,15 +126,18 @@ class XMLFile extends XMLParent, File {
string getEncoding() { xmlEncoding(this, result) } string getEncoding() { xmlEncoding(this, result) }
/** Gets the XML file itself. */ /** Gets the XML file itself. */
override XMLFile getFile() { result = this } override XmlFile getFile() { result = this }
/** Gets a top-most element in an XML file. */ /** Gets a top-most element in an XML file. */
XMLElement getARootElement() { result = this.getAChild() } XmlElement getARootElement() { result = this.getAChild() }
/** Gets a DTD associated with this XML file. */ /** Gets a DTD associated with this XML file. */
XMLDTD getADTD() { xmlDTDs(result, _, _, _, this) } XMLDTD getADTD() { xmlDTDs(result, _, _, _, this) }
} }
/** DEPRECATED: Alias for XmlFile */
deprecated class XMLFile = XmlFile;
/** /**
* An XML document type definition (DTD). * An XML document type definition (DTD).
* *
@@ -140,7 +149,7 @@ class XMLFile extends XMLParent, File {
* <!ELEMENT lastName (#PCDATA)> * <!ELEMENT lastName (#PCDATA)>
* ``` * ```
*/ */
class XMLDTD extends XMLLocatable, @xmldtd { class XMLDTD extends XmlLocatable, @xmldtd {
/** Gets the name of the root element of this DTD. */ /** Gets the name of the root element of this DTD. */
string getRoot() { xmlDTDs(this, result, _, _, _) } string getRoot() { xmlDTDs(this, result, _, _, _) }
@@ -154,7 +163,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
predicate isPublic() { not xmlDTDs(this, _, "", _, _) } predicate isPublic() { not xmlDTDs(this, _, "", _, _) }
/** Gets the parent of this DTD. */ /** Gets the parent of this DTD. */
XMLParent getParent() { xmlDTDs(this, _, _, _, result) } XmlParent getParent() { xmlDTDs(this, _, _, _, result) }
override string toString() { override string toString() {
this.isPublic() and this.isPublic() and
@@ -176,7 +185,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
* </manifest> * </manifest>
* ``` * ```
*/ */
class XMLElement extends @xmlelement, XMLParent, XMLLocatable { class XmlElement extends @xmlelement, XmlParent, XmlLocatable {
/** Holds if this XML element has the given `name`. */ /** Holds if this XML element has the given `name`. */
predicate hasName(string name) { name = this.getName() } predicate hasName(string name) { name = this.getName() }
@@ -184,10 +193,10 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override string getName() { xmlElements(this, result, _, _, _) } override string getName() { xmlElements(this, result, _, _, _) }
/** Gets the XML file in which this XML element occurs. */ /** Gets the XML file in which this XML element occurs. */
override XMLFile getFile() { xmlElements(this, _, _, _, result) } override XmlFile getFile() { xmlElements(this, _, _, _, result) }
/** Gets the parent of this XML element. */ /** Gets the parent of this XML element. */
XMLParent getParent() { xmlElements(this, _, result, _, _) } XmlParent getParent() { xmlElements(this, _, result, _, _) }
/** Gets the index of this XML element among its parent's children. */ /** Gets the index of this XML element among its parent's children. */
int getIndex() { xmlElements(this, _, _, result, _) } int getIndex() { xmlElements(this, _, _, result, _) }
@@ -196,7 +205,7 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
predicate hasNamespace() { xmlHasNs(this, _, _) } predicate hasNamespace() { xmlHasNs(this, _, _) }
/** Gets the namespace of this XML element, if any. */ /** Gets the namespace of this XML element, if any. */
XMLNamespace getNamespace() { xmlHasNs(this, result, _) } XmlNamespace getNamespace() { xmlHasNs(this, result, _) }
/** Gets the index of this XML element among its parent's children. */ /** Gets the index of this XML element among its parent's children. */
int getElementPositionIndex() { xmlElements(this, _, _, result, _) } int getElementPositionIndex() { xmlElements(this, _, _, result, _) }
@@ -205,10 +214,10 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override int getDepth() { result = this.getParent().getDepth() + 1 } override int getDepth() { result = this.getParent().getDepth() + 1 }
/** Gets an XML attribute of this XML element. */ /** Gets an XML attribute of this XML element. */
XMLAttribute getAnAttribute() { result.getElement() = this } XmlAttribute getAnAttribute() { result.getElement() = this }
/** Gets the attribute with the specified `name`, if any. */ /** Gets the attribute with the specified `name`, if any. */
XMLAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name } XmlAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name }
/** Holds if this XML element has an attribute with the specified `name`. */ /** Holds if this XML element has an attribute with the specified `name`. */
predicate hasAttribute(string name) { exists(this.getAttribute(name)) } predicate hasAttribute(string name) { exists(this.getAttribute(name)) }
@@ -220,6 +229,9 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
override string toString() { result = this.getName() } override string toString() { result = this.getName() }
} }
/** DEPRECATED: Alias for XmlElement */
deprecated class XMLElement = XmlElement;
/** /**
* An attribute that occurs inside an XML element. * An attribute that occurs inside an XML element.
* *
@@ -230,18 +242,18 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
* android:versionCode="1" * android:versionCode="1"
* ``` * ```
*/ */
class XMLAttribute extends @xmlattribute, XMLLocatable { class XmlAttribute extends @xmlattribute, XmlLocatable {
/** Gets the name of this attribute. */ /** Gets the name of this attribute. */
string getName() { xmlAttrs(this, _, result, _, _, _) } string getName() { xmlAttrs(this, _, result, _, _, _) }
/** Gets the XML element to which this attribute belongs. */ /** Gets the XML element to which this attribute belongs. */
XMLElement getElement() { xmlAttrs(this, result, _, _, _, _) } XmlElement getElement() { xmlAttrs(this, result, _, _, _, _) }
/** Holds if this attribute has a namespace. */ /** Holds if this attribute has a namespace. */
predicate hasNamespace() { xmlHasNs(this, _, _) } predicate hasNamespace() { xmlHasNs(this, _, _) }
/** Gets the namespace of this attribute, if any. */ /** Gets the namespace of this attribute, if any. */
XMLNamespace getNamespace() { xmlHasNs(this, result, _) } XmlNamespace getNamespace() { xmlHasNs(this, result, _) }
/** Gets the value of this attribute. */ /** Gets the value of this attribute. */
string getValue() { xmlAttrs(this, _, _, result, _, _) } string getValue() { xmlAttrs(this, _, _, result, _, _) }
@@ -250,6 +262,9 @@ class XMLAttribute extends @xmlattribute, XMLLocatable {
override string toString() { result = this.getName() + "=" + this.getValue() } override string toString() { result = this.getName() + "=" + this.getValue() }
} }
/** DEPRECATED: Alias for XmlAttribute */
deprecated class XMLAttribute = XmlAttribute;
/** /**
* A namespace used in an XML file. * A namespace used in an XML file.
* *
@@ -259,7 +274,7 @@ class XMLAttribute extends @xmlattribute, XMLLocatable {
* xmlns:android="http://schemas.android.com/apk/res/android" * xmlns:android="http://schemas.android.com/apk/res/android"
* ``` * ```
*/ */
class XMLNamespace extends XMLLocatable, @xmlnamespace { class XmlNamespace extends XmlLocatable, @xmlnamespace {
/** Gets the prefix of this namespace. */ /** Gets the prefix of this namespace. */
string getPrefix() { xmlNs(this, result, _, _) } string getPrefix() { xmlNs(this, result, _, _) }
@@ -276,6 +291,9 @@ class XMLNamespace extends XMLLocatable, @xmlnamespace {
} }
} }
/** DEPRECATED: Alias for XmlNamespace */
deprecated class XMLNamespace = XmlNamespace;
/** /**
* A comment in an XML file. * A comment in an XML file.
* *
@@ -285,17 +303,20 @@ class XMLNamespace extends XMLLocatable, @xmlnamespace {
* <!-- This is a comment. --> * <!-- This is a comment. -->
* ``` * ```
*/ */
class XMLComment extends @xmlcomment, XMLLocatable { class XmlComment extends @xmlcomment, XmlLocatable {
/** Gets the text content of this XML comment. */ /** Gets the text content of this XML comment. */
string getText() { xmlComments(this, result, _, _) } string getText() { xmlComments(this, result, _, _) }
/** Gets the parent of this XML comment. */ /** Gets the parent of this XML comment. */
XMLParent getParent() { xmlComments(this, _, result, _) } XmlParent getParent() { xmlComments(this, _, result, _) }
/** Gets a printable representation of this XML comment. */ /** Gets a printable representation of this XML comment. */
override string toString() { result = this.getText() } override string toString() { result = this.getText() }
} }
/** DEPRECATED: Alias for XmlComment */
deprecated class XMLComment = XmlComment;
/** /**
* A sequence of characters that occurs between opening and * A sequence of characters that occurs between opening and
* closing tags of an XML element, excluding other elements. * closing tags of an XML element, excluding other elements.
@@ -306,12 +327,12 @@ class XMLComment extends @xmlcomment, XMLLocatable {
* <content>This is a sequence of characters.</content> * <content>This is a sequence of characters.</content>
* ``` * ```
*/ */
class XMLCharacters extends @xmlcharacters, XMLLocatable { class XmlCharacters extends @xmlcharacters, XmlLocatable {
/** Gets the content of this character sequence. */ /** Gets the content of this character sequence. */
string getCharacters() { xmlChars(this, result, _, _, _, _) } string getCharacters() { xmlChars(this, result, _, _, _, _) }
/** Gets the parent of this character sequence. */ /** Gets the parent of this character sequence. */
XMLParent getParent() { xmlChars(this, _, result, _, _, _) } XmlParent getParent() { xmlChars(this, _, result, _, _, _) }
/** Holds if this character sequence is CDATA. */ /** Holds if this character sequence is CDATA. */
predicate isCDATA() { xmlChars(this, _, _, _, 1, _) } predicate isCDATA() { xmlChars(this, _, _, _, 1, _) }
@@ -319,3 +340,6 @@ class XMLCharacters extends @xmlcharacters, XMLLocatable {
/** Gets a printable representation of this XML character sequence. */ /** Gets a printable representation of this XML character sequence. */
override string toString() { result = this.getCharacters() } override string toString() { result = this.getCharacters() }
} }
/** DEPRECATED: Alias for XmlCharacters */
deprecated class XMLCharacters = XmlCharacters;

View File

@@ -1,6 +1,6 @@
import python import python
abstract class XmlBytecodeExpr extends XMLElement { } abstract class XmlBytecodeExpr extends XmlElement { }
/** DEPRECATED: Alias for XmlBytecodeExpr */ /** DEPRECATED: Alias for XmlBytecodeExpr */
deprecated class XMLBytecodeExpr = XmlBytecodeExpr; deprecated class XMLBytecodeExpr = XmlBytecodeExpr;

View File

@@ -4,7 +4,7 @@ import semmle.python.objects.Callables
import lib.BytecodeExpr import lib.BytecodeExpr
/** The XML data for a recorded call (includes all data). */ /** The XML data for a recorded call (includes all data). */
class XmlRecordedCall extends XMLElement { class XmlRecordedCall extends XmlElement {
XmlRecordedCall() { this.hasName("recorded_call") } XmlRecordedCall() { this.hasName("recorded_call") }
/** Gets the XML data for the call. */ /** Gets the XML data for the call. */
@@ -61,7 +61,7 @@ class XmlRecordedCall extends XMLElement {
deprecated class XMLRecordedCall = XmlRecordedCall; deprecated class XMLRecordedCall = XmlRecordedCall;
/** The XML data for the call part a recorded call. */ /** The XML data for the call part a recorded call. */
class XmlCall extends XMLElement { class XmlCall extends XmlElement {
XmlCall() { this.hasName("Call") } XmlCall() { this.hasName("Call") }
string get_filename_data() { result = this.getAChild("filename").getTextValue() } string get_filename_data() { result = this.getAChild("filename").getTextValue() }
@@ -114,7 +114,7 @@ class XmlCall extends XMLElement {
deprecated class XMLCall = XmlCall; deprecated class XMLCall = XmlCall;
/** The XML data for the callee part a recorded call. */ /** The XML data for the callee part a recorded call. */
abstract class XmlCallee extends XMLElement { } abstract class XmlCallee extends XmlElement { }
/** DEPRECATED: Alias for XmlCallee */ /** DEPRECATED: Alias for XmlCallee */
deprecated class XMLCallee = XmlCallee; deprecated class XMLCallee = XmlCallee;