MCPcopy Create free account
hub / github.com/auth0/auth0-cli / checkIPCmd

Function checkIPCmd

internal/cli/ips.go:33–77  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

31}
32
33func checkIPCmd(cli *cli) *cobra.Command {
34 var inputs struct {
35 IP string
36 }
37
38 cmd := &cobra.Command{
39 Use: "check",
40 Args: cobra.MaximumNArgs(1),
41 Short: "Check IP address",
42 Long: "Check if a given IP address is blocked via the Suspicious IP Throttling due to " +
43 "multiple suspicious attempts.",
44 Example: ` auth0 protection suspicious-ip-throttling ips check
45 auth0 ap sit ips check <ip>
46 auth0 ap sit ips check "178.178.178.178"`,
47 RunE: func(cmd *cobra.Command, args []string) error {
48 if len(args) == 0 {
49 if err := ipAddress.Ask(cmd, &inputs.IP); err != nil {
50 return err
51 }
52 } else {
53 inputs.IP = args[0]
54 }
55
56 var isBlocked bool
57 if err := ansi.Waiting(func() (err error) {
58 isBlocked, err = cli.api.Anomaly.CheckIP(cmd.Context(), inputs.IP)
59 return err
60 }); err != nil {
61 return fmt.Errorf("failed to check if IP %q is blocked: %w", inputs.IP, err)
62 }
63
64 cli.renderer.Heading("ip")
65
66 if isBlocked {
67 cli.renderer.Infof("The IP %s is blocked", inputs.IP)
68 return nil
69 }
70
71 cli.renderer.Infof("The IP %s is not blocked.", inputs.IP)
72 return nil
73 },
74 }
75
76 return cmd
77}
78
79func unblockIPCmd(cli *cli) *cobra.Command {
80 var inputs struct {

Callers 1

ipsCmdFunction · 0.85

Calls 6

WaitingFunction · 0.92
CheckIPMethod · 0.80
ErrorfMethod · 0.80
HeadingMethod · 0.80
InfofMethod · 0.80
AskMethod · 0.45

Tested by

no test coverage detected