(c *apiClient)
| 819 | } |
| 820 | |
| 821 | func cmdRulesDelete(c *apiClient) { |
| 822 | rules, err := c.getRules() |
| 823 | if err != nil { |
| 824 | fmt.Printf(" error: %v\n", err) |
| 825 | return |
| 826 | } |
| 827 | if len(rules) == 0 { |
| 828 | fmt.Println(" No injection rules to delete.") |
| 829 | return |
| 830 | } |
| 831 | |
| 832 | fmt.Println() |
| 833 | for i, r := range rules { |
| 834 | fmt.Printf(" %d) %s (tool: %s)\n", i+1, r.Name, r.ToolName) |
| 835 | } |
| 836 | |
| 837 | choice := interactiveReadLine("\n Delete rule #: ") |
| 838 | idx, err := strconv.Atoi(choice) |
| 839 | if err != nil || idx < 1 || idx > len(rules) { |
| 840 | fmt.Println(" invalid choice.") |
| 841 | return |
| 842 | } |
| 843 | |
| 844 | rule := rules[idx-1] |
| 845 | confirm := interactiveReadLine(fmt.Sprintf(" Delete '%s'? (y/n): ", rule.Name)) |
| 846 | if strings.ToLower(confirm) != "y" { |
| 847 | fmt.Println(" cancelled.") |
| 848 | return |
| 849 | } |
| 850 | |
| 851 | if err := c.deleteRule(rule.Name); err != nil { |
| 852 | fmt.Printf(" error: %v\n", err) |
| 853 | } else { |
| 854 | fmt.Println(" deleted.") |
| 855 | } |
| 856 | fmt.Println() |
| 857 | } |
| 858 | |
| 859 | // ----- observe command ----- |
| 860 |
no test coverage detected