Skip to content

Commit 1ca3c1c

Browse files
committed
Turn draft predicates into class member predicates
1 parent 19e9deb commit 1ca3c1c

File tree

1 file changed

+35
-41
lines changed
  • javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5

1 file changed

+35
-41
lines changed

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

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -204,52 +204,46 @@ class SapDefineModule extends AmdModuleDefinition::Range, MethodCallExpr, UserMo
204204
// )
205205
none() // TODO
206206
}
207-
}
208207

209-
/**
210-
* Holds if the `importingModule` "imports" the `importedModule` via path `importPath`.
211-
*/
212-
private predicate importerAndImportee(
213-
SapDefineModule importingModule, SapDefineModule importedModule, string importPath
214-
) {
215-
/* 1. Absolute import paths: We resolve this ourselves. */
216-
exists(string importedModuleDefinitionPath, string importedModuleDefinitionPathSlashNormalized |
208+
/**
209+
* Gets the module that this module imports via path `importPath`.
210+
*/
211+
SapDefineModule getImportedModule(string importPath) {
212+
/* 1. Absolute import paths: We resolve this ourselves. */
213+
exists(string importedModuleDefinitionPath, string importedModuleDefinitionPathSlashNormalized |
214+
/*
215+
* Let `importPath` = "my/app/path1/path2/controller/Some.controller",
216+
* `importedModuleDefinitionPath` = "my.app.path1.path2.controller.Some",
217+
* `importedModuleDefinitionPathSlashNormalized` = "my/app/path1/path2/controller/Some".
218+
* Then, `importedModuleDefinitionPathSlashNormalized` matches `importPath`.
219+
*/
220+
221+
importPath = this.asModule().getAnImport().getImportedPathExpr().getStringValue() and
222+
importedModuleDefinitionPath = result.getExtendCall().getName() and
223+
importedModuleDefinitionPathSlashNormalized =
224+
importedModuleDefinitionPath.replaceAll(".", "/") and
225+
importPath.matches(importedModuleDefinitionPathSlashNormalized + "%")
226+
)
227+
or
217228
/*
218-
* Let `importPath` = "my/app/path1/path2/controller/Some.controller",
219-
* `importedModuleDefinitionPath` = "my.app.path1.path2.controller.Some",
220-
* `importedModuleDefinitionPathSlashNormalized` = "my/app/path1/path2/controller/Some".
221-
* Then, `importedModuleDefinitionPathSlashNormalized` matches `importPath`.
229+
* 2. Relative import paths: We delegate the heaving lifting of resolving to
230+
* `Import.resolveImportedPath/0`.
222231
*/
223232

224-
importPath = importingModule.asModule().getAnImport().getImportedPathExpr().getStringValue() and
225-
importedModuleDefinitionPath = importedModule.getExtendCall().getName() and
226-
importedModuleDefinitionPathSlashNormalized = importedModuleDefinitionPath.replaceAll(".", "/") and
227-
importPath.matches(importedModuleDefinitionPathSlashNormalized + "%")
228-
)
229-
or
230-
/*
231-
* 2. Relative import paths: We delegate the heaving lifting of resolving to
232-
* `Import.resolveImportedPath/0`.
233-
*/
234-
235-
exists(Import import_ |
236-
importPath = import_.getImportedPathExpr().getStringValue() and
237-
import_ = importingModule.asModule().getAnImport() and
238-
import_.resolveImportedPath() = importedModule.getTopLevel()
239-
)
240-
}
233+
exists(Import import_ |
234+
importPath = import_.getImportedPathExpr().getStringValue() and
235+
import_ = this.asModule().getAnImport() and
236+
import_.resolveImportedPath() = result.getTopLevel()
237+
)
238+
}
241239

242-
/**
243-
* Holds if the `importingModule` extends the `importedModule`, imported via path `importPath`.
244-
*/
245-
private predicate importerExtendsImportee(
246-
SapDefineModule importingModule, SapDefineModule importedModule, string importPath
247-
) {
248-
importerAndImportee(importingModule, importedModule, importPath) and
249-
importingModule
250-
.getRequiredObject(importPath)
251-
.asSourceNode()
252-
.flowsTo(importingModule.getExtendCall().getReceiver())
240+
/**
241+
* Holds if the `importingModule` extends the `importedModule`, imported via path `importPath`.
242+
*/
243+
SapDefineModule getSuperModule(string importPath) {
244+
result = this.getImportedModule(importPath) and
245+
this.getRequiredObject(importPath).asSourceNode().flowsTo(this.getExtendCall().getReceiver())
246+
}
253247
}
254248

255249
class JQuerySap extends DataFlow::SourceNode {

0 commit comments

Comments
 (0)