Skip to content

Commit

Permalink
feat: add CheckBadCmd()
Browse files Browse the repository at this point in the history
  • Loading branch information
fufuok committed May 16, 2024
1 parent 3ffb9f8 commit bde92df
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmder/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmder
import (
"context"
"errors"
"strings"
"time"

"github.com/fufuok/utils"
Expand Down Expand Up @@ -68,3 +69,13 @@ func RunCmdWithContext(ctx context.Context, cmdArgs []string) cmd.Status {
}
}
}

// CheckBadCmd 检查命令是否包含潜在非法字符
func CheckBadCmd(s string) bool {
if strings.Contains(s, "&") || strings.Contains(s, "|") || strings.Contains(s, ";") ||
strings.Contains(s, "$") || strings.Contains(s, "'") || strings.Contains(s, "`") ||
strings.Contains(s, "(") || strings.Contains(s, ")") || strings.Contains(s, "\"") {
return true
}
return false
}

0 comments on commit bde92df

Please sign in to comment.