Skip to content

Commit 3709b5a

Browse files
committed
Broaden the requirements for an XML view
We have discovered XML views that have the namespace `sap.ui.core` instead of the documented `sap.ui.core.mvc`. To detect these XML views we now include root elements with: - the name `View`, and - a namespace `sap.ui.core.mvc`, or `sap.ui.core`, but with a namespace declaration for `sap.ui.core.mvc`.
1 parent 6342795 commit 3709b5a

File tree

1 file changed

+37
-5
lines changed
  • javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5

1 file changed

+37
-5
lines changed

javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/UI5View.qll

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,44 @@ class XmlBindingPath extends UI5BindingPath instanceof XmlAttribute {
399399
}
400400
}
401401

402+
class XmlRootElement extends XmlElement {
403+
XmlRootElement() { any(XmlFile f).getARootElement() = this }
404+
405+
/**
406+
* Returns a XML namespace declaration scoped to the element.
407+
*
408+
* The predicate relies on location information to determine the scope of the namespace declaration.
409+
* A XML element with the same starting line and column, but a larger ending line and column is considered the
410+
* scope of the namespace declaration.
411+
*/
412+
XmlNamespace getANamespaceDeclaration() {
413+
exists(Location elemLoc, Location nsLoc |
414+
elemLoc = this.getLocation() and
415+
nsLoc = result.getLocation()
416+
|
417+
elemLoc.getStartLine() = nsLoc.getStartLine() and
418+
elemLoc.getStartColumn() = nsLoc.getStartColumn() and
419+
(
420+
elemLoc.getEndLine() > nsLoc.getEndLine()
421+
or
422+
elemLoc.getEndLine() = nsLoc.getEndLine() and
423+
elemLoc.getEndColumn() > nsLoc.getEndColumn()
424+
)
425+
)
426+
}
427+
}
428+
402429
class XmlView extends UI5View, XmlFile {
403-
XmlElement root;
430+
XmlRootElement root;
404431

405432
XmlView() {
406433
root = this.getARootElement() and
407-
root.getNamespace().getUri() = "sap.ui.core.mvc" and
434+
(
435+
root.getNamespace().getUri() = "sap.ui.core.mvc"
436+
or
437+
root.getNamespace().getUri() = "sap.ui.core" and
438+
root.getANamespaceDeclaration().getUri() = "sap.ui.core.mvc"
439+
) and
408440
root.hasName("View")
409441
}
410442

@@ -510,7 +542,7 @@ abstract class UI5Control extends Locatable {
510542
CustomController getController() { result = this.getView().getController() }
511543
}
512544

513-
class XmlControl extends UI5Control, XmlElement {
545+
class XmlControl extends UI5Control instanceof XmlElement {
514546
XmlControl() { this.getParent+() = any(XmlView view) }
515547

516548
/** Get the qualified type string, e.g. `sap.m.SearchField` */
@@ -523,11 +555,11 @@ class XmlControl extends UI5Control, XmlElement {
523555
result = any(CustomControl control | control.getName() = this.getQualifiedType())
524556
}
525557

526-
override Location getLocation() { result = XmlElement.super.getLocation() }
558+
override Location getLocation() { result = this.(XmlElement).getLocation() }
527559

528560
override XmlFile getFile() { result = XmlElement.super.getFile() }
529561

530-
override UI5ControlProperty getAProperty(string name) { result = this.getAttribute(name) }
562+
override UI5ControlProperty getAProperty(string name) { result = this.(XmlElement).getAttribute(name) }
531563

532564
override CustomControl getDefinition() {
533565
result.getName() = this.getQualifiedType() and

0 commit comments

Comments
 (0)