Skip to content

Commit bb9e773

Browse files
committed
Overlay: Future-proof Java XML discarding
1 parent 3cd737e commit bb9e773

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

java/ql/lib/semmle/code/java/Overlay.qll

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ predicate isOverlay() { databaseMetadata("isOverlay", "true") }
1818
overlay[local]
1919
string getRawFile(@locatable el) {
2020
exists(@location loc, @file file |
21-
hasLocation(el, loc) and
21+
(hasLocation(el, loc) or xmllocations(el, loc)) and
2222
locations_default(loc, file, _, _, _, _) and
2323
files(file, result)
2424
)
@@ -92,23 +92,3 @@ overlay[discard_entity]
9292
private predicate discardBaseConfigLocatable(@configLocatable el) {
9393
overlayChangedFiles(baseConfigLocatable(el))
9494
}
95-
96-
overlay[local]
97-
private predicate baseXmlLocatable(@xmllocatable l) {
98-
not isOverlay() and not files(l, _) and not xmlNs(l, _, _, _)
99-
}
100-
101-
overlay[local]
102-
private predicate overlayHasXmlLocatable() {
103-
isOverlay() and
104-
exists(@xmllocatable l | not files(l, _) and not xmlNs(l, _, _, _))
105-
}
106-
107-
overlay[discard_entity]
108-
private predicate discardBaseXmlLocatable(@xmllocatable el) {
109-
// The XML extractor is currently not incremental, so if
110-
// the overlay contains any XML locatables, the overlay should
111-
// contain a full extraction and all XML locatables from base
112-
// should be discarded.
113-
baseXmlLocatable(el) and overlayHasXmlLocatable()
114-
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module;
66

77
import semmle.files.FileSystem
88
private import codeql.xml.Xml
9+
private import semmle.code.java.Overlay
910

1011
private module Input implements InputSig<File, Location> {
1112
class XmlLocatableBase = @xmllocatable or @xmlnamespaceable;
@@ -69,3 +70,15 @@ private module Input implements InputSig<File, Location> {
6970
}
7071

7172
import Make<File, Location, Input>
73+
74+
private class DiscardableXmlAttribute extends DiscardableLocatable, @xmlattribute { }
75+
76+
private class DiscardableXmlElement extends DiscardableLocatable, @xmlelement { }
77+
78+
private class DiscardableXmlComment extends DiscardableLocatable, @xmlcomment { }
79+
80+
private class DiscardableXmlCharacters extends DiscardableLocatable, @xmlcharacters { }
81+
82+
private class DiscardableXmlDtd extends DiscardableLocatable, @xmldtd { }
83+
84+
private class DiscardableXmlNamespace extends DiscardableReferableLocatable, @xmlnamespace { }

0 commit comments

Comments
 (0)