From dfeca636770df8c3e0cde9cf31808f2a2de8f6a2 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Thu, 12 Dec 2019 12:22:43 +0000 Subject: [PATCH] JavaScript: Fix characteristic predicate of `XMLParent`. The database type `@xmlparent` is defined a bit too loosely in that it includes all of `@file`, not just XML files. Fixing that would involve fiddling with the extractor/dbscheme, so I have opted to fix it at the QL level instead. --- javascript/ql/src/semmle/javascript/XML.qll | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/javascript/ql/src/semmle/javascript/XML.qll b/javascript/ql/src/semmle/javascript/XML.qll index 1bc2778a9b83..af06cedcbcd8 100755 --- a/javascript/ql/src/semmle/javascript/XML.qll +++ b/javascript/ql/src/semmle/javascript/XML.qll @@ -34,6 +34,12 @@ abstract class XMLLocatable extends @xmllocatable { * both of which can contain other elements. */ class XMLParent extends @xmlparent { + XMLParent() { + // explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`; + // the type `@xmlparent` currently also includes non-XML files + this instanceof @xmlelement or xmlEncoding(this, _) + } + /** * Gets a printable representation of this XML parent. * (Intended to be overridden in subclasses.)