Skip to content

Commit

Permalink
Merge pull request payara#6943 from kalinchan/FISH-9553
Browse files Browse the repository at this point in the history
FISH-9553 Sanitise properties in admin console
  • Loading branch information
kalinchan authored and Pandrex247 committed Sep 16, 2024
1 parent b22ad0e commit e873b39
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright 2018-2022 Payara Foundation and/or affiliates
// Portions Copyright 2018-2024 Payara Foundation and/or affiliates

/*
* UtilHandlers.java
Expand Down Expand Up @@ -1164,4 +1164,16 @@ public static String escapePropertyValue(String str){
}

private static final String PATH_SEPARATOR = "${path.separator}";

@Handler(id = "gf.sanitiseProperty",
input = {
@HandlerInput(name = "systemProperty", type = String.class, required = true)
},
output = {
@HandlerOutput(name = "result", type = String.class)
}
)
public static void sanitiseProperty(HandlerContext handlerCtx) {
handlerCtx.setOutputValue("result", escapePropertyValue(((String)handlerCtx.getInputValue("systemProperty"))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
only if the new code is made subject to such option by the copyright
holder.

Portions Copyright [2020] [Payara Foundation and/or its affiliates]
Portions Copyright [2020-2024] [Payara Foundation and/or its affiliates]
-->

<!initPage
Expand All @@ -59,8 +59,8 @@
setPageSessionAttribute(key="selfUrl", value="#{pageSession.parentUrl}/system-properties");
gf.restRequest(endpoint="#{sessionScope.REST_URL}/configs/config/#{pageSession.configName}/system-property/#{pageSession.propName}",
method="get", result="#{requestScope.result}");
setPageSessionAttribute(key="defaultValue", value="#{requestScope.result.data.extraProperties.entity.value}");

gf.sanitiseProperty(systemProperty="#{requestScope.result.data.extraProperties.entity.value}", result="#{currentVal}");
setPageSessionAttribute(key="defaultValue", value="#{currentVal}");
// Get instance to cluster mapping
createMap(result="#{requestScope.instanceMapping}");
gf.restRequest(endpoint="#{sessionScope.REST_URL}/clusters/cluster", method="get", result="#{requestScope.clusterResult}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
only if the new code is made subject to such option by the copyright
holder.

Portions Copyright [2018-2024] [Payara Foundation and/or its affiliates]
-->

<sun:table id="sysPropsTable" style="padding: 10pt" title="$resource{i18n.common.AdditionalProperties}"
Expand All @@ -62,7 +63,8 @@
foreach(var="prop", list="#{pageSession.sysProps}") {
createMap(result="#{row}");
mapPut(map="#{row}", key="name", value="#{prop.name}");
mapPut(map="#{row}", key="currentValue", value="#{!empty prop.value ? prop.value : prop.defaultValue}");
gf.sanitiseProperty(systemProperty="#{!empty prop.value ? prop.value : prop.defaultValue}", result="#{currentVal}");
mapPut(map="#{row}", key="currentValue", value="#{currentVal}");
mapPut(map="#{row}", key="overrideValue", value="#{!empty prop.value ? prop.value : ''}");
listAdd(list="#{pageSession.tableList}", value="#{row}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
only if the new code is made subject to such option by the copyright
holder.

Portions Copyright [2018-2024] [Payara Foundation and/or its affiliates]
-->

<!-- iiopServerPageNode.jsf -->
Expand All @@ -59,6 +60,8 @@
listAdd(value="#{pageSession.iiopListenerAttrs.data.extraProperties.entity['port']}" list="#{pageSession.iiopPortsList}");
}
gf.resolveTokens(tokens="#{pageSession.iiopPortsList}" endPoint="#{sessionScope.REST_URL}/servers/server/#{pageSession.instanceName}" resolvedTokens="#{pageSession.iiopResolvedPortsList}");
convertListToCommaString(list="#{pageSession.iiopResolvedPortsList}" commaString="#{pageSession.iiopPorts}");
convertListToCommaString(list="#{pageSession.iiopResolvedPortsList}" commaString="#{iiopPorts}");
gf.sanitiseProperty(systemProperty="#{iiopPorts}", result="#{pageSession.iiopPorts}");

/>
</sun:property>
5 changes: 3 additions & 2 deletions appserver/admingui/web/src/main/resources/serverPageNode.jsf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
only if the new code is made subject to such option by the copyright
holder.

Portions Copyright [2018] [Payara Foundation and/or its affiliates]
Portions Copyright [2018-2024] [Payara Foundation and/or its affiliates]
-->

<!-- serverPageNode.jsf -->
Expand All @@ -60,6 +60,7 @@
listAdd(value="#{pageSession.tmpPort}" list="#{pageSession.httpPortsList}");
}
gf.resolveTokens(tokens="#{pageSession.httpPortsList}" endPoint="#{sessionScope.REST_URL}/servers/server/#{pageSession.instanceName}" resolvedTokens="#{pageSession.httpResolvedPortsList}");
convertListToCommaString(list="#{pageSession.httpResolvedPortsList}" commaString="#{pageSession.httpPorts}");
convertListToCommaString(list="#{pageSession.httpResolvedPortsList}" commaString="#{portList}");
gf.sanitiseProperty(systemProperty="#{portList}", result="#{pageSession.httpPorts}");
/>
</sun:property>

0 comments on commit e873b39

Please sign in to comment.