@@ -187,6 +187,17 @@ predicate isBuiltInControl(string qualifiedTypeUri) {
187187 )
188188}
189189
190+ /**
191+ * A UI5 Fragment that might include XSS sources and sinks in standard controls.
192+ */
193+ abstract class UI5Fragment extends File {
194+ abstract UI5Control getControl ( ) ;
195+
196+ abstract UI5BindingPath getASource ( ) ;
197+
198+ abstract UI5BindingPath getAnHtmlISink ( ) ;
199+ }
200+
190201/**
191202 * A UI5 View that might include XSS sources and sinks in standard controls.
192203 */
@@ -683,8 +694,50 @@ class XmlView extends UI5View instanceof XmlFile {
683694 }
684695}
685696
697+ /**
698+ * TODO - consider - if this just copies all predicates - maybe this should be a subtype of XmlView
699+ * and we dont need a separate/parallel type for fragments vs views. this will become clear once
700+ */
701+ class XmlFragment extends UI5Fragment instanceof XmlFile {
702+ XmlRootElement root ;
703+
704+ XmlFragment ( ) {
705+ root = this .getARootElement ( ) and
706+ (
707+ root .getNamespace ( ) .getUri ( ) = "sap.m"
708+ or
709+ root .getNamespace ( ) .getUri ( ) = "sap.ui.core"
710+ ) and
711+ root .hasName ( "FragmentDefinition" )
712+ }
713+
714+ override UI5Control getControl ( ) {
715+ exists ( XmlElement element |
716+ result .asXmlControl ( ) = element and
717+ /* Use getAChild+ because some controls nest other controls inside them as aggregations */
718+ element = root .getAChild + ( ) and
719+ (
720+ /* 1. A builtin control provided by UI5 */
721+ isBuiltInControl ( element .getNamespace ( ) .getUri ( ) )
722+ or
723+ /* 2. A custom control with implementation code found in the webapp */
724+ exists ( CustomControl control |
725+ control .getName ( ) = element .getNamespace ( ) .getUri ( ) + "." + element .getName ( ) and
726+ inSameWebApp ( control .getFile ( ) , element .getFile ( ) )
727+ )
728+ )
729+ )
730+ }
731+
732+ override XmlBindingPath getASource ( ) { none ( ) }
733+
734+ override XmlBindingPath getAnHtmlISink ( ) { none ( ) }
735+ }
736+
686737private newtype TUI5Control =
687- TXmlControl ( XmlElement control ) or
738+ TXmlControl ( XmlElement control ) {
739+ control .getFile ( ) .getName ( ) .matches ( [ "%.view.xml" , "%.fragment.xml" ] )
740+ } or
688741 TJsonControl ( JsonObject control ) {
689742 exists ( JsonView view | control .getParent ( ) = view .getRoot ( ) .getPropValue ( "content" ) )
690743 } or
0 commit comments