Skip to content

Commit 9c3e275

Browse files
authored
Merge pull request #20011 from kaspersv/kaspersv/discard-xml
Overlay: Add XML and Java property discarding
2 parents b13f118 + f84a308 commit 9c3e275

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,41 @@ private predicate discardReferableLocatable(@locatable el) {
7272
not drl.existsInOverlay()
7373
)
7474
}
75+
76+
overlay[local]
77+
private predicate baseConfigLocatable(@configLocatable l) { not isOverlay() and exists(l) }
78+
79+
overlay[local]
80+
private predicate overlayHasConfigLocatables() {
81+
isOverlay() and
82+
exists(@configLocatable el)
83+
}
84+
85+
overlay[discard_entity]
86+
private predicate discardBaseConfigLocatable(@configLocatable el) {
87+
// The properties extractor is currently not incremental, so if
88+
// the overlay contains any config locatables, the overlay should
89+
// contain a full extraction and all config locatables from base
90+
// should be discarded.
91+
baseConfigLocatable(el) and overlayHasConfigLocatables()
92+
}
93+
94+
overlay[local]
95+
private predicate baseXmlLocatable(@xmllocatable l) {
96+
not isOverlay() and not files(l, _) and not xmlNs(l, _, _, _)
97+
}
98+
99+
overlay[local]
100+
private predicate overlayHasXmlLocatable() {
101+
isOverlay() and
102+
exists(@xmllocatable l | not files(l, _) and not xmlNs(l, _, _, _))
103+
}
104+
105+
overlay[discard_entity]
106+
private predicate discardBaseXmlLocatable(@xmllocatable el) {
107+
// The XML extractor is currently not incremental, so if
108+
// the overlay contains any XML locatables, the overlay should
109+
// contain a full extraction and all XML locatables from base
110+
// should be discarded.
111+
baseXmlLocatable(el) and overlayHasXmlLocatable()
112+
}

0 commit comments

Comments
 (0)