Skip to content

Commit

Permalink
bool-applied
Browse files Browse the repository at this point in the history
  • Loading branch information
yashbudhia committed Oct 6, 2024
1 parent ec40c24 commit dffb232
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/util/blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ import (
"strings"
)

var blacklistedCommands = []string{
"FLUSHALL", "FLUSHDB", "DUMP", "ABORT", "AUTH", "CONFIG", "SAVE", "BGSAVE",
"BGREWRITEAOF", "RESTORE", "MULTI", "EXEC", "DISCARD", "QWATCH", "QUNWATCH",
"LATENCY", "CLIENT", "SLEEP", "PERSIST",
var blocklistedCommands = map[string]bool{
"FLUSHALL": true, "FLUSHDB": true, "DUMP": true, "ABORT": true, "AUTH": true,
"CONFIG": true, "SAVE": true, "BGSAVE": true, "BGREWRITEAOF": true, "RESTORE": true,
"MULTI": true, "EXEC": true, "DISCARD": true, "QWATCH": true, "QUNWATCH": true,
"LATENCY": true, "CLIENT": true, "SLEEP": true, "PERSIST": true,
}

// BlockListedCommand checks if a command is blocklisted
func BlockListedCommand(cmd string) error {
for _, blacklistedCmd := range blacklistedCommands {
if strings.ToUpper(cmd) == blacklistedCmd {
return errors.New("command is blocklisted")
}
if blocklistedCommands[strings.ToUpper(cmd)] {
return errors.New("command is blocklisted")
}
return nil
}

0 comments on commit dffb232

Please sign in to comment.