| 618 | } |
| 619 | |
| 620 | func cmdRules(c *apiClient) { |
| 621 | rules, err := c.getRules() |
| 622 | if err != nil { |
| 623 | fmt.Printf(" error: %v\n", err) |
| 624 | return |
| 625 | } |
| 626 | if len(rules) == 0 { |
| 627 | fmt.Println(" No injection rules configured.") |
| 628 | return |
| 629 | } |
| 630 | |
| 631 | fmt.Println() |
| 632 | fmt.Printf(" %-4s %-18s %-18s %-8s %-10s %-8s\n", "#", "Name", "ToolName", "Enabled", "Timing", "MaxInj") |
| 633 | printSep(70) |
| 634 | for i, r := range rules { |
| 635 | enabled := "yes" |
| 636 | if !r.Enabled { |
| 637 | enabled = "no" |
| 638 | } |
| 639 | maxInj := "1" |
| 640 | if r.MaxInjections > 0 { |
| 641 | maxInj = strconv.Itoa(r.MaxInjections) |
| 642 | } |
| 643 | fmt.Printf(" %-4d %-18s %-18s %-8s %-10s %-8s\n", i+1, r.Name, r.ToolName, enabled, r.Timing, maxInj) |
| 644 | } |
| 645 | fmt.Println() |
| 646 | } |
| 647 | |
| 648 | func cmdRulesAdd(c *apiClient) { |
| 649 | fmt.Println() |