github-advanced-security[bot] commented on code in PR #11:
URL:
https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/pull/11#discussion_r2574831425
##########
src/main/java/org/apache/sling/serviceuser/webconsole/impl/ServiceUserWebConsolePlugin.java:
##########
@@ -553,16 +554,28 @@
private List<Pair<String, String>> getPrivileges(HttpServletRequest
request) {
List<Pair<String, String>> privileges = new ArrayList<>();
- List<String> params = Collections.list(request.getParameterNames());
+
+ List<String> params = new ArrayList<>();
+ // filter the parameter names
+ Enumeration<String> parameterNames = request.getParameterNames();
+ while (parameterNames.hasMoreElements()) {
+ String paramName = parameterNames.nextElement();
+ if (paramName.startsWith("acl-path-")) {
+ params.add(paramName);
+ }
+ }
for (String param : params) {
- if (param.startsWith("acl-path-")) {
- String path = request.getParameter(param);
- String privilege =
request.getParameter(param.replace("-path-", "-privilege-"));
- if (StringUtils.isNotBlank(path) &&
StringUtils.isNotBlank(privilege)) {
- privileges.add(new ImmutablePair<>(path, privilege));
+ String path = request.getParameter(param);
+ if (StringUtils.isEmpty(path)) {
+ log.warn("Unable to load ACL due to missing value for
parameter {}", param);
Review Comment:
## Logging should not be vulnerable to injection attacks
<!--SONAR_ISSUE_KEY:AZrWjBx7xbkIUrDe2Uvs-->Change this code to not log
user-controlled data. <p>See more on <a
href="https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-serviceuser-webconsole&issues=AZrWjBx7xbkIUrDe2Uvs&open=AZrWjBx7xbkIUrDe2Uvs&pullRequest=11">SonarQube
Cloud</a></p>
[Show more
details](https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/security/code-scanning/11)
##########
src/main/java/org/apache/sling/serviceuser/webconsole/impl/ServiceUserWebConsolePlugin.java:
##########
@@ -553,16 +554,28 @@
private List<Pair<String, String>> getPrivileges(HttpServletRequest
request) {
List<Pair<String, String>> privileges = new ArrayList<>();
- List<String> params = Collections.list(request.getParameterNames());
+
+ List<String> params = new ArrayList<>();
+ // filter the parameter names
+ Enumeration<String> parameterNames = request.getParameterNames();
+ while (parameterNames.hasMoreElements()) {
+ String paramName = parameterNames.nextElement();
+ if (paramName.startsWith("acl-path-")) {
+ params.add(paramName);
+ }
+ }
for (String param : params) {
- if (param.startsWith("acl-path-")) {
- String path = request.getParameter(param);
- String privilege =
request.getParameter(param.replace("-path-", "-privilege-"));
- if (StringUtils.isNotBlank(path) &&
StringUtils.isNotBlank(privilege)) {
- privileges.add(new ImmutablePair<>(path, privilege));
+ String path = request.getParameter(param);
+ if (StringUtils.isEmpty(path)) {
+ log.warn("Unable to load ACL due to missing value for
parameter {}", param);
+ } else {
+ String privilegeParam = param.replace("-path-", "-privilege-");
+ String privilege = request.getParameter(privilegeParam);
+ if (StringUtils.isEmpty(privilege)) {
+ log.warn("Unable to load ACL due to missing value for
parameter {}", privilegeParam);
Review Comment:
## Logging should not be vulnerable to injection attacks
<!--SONAR_ISSUE_KEY:AZrWjBx7xbkIUrDe2Uvr-->Change this code to not log
user-controlled data. <p>See more on <a
href="https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-serviceuser-webconsole&issues=AZrWjBx7xbkIUrDe2Uvr&open=AZrWjBx7xbkIUrDe2Uvr&pullRequest=11">SonarQube
Cloud</a></p>
[Show more
details](https://github.com/apache/sling-org-apache-sling-serviceuser-webconsole/security/code-scanning/10)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]