Skip to content

Commit b301afd

Browse files
committed
rename function isHTMLSanitized
1 parent 6d62945 commit b301afd

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -838,28 +838,29 @@ class UI5Control extends TUI5Control {
838838
string getControlTypeName() { result = this.getQualifiedType().replaceAll(".", "/") }
839839

840840
/**
841-
* Holds if the attribute `sanitizeContent`
842-
* in controls `sap.ui.core.HTML` and `sap.ui.richttexteditor.RichTextEditor`
843-
* is set to true and never set to false anywhere
841+
* Holds if the control content is sanitized for HTML
842+
* 'sap/ui/core/HTML' sanitized using the property 'sanitizeContent'
843+
* 'sap/ui/richttexteditor/RichTextEditor' sanitized using the property 'sanitizeValue'
844844
*/
845-
predicate isSanitizedControl() {
846-
not this = this.sanitizeContentSetTo(false) and
847-
(
848-
this.getControlTypeName() = "sap/ui/richttexteditor/RichTextEditor"
849-
or
850-
this.getControlTypeName() = "sap/ui/core/HTML" and
851-
this = this.sanitizeContentSetTo(true)
852-
)
845+
predicate isHTMLSanitized() {
846+
this.getControlTypeName() = "sap/ui/richttexteditor/RichTextEditor" and
847+
this.isSanitizePropertySetTo("sanitizeValue", true) and
848+
not this.isSanitizePropertySetTo("sanitizeValue", false)
849+
or
850+
this.getControlTypeName() = "sap/ui/core/HTML" and
851+
this.isSanitizePropertySetTo("sanitizeContent", true) and
852+
not this.isSanitizePropertySetTo("sanitizeContent", false)
853853
}
854854

855-
private predicate sanitizeContentSetTo(boolean val) {
856-
this.getAReference().getAPropertyWrite("sanitizeContent").getRhs().mayHaveBooleanValue(val)
855+
bindingset[propName, val]
856+
private predicate isSanitizePropertySetTo(string propName, boolean val) {
857+
/* 1. `sanitizeContent` attribute is set declaratively. */
858+
this.getProperty(propName).toString() = val.toString()
857859
or
858-
exists(CallNode setPropertyCall |
859-
setPropertyCall = this.getAReference().getAMemberCall("setProperty")
860-
|
861-
setPropertyCall.getArgument(0).getStringValue() = "sanitizeContent" and
862-
setPropertyCall.getArgument(1).mayHaveBooleanValue(val)
860+
/* 2. `sanitizeContent` attribute is set programmatically using setProperty(). */
861+
exists(CallNode node | node = this.getAReference().getAMemberCall("setProperty") |
862+
node.getArgument(0).getStringValue() = propName and
863+
not node.getArgument(1).mayHaveBooleanValue(val.booleanNot())
863864
)
864865
}
865866
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import javascript
22
import semmle.javascript.dataflow.DataFlow as StdLibDataFlow
33
import advanced_security.javascript.frameworks.ui5.UI5
4-
import advanced_security.javascript.frameworks.ui5.UI5View
54
import advanced_security.javascript.frameworks.ui5.RemoteFlowSources
65
import advanced_security.javascript.frameworks.ui5.dataflow.FlowSteps
76
private import PatchDataFlow
@@ -107,7 +106,7 @@ module UI5PathGraph<PathNodeSig ConfigPathNode, PathGraphSig<ConfigPathNode> Con
107106
}
108107

109108
UI5PathNode getAPrimaryHtmlISink() {
110-
not result.asUI5BindingPathNode().getControlDeclaration().isSanitizedControl() and
109+
not result.asUI5BindingPathNode().getControlDeclaration().isHTMLSanitized() and
111110
if
112111
this.asDataFlowNode() instanceof LocalModelContentBoundBidirectionallyToHtmlISinkControl or
113112
this.asDataFlowNode() instanceof UI5ExternalModel // TODO: Narrow it down to ExternalModelBoundToHtmlISinkControl

0 commit comments

Comments
 (0)