thatmattlove / hyperglass

hyperglass is the network looking glass that tries to make the internet better.
https://hyperglass.dev
BSD 3-Clause Clear License
626 stars 94 forks source link

Unable to send command to MikroTik routers where syntax is: bgp-as-path~"^222,111\$" #268

Closed bbs2web closed 3 months ago

bbs2web commented 3 months ago

Deployment Type

Manual

Version

v2.0.3

Steps to Reproduce

Have configured directives.yaml with the custom command to match provided filter:

mikrotik_bgp_aspath: name: BGP AS Path rules:

The following command works as expected when I test manually: /ip route print detail where bgp-as-path~"^222,111\$" !routing-mark

PS: Yes, with the trailing backslash before the end of line ($) character. The regex appears to correctly validate, in that I receive no errors when entering ^222,111\$

Expected Behavior

Should return route details

Observed Behavior

Tries momentarily and then reports an error (Something went wrong.).

Configuration

org_name: Redacted
plugins: []
primary_asn: 64500
request_timeout: 90
site_description: Redacted Network Looking Glass
site_title: Redacted Network Looking Glass
web:
  dns_provider:
    name: cloudflare
  links:
   - title: PeeringDB
     url: https://www.peeringdb.com/asn/{primary_asn}
     side: left
     order: 0
   - title: Redacted
     url: https://www.inq.co.za
     side: left
     order: 1

Devices

- name: ZA, Johannesburg, Teraco, Isando
    address: redacted.co.za
    credential:
      username: hyperglasslg+ct140w
      password: ****************
    platform: mikrotik_routeros
    attrs:
      source4: 192.0.2.1
      source6: 2001:db8::1
    directives:
      - builtins: false
      - mikrotik_bgp_aspath
      - mikrotik_community
      - mikrotik_bgp_route
      - mikrotik_ping
      - mikrotik_traceroute

Logs

With HYPERGLASS_DEBUG and HYPERGLASS_DEV_MODE set to 'true' nothing is logged.

Same result when I try only entering the numbers of a random route's ASN.
Input: 13335

This should then be run as:
/ip route print detail where bgp-as-path~"13335" !routing-mark

PS: This command works when I test it manually.
bbs2web commented 3 months ago

Github escaping is making the expression difficult to read, the regex is two backslashes: image

Regex validation: image

PS: The following regex should hopefully be safer: ^(\^)?[0-9,]+(\\\$)?$