Skip to content

Commit 7a020d2

Browse files
committed
Ensure that the channel name and the message types are matched
1 parent 969c218 commit 7a020d2

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

javascript/frameworks/ui5/ext/ui5.model.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ extensions:
7171
- ["UI5ClientStorage", "sap/ui/core/util/File", ""]
7272
- ["UI5ClientStorage", "global", "Member[sap].Member[ui].Member[core].Member[util].Member[File]"]
7373
# Publishing and Subscribing to Events
74-
- ["UI5PublishedEventData", "sap/ui/core/EventBus", "Member[getInstance].ReturnValue.Member[publish].Argument[2]"]
75-
- ["UI5EventSubscriptionHandlerDataParameter", "sap/ui/core/EventBus", "Member[getInstance].ReturnValue.Member[subscribe].Argument[2].Parameter[2]"]
74+
- ["UI5EventBusPublish", "sap/ui/core/EventBus", "Member[getInstance].ReturnValue.Member[publish]"]
75+
- ["UI5EventBusPublishedEventData", "UI5EventBusPublish", "Argument[2]"]
76+
- ["UI5EventBusSubscribe", "sap/ui/core/EventBus", "Member[getInstance].ReturnValue.Member[subscribe]"]
77+
- ["UI5EventSubscriptionHandlerDataParameter", "UI5EventBusSubscribe", "Argument[2].Parameter[2]"]
7678

7779
- addsTo:
7880
pack: codeql/javascript-all

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,29 @@ class LogArgumentToListener extends DataFlow::SharedFlowStep {
369369

370370
class PublishedEventToEventSubscribedEventData extends DataFlow::SharedFlowStep {
371371
override predicate step(DataFlow::Node start, DataFlow::Node end) {
372-
start = ModelOutput::getATypeNode("UI5PublishedEventData").getInducingNode() and
373-
end = ModelOutput::getATypeNode("UI5EventSubscriptionHandlerDataParameter").getInducingNode()
372+
exists(
373+
API::Node publishMethod, API::Node publishedData, API::Node subscribeMethod,
374+
API::Node subscribeMethodCallbackDataParameter
375+
|
376+
publishMethod = ModelOutput::getATypeNode("UI5EventBusPublish") and
377+
publishedData = ModelOutput::getATypeNode("UI5EventBusPublishedEventData") and
378+
subscribeMethod = ModelOutput::getATypeNode("UI5EventBusSubscribe") and
379+
subscribeMethodCallbackDataParameter =
380+
ModelOutput::getATypeNode("UI5EventSubscriptionHandlerDataParameter")
381+
|
382+
/* Ensure that `publishedData` belongs to `publishMethod`. */
383+
publishMethod.getASuccessor*() = publishedData and
384+
/* Ensure that `subscribeMethodCallbackDataParameter` belongs to `subscribeMethod`. */
385+
subscribeMethod.getASuccessor*() = subscribeMethodCallbackDataParameter and
386+
/* Ensure that the published and subscribed channels are the same. */
387+
publishMethod.getACall().getArgument(0).getALocalSource().getStringValue() =
388+
subscribeMethod.getACall().getArgument(0).getALocalSource().getStringValue() and
389+
/* Ensure that the published and subscribed message types are the same. */
390+
publishMethod.getACall().getArgument(1).getALocalSource().getStringValue() =
391+
subscribeMethod.getACall().getArgument(1).getALocalSource().getStringValue() and
392+
/* Wire into the start and end of this step. */
393+
start = publishedData.getInducingNode() and
394+
end = subscribeMethodCallbackDataParameter.getInducingNode()
395+
)
374396
}
375397
}

0 commit comments

Comments
 (0)