diff options
author | Madelyn Olson <34459052+madolson@users.noreply.github.com> | 2022-03-15 18:21:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-15 18:21:13 -0700 |
commit | 416c9ac2ef5b7adfdfd83e2b98ec25de23f37627 (patch) | |
tree | 7f9396a965a800288a38c41c099ba3918d489f4e /tests/modules | |
parent | c30de7073cca2bc106a261a5ddfc8be546ea0e3d (diff) | |
download | redis-416c9ac2ef5b7adfdfd83e2b98ec25de23f37627.tar.gz |
Add module API for redacting command arguments (#10425)
Add module API for redacting client commands
Diffstat (limited to 'tests/modules')
-rw-r--r-- | tests/modules/auth.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/modules/auth.c b/tests/modules/auth.c index 040a447ec..612320dbc 100644 --- a/tests/modules/auth.c +++ b/tests/modules/auth.c @@ -54,6 +54,16 @@ int Auth_AuthRealUser(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { return RedisModule_ReplyWithLongLong(ctx, (uint64_t) client_id); } +/* This command redacts every other arguments and returns OK */ +int Auth_RedactedAPI(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { + REDISMODULE_NOT_USED(argv); + for(int i = argc - 1; i > 0; i -= 2) { + int result = RedisModule_RedactClientCommandArgument(ctx, i); + RedisModule_Assert(result == REDISMODULE_OK); + } + return RedisModule_ReplyWithSimpleString(ctx, "OK"); +} + int Auth_ChangeCount(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); @@ -87,6 +97,10 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) Auth_ChangeCount,"",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_CreateCommand(ctx,"auth.redact", + Auth_RedactedAPI,"",0,0,0) == REDISMODULE_ERR) + return REDISMODULE_ERR; + return REDISMODULE_OK; } |