AddToWhitelist adds a command to the in-memory whitelist for a target type. This change is session-only and does not persist to the config file.
(targetType TargetType, command string)
| 297 | // AddToWhitelist adds a command to the in-memory whitelist for a target type. |
| 298 | // This change is session-only and does not persist to the config file. |
| 299 | func (e *Executor) AddToWhitelist(targetType TargetType, command string) { |
| 300 | switch targetType { |
| 301 | case TargetHost: |
| 302 | e.config.AllowedCommands.Host = append([]string{command}, e.config.AllowedCommands.Host...) |
| 303 | case TargetContainer: |
| 304 | e.config.AllowedCommands.Container = append([]string{command}, e.config.AllowedCommands.Container...) |
| 305 | case TargetVM: |
| 306 | e.config.AllowedCommands.VM = append([]string{command}, e.config.AllowedCommands.VM...) |
| 307 | } |
| 308 | // Refresh the validator so it picks up the new entry. |
| 309 | e.validator = NewValidator(e.config) |
| 310 | } |
| 311 | |
| 312 | // ExecuteCustomHostCommand executes an arbitrary command on a host via SSH without |
| 313 | // whitelist validation. The command must be non-interactive; sudo requiring a password |
no test coverage detected