| 55 | } |
| 56 | |
| 57 | func GetSimpleCommandPrefix(command string) string { |
| 58 | cleaned := StripAllSafeEnvPrefixes(command) |
| 59 | tokens := Tokenize(cleaned, false) |
| 60 | if len(tokens) == 0 { |
| 61 | return "" |
| 62 | } |
| 63 | base := tokens[0] |
| 64 | if idx := strings.LastIndex(base, "/"); idx >= 0 { |
| 65 | base = base[idx+1:] |
| 66 | } |
| 67 | if blockedRulePrefixes[base] || len(tokens) < 2 || strings.HasPrefix(tokens[1], "-") { |
| 68 | if base == "git" && len(tokens) >= 4 && tokens[1] == "-c" { |
| 69 | return "git " + tokens[3] |
| 70 | } |
| 71 | return "" |
| 72 | } |
| 73 | return base + " " + tokens[1] |
| 74 | } |
| 75 | |
| 76 | func AggregateCompoundPermissions(subResults []PermissionResult) PermissionResult { |
| 77 | if len(subResults) == 0 { |