-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Support rename-command (#1817) #1822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
sazzad16
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use 2 spaces for a tab in entire implementation.
src/test/java/redis/clients/jedis/tests/commands/RenameProtocolCommandsTest.java
Outdated
Show resolved
Hide resolved
src/test/java/redis/clients/jedis/tests/commands/RenameProtocolCommandsTest.java
Outdated
Show resolved
Hide resolved
src/test/java/redis/clients/jedis/tests/commands/RenameProtocolCommandsTest.java
Outdated
Show resolved
Hide resolved
|
LGTM! |
|
What if we also add a Thoughts? |
|
@marcosnils Your provided link is about rename command which is already implemented in But this PR is about supporting rename-command of Redis Security. |
|
@smadasu you're right. How about if we add the |
I'm also concerned about that. But I couldn't find another way, let alone a better one, to support this feature. I can see only two options regarding this. Either use an available solution or leave that feature out from supporting. |
|
@marcosnils rename-command shouldn't be part of the API since as @sazzad16 mentioned a command is renamed using the Redis configuration file. Meaning, a user shouldn't really rename methods in runtime. @sazzad16 I think it will be a shame to leave this capability aside since command rename is a simple but efficient security method. Which indeed doesn't add any really security layer but protect from most of crawlers attacks. |
Right. Still the |
|
@marcosnils node_redis is doing it on client initialization |
|
Same with .NET client StackExchange.Redis |
|
@marcosnils I don't think our current design fit adding it constructor settings |
|
@marcosnils Don't know if it's relevant, but a note: currently, there is a way to alter localhost in Jedis which is done without constructor. |
|
@marcosnils I don't think #1787 will help here unless we also moving from Enums and make a bigger redesign. It's probably cleaner to do it as part of the constructor but are we ready to make this refactor? As @sazzad16 mentioned I think this pattern is already being used in the product for another rare use case so I think it can be a good compromise. |
I'm not against this change, I'm just trying to evaluate all other alternatives as I'm not 100% convinced about this approach. As you're saying, the I guess we could move forward with this approach and refactor it later in the future, but taking the opportunity that we'll be probably releasing 3.0 next, I'd like to take advantage of the interface breaking changes and do it the right way. |
| daemonize yes | ||
| protected-mode no | ||
| port 6386 | ||
| requirepass foobared |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test requires instance at 6386 port to be password-less. Either create a new instance or create a new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"a new instance or create a new one"? what is the different between "new instance" and "new one"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops!
"Either use password-less instance or create a new one."
|
@gkorland I vote to include this feature. IMO, adding solution for one configuration is far better than not having solution for multiple configuration. And I'm okay with your implementation. Not to mention, we've waited a year for an alternate solution. |
|
@gkorland @sazzad16 : When we configure Redis with Sentinel for HA, arent we suppoosed to configure the same Redis password in every instance. Isn't this expected already that we need to have same configuration across nodes. Also, can we conclude on the version in which this rename-command feature will be supported. |
Yes and No. Within same sentinel, it is expected that the nodes within that sentinel are of same configuration. For example, they are expected to have same password. But Jedis is not limited to connect with only one Redis instance/sentinel/cluster. It allows you to connect with many of them at once. So you can set up two different sentinels (two different group of nodes, say A and B) and connect with them simultaneously within same application using Jedis. Those two set of sentinel nodes are not required to have same configuration. For example, both set of nodes A and B are not required to have same password, even though all nodes of sentinel A are expected to have same password as well as all nodes of sentinel B are expected to have same password. I hope this clears your confusion about my statement. |
Not yet. |
|
@sazzad16 if we agree this solution is better than nothing, let's mark it as 3.2.0? |
|
@gkorland sure thing! @marcosnils It has been a year. Humbly speaking, we have waited enough for an alternate solution. |
| } | ||
|
|
||
| public void rename(final String newName) { | ||
| raw = SafeEncoder.encode(newName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this be an issue in multithreading? Synchronized/Lock may be required here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, but volatile should do, I'm trying to find a way to avoid the performance penalty on each getRaw() call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- +1 to volatile (or AtomicReference), at the moment it's not though, so we need to update that to either volatile or AtomicReference.
- We should make this fail (and have tests for) if
newNameis:- null
- empty
- an existing command name
| jedis.del("mykey"); | ||
| fail("'DEL' command should be unknown"); | ||
| } catch (JedisDataException expected) { | ||
| assertEquals("ERR unknown command 'DEL'", expected.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assertEquals("ERR unknown command 'DEL'", expected.getMessage()); | |
| // We need use a regex for the error message, because it may has different format | |
| // 1, ERR unknown command 'DEL' | |
| // 2, ERR unknown command `del`, with args beginning with: `abc` (Redis 6.2) | |
| Assert.assertTrue(expected.getMessage().matches("ERR unknown command .DEL.*")); |
| } | ||
|
|
||
| public void rename(final String newName) { | ||
| raw = SafeEncoder.encode(newName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- +1 to volatile (or AtomicReference), at the moment it's not though, so we need to update that to either volatile or AtomicReference.
- We should make this fail (and have tests for) if
newNameis:- null
- empty
- an existing command name
|
@gkorland Command renaming is deprecated in Redis. See redis/redis@7604ab7 |
|
Lets close |
No description provided.