Skip to content

Commit 4f6bdde

Browse files
committed
Clean up code: remove unneeded definitions
1 parent 11a97a6 commit 4f6bdde

File tree

3 files changed

+19
-85
lines changed

3 files changed

+19
-85
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ private class InputControlInstantiation extends ElementInstantiation {
2626

2727
private module TrackPlaceAtCallConfigFlow = TaintTracking::Global<TrackPlaceAtCallConfig>;
2828

29-
class DataFromInstantiatedAndPlacedAtControl extends RemoteFlowSource, XssThroughDom::Source
30-
{
29+
class DataFromInstantiatedAndPlacedAtControl extends RemoteFlowSource, XssThroughDom::Source {
3130
InputControlInstantiation controlInstantiation;
3231
ControlPlaceAtCall placeAtCall;
3332

@@ -48,11 +47,6 @@ class DataFromInstantiatedAndPlacedAtControl extends RemoteFlowSource, XssThroug
4847
override string getSourceType() {
4948
result = "Data from an instantiated control placed in a DOM tree"
5049
}
51-
52-
ControlPlaceAtCall getPlaceAtCall() {
53-
// result = "TODO"
54-
none() // TODO
55-
}
5650
}
5751

5852
class LocalModelContentBoundBidirectionallyToSourceControl extends RemoteFlowSource {

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

Lines changed: 17 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -301,21 +301,25 @@ class CustomControl extends SapExtendCall {
301301

302302
class ControlPlaceAtCall extends MethodCallNode {
303303
ControlPlaceAtCall() {
304-
exists(SapElement ui5Control |
305-
/* 1. `this.placeAt(...)` in a custom control definition */
306-
this = ui5Control.asDefinition().getAThisNode().getAMemberCall("placeAt")
307-
or
308-
/*
309-
* 2. `new SomeControl(...).placeAt(...)` where
310-
* `SomeControl` may be UI5 library control or a custom control
311-
*/
304+
/* 1. `this.placeAt(...)` in a custom control definition. */
305+
exists(CustomControl control | this = control.getAThisNode().getAMemberCall("placeAt"))
306+
or
307+
/*
308+
* 2. `new SomeControl(...).placeAt(...)` where `SomeControl` may be UI5
309+
* library control or a custom control.
310+
*/
312311

313-
this = ui5Control.asInstantiation().getAMemberCall("placeAt")
314-
or
315-
// this = ui5Control.getParentElement*().asInstantiation().getAMemberCall("placeAt") or
316-
/* 3. `.byId(...).placeAt(...)` */
317-
this = ui5Control.asReference().getAMemberCall("placeAt")
312+
exists(ElementInstantiation controlInstantiation |
313+
this = controlInstantiation.getAMemberCall("placeAt")
318314
)
315+
or
316+
/*
317+
* 3. `oController.getView().byId(...).placeAt(...)` where
318+
* `oController.getView().byId(...)` is a reference to a library control
319+
* or a custom control.
320+
*/
321+
322+
exists(ControlReference controlReference | this = controlReference.getAMemberCall("placeAt"))
319323
}
320324

321325
string getDomElementId() { result = this.getArgument(0).getStringValue() }
@@ -1278,66 +1282,6 @@ private newtype TSapElement =
12781282
TReferenceOfElement(Reference reference) or
12791283
TInstantiationOfElement(ElementInstantiation newNode)
12801284

1281-
class SapElement extends TSapElement {
1282-
SapExtendCall asDefinition() { this = TDefinitionOfElement(result) }
1283-
1284-
Reference asReference() { this = TReferenceOfElement(result) }
1285-
1286-
ElementInstantiation asInstantiation() { this = TInstantiationOfElement(result) }
1287-
1288-
SapElement getParentElement() {
1289-
result.asReference() = this.asDefinition().(CustomControl).getController().getAViewReference() or
1290-
result.asReference() =
1291-
this.asReference().(ControlReference).getDefinition().getController().getAViewReference() or
1292-
result.asDefinition() = this.asReference().(ViewReference).getDefinition().getController() or
1293-
result.asDefinition() = this.asDefinition().(CustomController).getOwnerComponent() or
1294-
result.asDefinition() =
1295-
this.asReference().(ControllerReference).getDefinition().getOwnerComponent() or
1296-
/* ==================== exists(result.asInstantiation()) branches ==================== */
1297-
result.asInstantiation() =
1298-
this.asReference().(ControlReference).getAMemberCall(_).getAnArgument().getALocalSource() or
1299-
result.asInstantiation() =
1300-
this.asReference().(ControlReference).getAPropertyWrite().getRhs().getALocalSource()
1301-
// or
1302-
// result.asInstantiation() =
1303-
// this.asInstantiation().getAMemberCall(_).getAnArgument().getALocalSource() or
1304-
// result.asInstantiation() = this.asInstantiation().getAPropertyWrite().getRhs().getALocalSource() or
1305-
// result.asInstantiation() = this.asInstantiation().getAnArgument()
1306-
// TrackParentControlConfig::flow(this.asInstantiation())
1307-
/* =================================================================================== */
1308-
}
1309-
1310-
string getId() {
1311-
result = this.asInstantiation().getId()
1312-
or
1313-
/* TODO: Needs testing */
1314-
result =
1315-
this.asDefinition()
1316-
.(CustomControl)
1317-
.getMetadata()
1318-
.getProperty("id")
1319-
.getAPropertySource()
1320-
.getStringValue()
1321-
/*
1322-
* Note that because we cannot statically determine the ID of an element from the references alone,
1323-
* we do not implement the branch of `TReferenceOfElement`.
1324-
*/
1325-
1326-
}
1327-
1328-
string toString() {
1329-
result = this.asDefinition().toString() or
1330-
result = this.asReference().toString() or
1331-
result = this.asInstantiation().toString()
1332-
}
1333-
1334-
Location getLocation() {
1335-
result = this.asDefinition().getLocation() or
1336-
result = this.asReference().getLocation() or
1337-
result = this.asInstantiation().getLocation()
1338-
}
1339-
}
1340-
13411285
/**
13421286
* The property metadata found in an SapExtendCall.
13431287
*/

javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/dataflow/DataFlow.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,11 @@ module TrackPlaceAtCallConfig implements DataFlow::ConfigSig {
229229
*/
230230
predicate isSource(DataFlow::Node node) { node instanceof ElementInstantiation }
231231

232-
additional predicate isSinkWithPlaceAtCall(DataFlow::Node node, ControlPlaceAtCall placeAtCall) {
233-
node = placeAtCall
234-
}
235-
236232
/**
237233
* An "extension point" exposed from a parent element instantiation to
238234
* register a child to itself.
239235
*/
240-
predicate isSink(DataFlow::Node node) { isSinkWithPlaceAtCall(node, _) }
236+
predicate isSink(DataFlow::Node node) { node instanceof ControlPlaceAtCall }
241237

242238
/**
243239
* Step from data being written and the property that is being written to.

0 commit comments

Comments
 (0)