Enha: remove non POSIX command 'realpath'
This commit is contained in:
45
tools.go
45
tools.go
@@ -500,27 +500,26 @@ func executeCommand(args map[string]string) []byte {
|
|||||||
|
|
||||||
func isCommandAllowed(command string) bool {
|
func isCommandAllowed(command string) bool {
|
||||||
allowedCommands := map[string]bool{
|
allowedCommands := map[string]bool{
|
||||||
"grep": true,
|
"grep": true,
|
||||||
"sed": true,
|
"sed": true,
|
||||||
"awk": true,
|
"awk": true,
|
||||||
"find": true,
|
"find": true,
|
||||||
"cat": true,
|
"cat": true,
|
||||||
"head": true,
|
"head": true,
|
||||||
"tail": true,
|
"tail": true,
|
||||||
"sort": true,
|
"sort": true,
|
||||||
"uniq": true,
|
"uniq": true,
|
||||||
"wc": true,
|
"wc": true,
|
||||||
"ls": true,
|
"ls": true,
|
||||||
"echo": true,
|
"echo": true,
|
||||||
"cut": true,
|
"cut": true,
|
||||||
"tr": true,
|
"tr": true,
|
||||||
"cp": true,
|
"cp": true,
|
||||||
"mv": true,
|
"mv": true,
|
||||||
"rm": true,
|
"rm": true,
|
||||||
"mkdir": true,
|
"mkdir": true,
|
||||||
"rmdir": true,
|
"rmdir": true,
|
||||||
"pwd": true,
|
"pwd": true,
|
||||||
"realpath": true,
|
|
||||||
}
|
}
|
||||||
return allowedCommands[command]
|
return allowedCommands[command]
|
||||||
}
|
}
|
||||||
@@ -778,14 +777,14 @@ var baseTools = []models.Tool{
|
|||||||
Type: "function",
|
Type: "function",
|
||||||
Function: models.ToolFunc{
|
Function: models.ToolFunc{
|
||||||
Name: "execute_command",
|
Name: "execute_command",
|
||||||
Description: "Execute a shell command safely. Use when you need to run system commands like grep sed awk find cat head tail sort uniq wc ls echo cut tr cp mv rm mkdir rmdir pwd realpath",
|
Description: "Execute a shell command safely. Use when you need to run system commands like grep sed awk find cat head tail sort uniq wc ls echo cut tr cp mv rm mkdir rmdir pwd",
|
||||||
Parameters: models.ToolFuncParams{
|
Parameters: models.ToolFuncParams{
|
||||||
Type: "object",
|
Type: "object",
|
||||||
Required: []string{"command"},
|
Required: []string{"command"},
|
||||||
Properties: map[string]models.ToolArgProps{
|
Properties: map[string]models.ToolArgProps{
|
||||||
"command": models.ToolArgProps{
|
"command": models.ToolArgProps{
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Description: "command to execute (only commands from whitelist are allowed: grep sed awk find cat head tail sort uniq wc ls echo cut tr cp mv rm mkdir rmdir pwd realpath",
|
Description: "command to execute (only commands from whitelist are allowed: grep sed awk find cat head tail sort uniq wc ls echo cut tr cp mv rm mkdir rmdir pwd",
|
||||||
},
|
},
|
||||||
"args": models.ToolArgProps{
|
"args": models.ToolArgProps{
|
||||||
Type: "string",
|
Type: "string",
|
||||||
|
|||||||
Reference in New Issue
Block a user