-
Notifications
You must be signed in to change notification settings - Fork 1k
chore(acl): Implicit categories #3411
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1530,68 +1530,36 @@ void StringFamily::ClThrottle(CmdArgList args, Transaction* tx, SinkReplyBuilder | |
|
||
#define HFUNC(x) SetHandler(&StringFamily::x) | ||
|
||
namespace acl { | ||
constexpr uint32_t kSet = WRITE | STRING | SLOW; | ||
constexpr uint32_t kSetEx = WRITE | STRING | SLOW; | ||
constexpr uint32_t kPSetEx = WRITE | STRING | SLOW; | ||
constexpr uint32_t kSetNx = WRITE | STRING | FAST; | ||
constexpr uint32_t kAppend = WRITE | STRING | FAST; | ||
constexpr uint32_t kPrepend = WRITE | STRING | FAST; | ||
constexpr uint32_t kIncr = WRITE | STRING | FAST; | ||
constexpr uint32_t kDecr = WRITE | STRING | FAST; | ||
constexpr uint32_t kIncrBy = WRITE | STRING | FAST; | ||
constexpr uint32_t kIncrByFloat = WRITE | STRING | FAST; | ||
constexpr uint32_t kDecrBy = WRITE | STRING | FAST; | ||
constexpr uint32_t kGet = READ | STRING | FAST; | ||
constexpr uint32_t kGetDel = WRITE | STRING | FAST; | ||
constexpr uint32_t kGetEx = WRITE | STRING | FAST; | ||
constexpr uint32_t kGetSet = WRITE | STRING | FAST; | ||
constexpr uint32_t kMGet = READ | STRING | FAST; | ||
constexpr uint32_t kMSet = WRITE | STRING | SLOW; | ||
constexpr uint32_t kMSetNx = WRITE | STRING | SLOW; | ||
constexpr uint32_t kStrLen = READ | STRING | FAST; | ||
constexpr uint32_t kGetRange = READ | STRING | SLOW; | ||
constexpr uint32_t kSubStr = READ | STRING | SLOW; | ||
constexpr uint32_t kSetRange = WRITE | STRING | SLOW; | ||
// ClThrottle is a module in redis. Therefore we introduce a new extension | ||
// to the category. We should consider other defaults as well | ||
constexpr uint32_t kClThrottle = THROTTLE; | ||
} // namespace acl | ||
|
||
void StringFamily::Register(CommandRegistry* registry) { | ||
constexpr uint32_t kMSetMask = | ||
CO::WRITE | CO::DENYOOM | CO::INTERLEAVED_KEYS | CO::NO_AUTOJOURNAL; | ||
|
||
registry->StartFamily(); | ||
*registry | ||
<< CI{"SET", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, -3, 1, 1, acl::kSet}.HFUNC(Set) | ||
<< CI{"SETEX", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, 4, 1, 1, acl::kSetEx}.HFUNC( | ||
SetEx) | ||
<< CI{"PSETEX", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, 4, 1, 1, acl::kPSetEx}.HFUNC( | ||
PSetEx) | ||
<< CI{"SETNX", CO::WRITE | CO::DENYOOM, 3, 1, 1, acl::kSetNx}.HFUNC(SetNx) | ||
<< CI{"APPEND", CO::WRITE | CO::DENYOOM | CO::FAST, 3, 1, 1, acl::kAppend}.HFUNC(Append) | ||
<< CI{"PREPEND", CO::WRITE | CO::DENYOOM | CO::FAST, 3, 1, 1, acl::kPrepend}.HFUNC(Prepend) | ||
<< CI{"INCR", CO::WRITE | CO::FAST, 2, 1, 1, acl::kIncr}.HFUNC(Incr) | ||
<< CI{"DECR", CO::WRITE | CO::FAST, 2, 1, 1, acl::kDecr}.HFUNC(Decr) | ||
<< CI{"INCRBY", CO::WRITE | CO::FAST, 3, 1, 1, acl::kIncrBy}.HFUNC(IncrBy) | ||
<< CI{"INCRBYFLOAT", CO::WRITE | CO::FAST, 3, 1, 1, acl::kIncrByFloat}.HFUNC(IncrByFloat) | ||
<< CI{"DECRBY", CO::WRITE | CO::FAST, 3, 1, 1, acl::kDecrBy}.HFUNC(DecrBy) | ||
<< CI{"GET", CO::READONLY | CO::FAST, 2, 1, 1, acl::kGet}.HFUNC(Get) | ||
<< CI{"GETDEL", CO::WRITE | CO::FAST, 2, 1, 1, acl::kGetDel}.HFUNC(GetDel) | ||
<< CI{"GETEX", CO::WRITE | CO::DENYOOM | CO::FAST | CO::NO_AUTOJOURNAL, -2, 1, 1, acl::kGetEx} | ||
.HFUNC(GetEx) | ||
<< CI{"GETSET", CO::WRITE | CO::DENYOOM | CO::FAST, 3, 1, 1, acl::kGetSet}.HFUNC(GetSet) | ||
<< CI{"MGET", CO::READONLY | CO::FAST | CO::IDEMPOTENT, -2, 1, -1, acl::kMGet}.HFUNC(MGet) | ||
<< CI{"MSET", kMSetMask, -3, 1, -1, acl::kMSet}.HFUNC(MSet) | ||
<< CI{"MSETNX", kMSetMask, -3, 1, -1, acl::kMSetNx}.HFUNC(MSetNx) | ||
<< CI{"STRLEN", CO::READONLY | CO::FAST, 2, 1, 1, acl::kStrLen}.HFUNC(StrLen) | ||
<< CI{"GETRANGE", CO::READONLY | CO::FAST, 4, 1, 1, acl::kGetRange}.HFUNC(GetRange) | ||
<< CI{"SUBSTR", CO::READONLY | CO::FAST, 4, 1, 1, acl::kSubStr}.HFUNC( | ||
GetRange) // Alias for GetRange | ||
<< CI{"SETRANGE", CO::WRITE | CO::FAST | CO::DENYOOM, 4, 1, 1, acl::kSetRange}.HFUNC(SetRange) | ||
<< CI{"CL.THROTTLE", CO::WRITE | CO::DENYOOM | CO::FAST, -5, 1, 1, acl::kClThrottle}.HFUNC( | ||
ClThrottle); | ||
registry->StartFamily(acl::STRING); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can create a class template that is implicitly convertible to |
||
*registry << CI{"SET", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, -3, 1, 1}.HFUNC(Set) | ||
<< CI{"SETEX", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, 4, 1, 1}.HFUNC(SetEx) | ||
<< CI{"PSETEX", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, 4, 1, 1}.HFUNC(PSetEx) | ||
<< CI{"SETNX", CO::WRITE | CO::DENYOOM | CO::FAST, 3, 1, 1}.HFUNC(SetNx) | ||
<< CI{"APPEND", CO::WRITE | CO::DENYOOM | CO::FAST, 3, 1, 1}.HFUNC(Append) | ||
<< CI{"PREPEND", CO::WRITE | CO::DENYOOM | CO::FAST, 3, 1, 1}.HFUNC(Prepend) | ||
<< CI{"INCR", CO::WRITE | CO::FAST, 2, 1, 1}.HFUNC(Incr) | ||
<< CI{"DECR", CO::WRITE | CO::FAST, 2, 1, 1}.HFUNC(Decr) | ||
<< CI{"INCRBY", CO::WRITE | CO::FAST, 3, 1, 1}.HFUNC(IncrBy) | ||
<< CI{"INCRBYFLOAT", CO::WRITE | CO::FAST, 3, 1, 1}.HFUNC(IncrByFloat) | ||
<< CI{"DECRBY", CO::WRITE | CO::FAST, 3, 1, 1}.HFUNC(DecrBy) | ||
<< CI{"GET", CO::READONLY | CO::FAST, 2, 1, 1}.HFUNC(Get) | ||
<< CI{"GETDEL", CO::WRITE | CO::FAST, 2, 1, 1}.HFUNC(GetDel) | ||
<< CI{"GETEX", CO::WRITE | CO::DENYOOM | CO::FAST | CO::NO_AUTOJOURNAL, -2, 1, 1}.HFUNC( | ||
GetEx) | ||
<< CI{"GETSET", CO::WRITE | CO::DENYOOM | CO::FAST, 3, 1, 1}.HFUNC(GetSet) | ||
<< CI{"MGET", CO::READONLY | CO::FAST | CO::IDEMPOTENT, -2, 1, -1}.HFUNC(MGet) | ||
<< CI{"MSET", kMSetMask, -3, 1, -1}.HFUNC(MSet) | ||
<< CI{"MSETNX", kMSetMask, -3, 1, -1}.HFUNC(MSetNx) | ||
<< CI{"STRLEN", CO::READONLY | CO::FAST, 2, 1, 1}.HFUNC(StrLen) | ||
<< CI{"GETRANGE", CO::READONLY, 4, 1, 1}.HFUNC(GetRange) | ||
<< CI{"SUBSTR", CO::READONLY, 4, 1, 1}.HFUNC(GetRange) // Alias for GetRange | ||
<< CI{"SETRANGE", CO::WRITE | CO::DENYOOM, 4, 1, 1}.HFUNC(SetRange) | ||
<< CI{"CL.THROTTLE", CO::WRITE | CO::DENYOOM | CO::FAST, -5, 1, 1, acl::THROTTLE}.HFUNC( | ||
ClThrottle); | ||
} | ||
|
||
} // namespace dfly |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 counter example to this is
HGETALL
which we mark as:which according to the rules above would mark it as
FAST
instead ofSLOW
.My concern here is that we have to manually check all of these commands and the
CO::
variants actually do map to the rules implemented inImplicitAclCategories
(and if the above mapping has no mistakes as well)Another concern I have is that if we have bugs in our
CO::
variants theImplicit
rules describe above will insert abugs
in our ACL rules.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 can apply that concern to any code, I've added an option to return acl categories from COMMAND, so we can compare before and after and see the differences
before.txt
It's not a counter example, we just remove CO::FAST. Again, the CO tags don't mean anything now
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.
Nice, in fact a
diff
on this will also hinter any errors. I like that