kellyjonbrazil / jc

CLI tool and python library that converts the output of popular command-line tools, file-types, and common strings to JSON, YAML, or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.
MIT License
7.91k stars 210 forks source link

Bug: Traceroute ignored IPs when multiple IPs on hop #560

Closed poclecoqq closed 5 months ago

poclecoqq commented 7 months ago

Description: When a hop in a traceroute has many IPs, the parser only considers the first IP it sees and ignores the others.

Given a traceroute with a line such as:

12  http://as15169-10g-sk1.sthix.net  (192.121.80.47) [*]  10.010 ms 72.14.196.42 (72.14.196.42) [AS15169]  9.182 ms  44.983 ms

we would expect jc to return (for that hop/line):

{
            "hop": 12,
            "probes": [
                {
                    "annotation": null,
                    "asn": null,
                    "ip": "192.121.80.47",
                    "name": "http://as15169-10g-sk1.sthix.net",
                    "rtt": 10.01
                },
                {
                    "annotation": null,
                    "asn": 15169,
                    "ip": "72.14.196.42",
                    "name": "72.14.196.42",
                    "rtt": 9.182
                },
                {
                    "annotation": null,
                    "asn": 15169,
                    "ip": "72.14.196.42",
                    "name": "72.14.196.42",
                    "rtt": 44.983
                }
            ]
},

instead, it currently returns (please compare the IP, name, and ASN fields):

        {
            "hop": 12,
            "probes": [
                {
                    "annotation": null,
                    "asn": 15169,
                    "ip": "192.121.80.47",
                    "name": "http://as15169-10g-sk1.sthix.net",
                    "rtt": 10.01
                },
                {
                    "annotation": null,
                    "asn": 15169,
                    "ip": "192.121.80.47",
                    "name": "http://as15169-10g-sk1.sthix.net",
                    "rtt": 9.182
                },
                {
                    "annotation": null,
                    "asn": 15169,
                    "ip": "192.121.80.47",
                    "name": "http://as15169-10g-sk1.sthix.net",
                    "rtt": 44.983
                }
            ]
        },

The example above is an extract from ./tests/fixtures/generic/traceroute1.out. I have already fixed that bug in a forked repository.

kellyjonbrazil commented 7 months ago

Thanks for reporting this. I created a PR from your fork and will take a look at merging that in.

kellyjonbrazil commented 6 months ago

This is fixed in the dev branch and will make it into the next release.

https://github.com/kellyjonbrazil/jc/blob/dev/jc/parsers/traceroute.py

You can test by copying the parser file above into your parser plugin folder:

kellyjonbrazil commented 5 months ago

Fixed in v1.25.3