@@ -5,7 +5,6 @@ private import semmle.javascript.security.dataflow.DomBasedXssCustomizations
55private import advanced_security.javascript.frameworks.ui5.UI5View
66
77module UI5 {
8-
98 bindingset [ this ]
109 private class JsonStringReader extends string {
1110 bindingset [ result ]
@@ -64,17 +63,17 @@ module UI5 {
6463
6564 string toString ( ) { result = this .getName ( ) + ": " + this .getRoot ( ) }
6665
67- predicate contains ( File file ) {
68- file .getParentContainer + ( ) = getRoot ( )
69- }
66+ predicate contains ( File file ) { file .getParentContainer + ( ) = getRoot ( ) }
7067 }
7168
7269 private string getAResourceRootConfig ( ) {
7370 result = any ( SapUiCoreScript script ) .getAttributeByName ( "data-sap-ui-resourceroots" ) .getValue ( )
7471 }
7572
7673 class SapUiCoreScript extends HTML:: ScriptElement {
77- SapUiCoreScript ( ) { this .getSourcePath ( ) .matches ( [ "%/sap-ui-core.js" , "%sap-ui-core-nojQuery.js" ] ) }
74+ SapUiCoreScript ( ) {
75+ this .getSourcePath ( ) .matches ( [ "%/sap-ui-core.js" , "%sap-ui-core-nojQuery.js" ] )
76+ }
7877
7978 ResourceRoot getAResourceRoot ( ) {
8079 result .getSource ( ) = this .getAttributeByName ( "data-sap-ui-resourceroots" ) .getValue ( )
@@ -88,8 +87,9 @@ module UI5 {
8887 /** A UI5 web application manifest associated with a bootstrapped UI5 web application. */
8988 class WebAppManifest extends File {
9089 WebApp webapp ;
90+
9191 WebAppManifest ( ) {
92- this .getBaseName ( ) = "manifest.json" and
92+ this .getBaseName ( ) = "manifest.json" and
9393 this .getParentContainer ( ) = webapp .getWebAppFolder ( )
9494 }
9595
@@ -100,34 +100,34 @@ module UI5 {
100100 class WebApp extends HTML:: HtmlFile {
101101 SapUiCoreScript coreScript ;
102102
103- WebApp ( ) {
104- coreScript .getFile ( ) = this
105- }
103+ WebApp ( ) { coreScript .getFile ( ) = this }
106104
107- File getAResource ( ) {
108- coreScript .getAResolvedResourceRoot ( ) .contains ( result )
109- }
105+ File getAResource ( ) { coreScript .getAResolvedResourceRoot ( ) .contains ( result ) }
110106
111107 File getResource ( string path ) {
112108 getWebAppFolder ( ) .getAbsolutePath ( ) + "/" + path = result .getAbsolutePath ( )
113109 }
114110
115- Folder getWebAppFolder ( ) {
116- result = this .getParentContainer ( )
117- }
111+ Folder getWebAppFolder ( ) { result = this .getParentContainer ( ) }
118112
119- WebAppManifest getManifest ( ) {
120- result .getWebapp ( ) = this
121- }
113+ WebAppManifest getManifest ( ) { result .getWebapp ( ) = this }
122114
123115 File getInitialModule ( ) {
124- exists ( string initialModuleResourcePath , string resolvedModulePath , ResolvedResourceRoot resourceRoot |
125- initialModuleResourcePath = coreScript .getAttributeByName ( "data-sap-ui-onInit" ) .getValue ( ) and coreScript .getAResolvedResourceRoot ( ) = resourceRoot and
126- resolvedModulePath = initialModuleResourcePath .regexpReplaceAll ( "^module\\s*:\\s*" , "" ) .replaceAll ( resourceRoot .getName ( ) , resourceRoot .getRoot ( ) .getAbsolutePath ( ) ) and
116+ exists (
117+ string initialModuleResourcePath , string resolvedModulePath ,
118+ ResolvedResourceRoot resourceRoot
119+ |
120+ initialModuleResourcePath = coreScript .getAttributeByName ( "data-sap-ui-onInit" ) .getValue ( ) and
121+ coreScript .getAResolvedResourceRoot ( ) = resourceRoot and
122+ resolvedModulePath =
123+ initialModuleResourcePath
124+ .regexpReplaceAll ( "^module\\s*:\\s*" , "" )
125+ .replaceAll ( resourceRoot .getName ( ) , resourceRoot .getRoot ( ) .getAbsolutePath ( ) ) and
127126 result .getAbsolutePath ( ) = resolvedModulePath + ".js"
128127 )
129128 }
130129 }
130+
131131 /**
132132 * https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.loader%23methods/sap.ui.loader.config
133133 */
@@ -169,9 +169,7 @@ module UI5 {
169169 )
170170 }
171171
172- WebApp getWebApp ( ) {
173- this .getFile ( ) = result .getAResource ( )
174- }
172+ WebApp getWebApp ( ) { this .getFile ( ) = result .getAResource ( ) }
175173
176174 SapDefineModule getExtendingDefine ( ) {
177175 exists ( Extension baseExtension , Extension subclassExtension , SapDefineModule subclassDefine |
@@ -386,9 +384,7 @@ module UI5 {
386384 */
387385 bindingset [ path]
388386 JsonObject resolveDirectPath ( string path ) {
389- exists ( WebApp webApp |
390- result .getJsonFile ( ) = webApp .getResource ( path )
391- )
387+ exists ( WebApp webApp | result .getJsonFile ( ) = webApp .getResource ( path ) )
392388 }
393389
394390 /**
@@ -593,14 +589,18 @@ module UI5 {
593589 result .getMethodName ( ) = "setProperty" and
594590 result .getArgument ( 0 ) .asExpr ( ) .( StringLiteral ) .getValue ( ) = propName and
595591 // TODO: in same controller
596- exists ( WebApp webApp | webApp .getAResource ( ) = this .getFile ( ) and webApp .getAResource ( ) = result .getFile ( ) )
592+ exists ( WebApp webApp |
593+ webApp .getAResource ( ) = this .getFile ( ) and webApp .getAResource ( ) = result .getFile ( )
594+ )
597595 }
598596
599597 bindingset [ propName]
600598 MethodCallNode getARead ( string propName ) {
601599 result .getMethodName ( ) = "get" + capitalize ( propName ) and
602600 // TODO: in same controller
603- exists ( WebApp webApp | webApp .getAResource ( ) = this .getFile ( ) and webApp .getAResource ( ) = result .getFile ( ) )
601+ exists ( WebApp webApp |
602+ webApp .getAResource ( ) = this .getFile ( ) and webApp .getAResource ( ) = result .getFile ( )
603+ )
604604 }
605605 }
606606}
0 commit comments