You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/07/29 15:18:59 UTC

[GitHub] [inlong] dockerzhang commented on a diff in pull request #5225: [INLONG-5014][CodeQL] Fix the code scanning alerts exposed by CodeQL

dockerzhang commented on code in PR #5225:
URL: https://github.com/apache/inlong/pull/5225#discussion_r933377791


##########
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/master/web/MasterStatusCheckFilter.java:
##########
@@ -65,7 +69,10 @@ public void doFilter(ServletRequest request,
             if (TStringUtils.isNotBlank(req.getQueryString())) {
                 sBuilder.append("?").append(req.getQueryString());
             }
-            resp.sendRedirect(sBuilder.toString());
+            this.redirectWhiteList = sBuilder.toString();
+            if (redirectWhiteList.equals(sBuilder.toString())) {

Review Comment:
   refer to the following example
   ```
   public class UrlRedirect extends HttpServlet {
   	private static final String VALID_REDIRECT = "http://cwe.mitre.org/data/definitions/601.html";
   
   	protected void doGet(HttpServletRequest request, HttpServletResponse response)
   	throws ServletException, IOException {
   		// BAD: a request parameter is incorporated without validation into a URL redirect
   		response.sendRedirect(request.getParameter("target"));
   
   		// GOOD: the request parameter is validated against a known fixed string
   		if (VALID_REDIRECT.equals(request.getParameter("target"))) {
   			response.sendRedirect(VALID_REDIRECT);
   		}
   	}
   }
   ```
   I think it's better to add an expected URL rule to match the `sBuilder.toString()` to prevent unexpected values.



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org