From 9b8a06137c20c6fa112e0ce5830bec51edf39999 Mon Sep 17 00:00:00 2001 From: Roshan Khatri <117414976+roshkhatri@users.noreply.github.com> Date: Wed, 9 Oct 2024 21:20:47 -0700 Subject: [PATCH] Fix empty response for ACL CAT category subcommand for module defined categories (#1140) The module commands which were added to acl categories were getting skipped when `ACL CAT category` command was executed. This PR fixes the bug. Before: ``` 127.0.0.1:6379> ACL CAT foocategory (empty array) ``` After: ``` 127.0.0.1:6379> ACL CAT foocategory aclcheck.module.command.test.add.new.aclcategories ``` --------- Signed-off-by: Roshan Khatri Co-authored-by: Harkrishn Patro --- src/acl.c | 1 - tests/unit/moduleapi/aclcheck.tcl | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/acl.c b/src/acl.c index 14d9c6e6f..688820fd8 100644 --- a/src/acl.c +++ b/src/acl.c @@ -2760,7 +2760,6 @@ void aclCatWithFlags(client *c, dict *commands, uint64_t cflag, int *arraylen) { while ((de = dictNext(di)) != NULL) { struct serverCommand *cmd = dictGetVal(de); - if (cmd->flags & CMD_MODULE) continue; if (cmd->acl_categories & cflag) { addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname)); (*arraylen)++; diff --git a/tests/unit/moduleapi/aclcheck.tcl b/tests/unit/moduleapi/aclcheck.tcl index 1ea09a232..4c5a8380e 100644 --- a/tests/unit/moduleapi/aclcheck.tcl +++ b/tests/unit/moduleapi/aclcheck.tcl @@ -143,6 +143,10 @@ start_server {tags {"modules acl"}} { assert_equal [r acl DRYRUN j8 aclcheck.module.command.test.add.new.aclcategories] OK } + test {test if ACL CAT output for the new category is correct} { + assert_equal [r ACL CAT foocategory] aclcheck.module.command.test.add.new.aclcategories + } + test {test permission compaction and simplification for categories added by a module} { r acl SETUSER j9 on >password -@all +@foocategory -@foocategory catch {r ACL GETUSER j9} res