Skip to content

Commit

Permalink
name-changed
Browse files Browse the repository at this point in the history
  • Loading branch information
yashbudhia committed Oct 6, 2024
1 parent 2b1a6a5 commit ec40c24
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions internal/server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ func (s *HTTPServer) CliHandler(w http.ResponseWriter, r *http.Request) {
return
}

// Check if the command is blacklisted
if err := util.IsBlacklistedCommand(diceCmd.Cmd); err != nil {
// Return the error message in the specified format
http.Error(w, errorResponse(fmt.Sprintf("ERR unknown command '%s'", diceCmd.Cmd)), http.StatusForbidden)
return
}
// Check if the command is blocklisted
if err := util.BlockListedCommand(diceCmd.Cmd); err != nil {
http.Error(w, errorResponse(fmt.Sprintf("ERR unknown command '%s'", diceCmd.Cmd)), http.StatusForbidden)
return
}


resp, err := s.DiceClient.ExecuteCommand(diceCmd)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ var blacklistedCommands = []string{
"LATENCY", "CLIENT", "SLEEP", "PERSIST",
}

// IsBlacklistedCommand checks if a command is blacklisted
func IsBlacklistedCommand(cmd string) error {
// 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 blacklisted")
return errors.New("command is blocklisted")
}
}
return nil
Expand Down

0 comments on commit ec40c24

Please sign in to comment.