mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge pull request #20484 from kaspersv/kaspersv/future-proof-java-discarding
Overlay: Future-proof Java config & XML discard predicates
This commit is contained in:
@@ -18,7 +18,7 @@ predicate isOverlay() { databaseMetadata("isOverlay", "true") }
|
||||
overlay[local]
|
||||
string getRawFile(@locatable el) {
|
||||
exists(@location loc, @file file |
|
||||
hasLocation(el, loc) and
|
||||
(hasLocation(el, loc) or xmllocations(el, loc)) and
|
||||
locations_default(loc, file, _, _, _, _) and
|
||||
files(file, result)
|
||||
)
|
||||
@@ -73,40 +73,22 @@ private predicate discardReferableLocatable(@locatable el) {
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets the raw file for a configLocatable. */
|
||||
overlay[local]
|
||||
private predicate baseConfigLocatable(@configLocatable l) { not isOverlay() and exists(l) }
|
||||
private string getRawFileForConfig(@configLocatable el) {
|
||||
exists(@location loc, @file file |
|
||||
configLocations(el, loc) and
|
||||
locations_default(loc, file, _, _, _, _) and
|
||||
files(file, result)
|
||||
)
|
||||
}
|
||||
|
||||
overlay[local]
|
||||
private predicate overlayHasConfigLocatables() {
|
||||
isOverlay() and
|
||||
exists(@configLocatable el)
|
||||
private string baseConfigLocatable(@configLocatable el) {
|
||||
not isOverlay() and result = getRawFileForConfig(el)
|
||||
}
|
||||
|
||||
overlay[discard_entity]
|
||||
private predicate discardBaseConfigLocatable(@configLocatable el) {
|
||||
// The properties extractor is currently not incremental, so if
|
||||
// the overlay contains any config locatables, the overlay should
|
||||
// contain a full extraction and all config locatables from base
|
||||
// should be discarded.
|
||||
baseConfigLocatable(el) and overlayHasConfigLocatables()
|
||||
}
|
||||
|
||||
overlay[local]
|
||||
private predicate baseXmlLocatable(@xmllocatable l) {
|
||||
not isOverlay() and not files(l, _) and not xmlNs(l, _, _, _)
|
||||
}
|
||||
|
||||
overlay[local]
|
||||
private predicate overlayHasXmlLocatable() {
|
||||
isOverlay() and
|
||||
exists(@xmllocatable l | not files(l, _) and not xmlNs(l, _, _, _))
|
||||
}
|
||||
|
||||
overlay[discard_entity]
|
||||
private predicate discardBaseXmlLocatable(@xmllocatable el) {
|
||||
// The XML extractor is currently not incremental, so if
|
||||
// the overlay contains any XML locatables, the overlay should
|
||||
// contain a full extraction and all XML locatables from base
|
||||
// should be discarded.
|
||||
baseXmlLocatable(el) and overlayHasXmlLocatable()
|
||||
overlayChangedFiles(baseConfigLocatable(el))
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ module;
|
||||
|
||||
import semmle.files.FileSystem
|
||||
private import codeql.xml.Xml
|
||||
private import semmle.code.java.Overlay
|
||||
|
||||
private module Input implements InputSig<File, Location> {
|
||||
class XmlLocatableBase = @xmllocatable or @xmlnamespaceable;
|
||||
@@ -69,3 +70,13 @@ private module Input implements InputSig<File, Location> {
|
||||
}
|
||||
|
||||
import Make<File, Location, Input>
|
||||
|
||||
private class DiscardableXmlAttribute extends DiscardableLocatable, @xmlattribute { }
|
||||
|
||||
private class DiscardableXmlElement extends DiscardableLocatable, @xmlelement { }
|
||||
|
||||
private class DiscardableXmlComment extends DiscardableLocatable, @xmlcomment { }
|
||||
|
||||
private class DiscardableXmlCharacters extends DiscardableLocatable, @xmlcharacters { }
|
||||
|
||||
private class DiscardableXmlDtd extends DiscardableLocatable, @xmldtd { }
|
||||
|
||||
Reference in New Issue
Block a user