praetorian-inc / chariot-ui

Chariot Offensive Security Platform
https://preview.chariot.praetorian.com
MIT License
15 stars 6 forks source link

Need to display some form of error message for IPv6 CIDR #149

Closed peter-kwan closed 6 days ago

peter-kwan commented 1 week ago

Bug Description I put 2001:db8::/123 as a new seed and clicked Add. UI does nothing. IPv6 CIDR aren't supported now. We should display a toast stating as such.

storbeck commented 1 week ago

The reason the UI does nothing is because it failed form validation.

If the input does not follow the following regex, we prevent form submission.

  DOMAIN:
    /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?:\.\w+)?/,
  IPV4: /(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/,
  IPV6: /(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}/,
  CIDR: /(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(?:3[0-2]|[12]?[0-9])/,
  GIT_ORG: /https:\/\/github\.com\/([a-zA-Z\d-]+)/,

We reserve toast alerts for network-produced errors. Since we never send a network request for form validation errors, instead I have added messaging in place so the user can fix the input for resubmission.

https://github.com/praetorian-inc/chariot-ui/assets/449874/aed51179-a059-4806-a662-d4a223cbcbe4