MCPcopy Create free account
hub / github.com/astercloud/aster / isExcludedCommand

Method isExcludedCommand

pkg/sandbox/local.go:1033–1056  ·  view source on GitHub ↗

isExcludedCommand 检查命令是否在排除列表中

(cmd string)

Source from the content-addressed store, hash-verified

1031
1032// isExcludedCommand 检查命令是否在排除列表中
1033func (ls *LocalSandbox) isExcludedCommand(cmd string) bool {
1034 if len(ls.excludedCommands) == 0 {
1035 return false
1036 }
1037
1038 // 提取命令的第一个词(命令名)
1039 cmdParts := strings.Fields(cmd)
1040 if len(cmdParts) == 0 {
1041 return false
1042 }
1043 cmdName := cmdParts[0]
1044
1045 for _, excluded := range ls.excludedCommands {
1046 if cmdName == excluded {
1047 return true
1048 }
1049 // 支持路径形式的命令
1050 if strings.HasSuffix(cmdName, "/"+excluded) {
1051 return true
1052 }
1053 }
1054
1055 return false
1056}
1057
1058// execDirect 直接执行命令(排除命令,仍有基本安全检查)
1059func (ls *LocalSandbox) execDirect(ctx context.Context, cmd string, opts *ExecOptions) (*ExecResult, error) {

Callers 2

ExecMethod · 0.95

Calls

no outgoing calls

Tested by 1