ValidateCommand valida um comando antes da execução
(cmd string)
| 193 | |
| 194 | // ValidateCommand valida um comando antes da execução |
| 195 | func (v *CommandValidator) ValidateCommand(cmd string) error { |
| 196 | if strings.TrimSpace(cmd) == "" { |
| 197 | return errors.New(i18n.T("agent.validator.empty_command")) |
| 198 | } |
| 199 | |
| 200 | if v.IsDangerous(cmd) { |
| 201 | // CORREÇÃO: Construir a string primeiro e passá-la como argumento para fmt.Errorf |
| 202 | errorMsg := i18n.T("agent.validator.dangerous_command", cmd) |
| 203 | return fmt.Errorf("%s", errorMsg) |
| 204 | } |
| 205 | |
| 206 | return nil |
| 207 | } |
| 208 | |
| 209 | // IsLikelyInteractive verifica se um comando provavelmente é interativo |
| 210 | func (v *CommandValidator) IsLikelyInteractive(cmd string) bool { |