[ https://issues.apache.org/jira/browse/GEODE-8583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17210318#comment-17210318 ]
ASF GitHub Bot commented on GEODE-8583: --------------------------------------- jhutchison commented on a change in pull request #5604: URL: https://github.com/apache/geode/pull/5604#discussion_r501859545 ########## File path: geode-redis/src/main/java/org/apache/geode/redis/internal/ParameterRequirements/RestrictedInputValuesParameterRequirements.java ########## @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.geode.redis.internal.ParameterRequirements; + +import java.util.List; + +import org.apache.geode.redis.internal.netty.Command; +import org.apache.geode.redis.internal.netty.ExecutionHandlerContext; + +public class RestrictedInputValuesParameterRequirements implements ParameterRequirements { + + List<String> allowedValues = null; + + public RestrictedInputValuesParameterRequirements(List<String> allowedValues) { + this.allowedValues = allowedValues; + } + + @Override + public void checkParameters(Command command, + ExecutionHandlerContext executionHandlerContext) { + List<byte[]> parameters = command.getProcessedCommand(); + String commandType = command.getCommandType().name(); + + parameters.forEach(parameter -> { + String parameterString = parameter.toString(); + if (isNotAllowed(parameterString) && + !parameterString.equalsIgnoreCase(commandType)) { Review comment: > This PR changes way too many files. I didn't look at all of them. But it should have only changed 2 or 3. > I'm not sure I like this change because now we have the parameters in two places. We still have the switch statement in InfoExecutor that checks for each one, but now we also have a list of them in another place (ALLOWED_INFO_COMMANDS). The other confusing thing is that the INFO command does allow other keywords it just ignores them. In native redis "INFO foobar" does not give an error but just returns nothing. But by adding a RestrictedInputValuesParameterRequirements to INFO it makes me think that any other params would cause an error. I'll double check, but the large number of files changed should be the result of my moving the RedisConstants class into a new subdirectory (because there is now another constants files to hold specifically allowed parameters , and it seemed to make sense to group them together). To be addressed below, I did forget to make the change to allow an error mesg for the class to be passed in as a parameter. As you say, for info, the error mesg will just be an empty string, but other commands can pass in other other err msgs as is appropriate to match native redis behavior. I still like having the logic for the commands in the executor for now. I see your point about the list of allowable commands being in 2 places. Ultimately I would like to use a singleton enum, but wasn't able to figure out how to make that work without some more playing around (let me know if you have thoughts) ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > create RestrictedInputValuesParameterRequirements in Redis Module > ----------------------------------------------------------------- > > Key: GEODE-8583 > URL: https://issues.apache.org/jira/browse/GEODE-8583 > Project: Geode > Issue Type: Improvement > Reporter: John Hutchison > Priority: Minor > Labels: pull-request-available, redis > -- This message was sent by Atlassian Jira (v8.3.4#803005)