(command string)
| 74 | } |
| 75 | |
| 76 | func CheckDestructiveWarnings(command string) []DestructiveWarning { |
| 77 | warnings := []DestructiveWarning{} |
| 78 | |
| 79 | for _, item := range destructivePatterns { |
| 80 | if item.Pattern.MatchString(command) { |
| 81 | warnings = append(warnings, DestructiveWarning{ |
| 82 | Category: item.Category, |
| 83 | Message: item.Message, |
| 84 | Pattern: item.Pattern.String(), |
| 85 | }) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | return warnings |
| 90 | } |
| 91 | |
| 92 | var absoluteDestroyPattern = regexp.MustCompile(`(?i)\brm\s+.*(?:-r|-rf|--recursive)\s+(?:/\s|/[\*]|~)`) |
| 93 |