From 70897e4ec5960a6422030e468beac252794e26e5 Mon Sep 17 00:00:00 2001 From: burningnode <19718295+burningnode@users.noreply.github.com> Date: Wed, 21 Feb 2018 19:38:13 +0100 Subject: [PATCH 01/13] Add files via upload Simple "get route" template for ScreenOS (Juniper NetScreen) --- templates/juniper_screenos_get_route.template | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 templates/juniper_screenos_get_route.template diff --git a/templates/juniper_screenos_get_route.template b/templates/juniper_screenos_get_route.template new file mode 100644 index 0000000000..984470c33b --- /dev/null +++ b/templates/juniper_screenos_get_route.template @@ -0,0 +1,18 @@ +Value Filldown VR (\S+) +Value BEST (\S) +Value ID (\d+) +Value Required PREFIX (\S+) +Value OUTINTERFACE (\S+) +Value NEXTHOP (\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}) +Value PROTOCOL (\w{1,2}) +Value PREF (\d+) +Value METRIC (\d+) +Value VSYS (\w+) + +Start + # Match the VR + ^IPv\d\s+Dest-routes\s+for\s+<${VR}> + # Match route line + ^${BEST}\s+${ID}\s+${PREFIX}\s+${OUTINTERFACE}\s+${NEXTHOP}\s+${PROTOCOL}\s+${PREF}\s+${METRIC}\s+${VSYS} -> Record + +EOF \ No newline at end of file From 300dbcee8ef7af69e6bf6c7ac601d086da00fabc Mon Sep 17 00:00:00 2001 From: burningnode <19718295+burningnode@users.noreply.github.com> Date: Wed, 21 Feb 2018 19:39:41 +0100 Subject: [PATCH 02/13] Add files via upload Adding screenos OS. --- .../get_route/juniper_screenos_get_route.parsed | 13 +++++++++++++ .../get_route/juniper_screenos_get_route.raw | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/juniper_screenos/get_route/juniper_screenos_get_route.parsed create mode 100644 tests/juniper_screenos/get_route/juniper_screenos_get_route.raw diff --git a/tests/juniper_screenos/get_route/juniper_screenos_get_route.parsed b/tests/juniper_screenos/get_route/juniper_screenos_get_route.parsed new file mode 100644 index 0000000000..fa7412fff1 --- /dev/null +++ b/tests/juniper_screenos/get_route/juniper_screenos_get_route.parsed @@ -0,0 +1,13 @@ +--- +parsed_sample: + +- vr: 'trust-vr' + best: '*' + id: '4' + prefix: '1.1.1.2/32' + outinterface: 'eth0/1' + nexthop: '0.0.0.0' + protocol: 'H' + pref: '0' + metric: '0' + vsys: 'Root' diff --git a/tests/juniper_screenos/get_route/juniper_screenos_get_route.raw b/tests/juniper_screenos/get_route/juniper_screenos_get_route.raw new file mode 100644 index 0000000000..bbc7e31fb3 --- /dev/null +++ b/tests/juniper_screenos/get_route/juniper_screenos_get_route.raw @@ -0,0 +1,15 @@ +IPv4 Dest-Routes for (0 entries) +---------------------------------------------------------------------- +H: Host C: Connected S: Static A: Auto-Exported +I: Imported R: RIP P: Permanent D: Auto-Discovered +iB: IBGP eB: EBGP O: OSPF E1: OSPF external type 1 +E2: OSPF external type 2 + +IPv4 Dest-Routes for (4 entries) +---------------------------------------------------------------------- + ID IP-Prefix Interface Gateway P Pref Mtr Vsys +---------------------------------------------------------------------- +* 4 1.1.1.2/32 eth0/1 0.0.0.0 H 0 0 Root +* 2 192.168.1.1/32 eth0/0 0.0.0.0 H 0 0 Root +* 1 192.168.1.0/24 eth0/0 0.0.0.0 C 0 0 Root +* 3 1.1.1.0/24 eth0/1 0.0.0.0 C 0 0 Root \ No newline at end of file From 4666a831c2e7793279fc2a28a1a72a7d4a665f3f Mon Sep 17 00:00:00 2001 From: burningnode <19718295+burningnode@users.noreply.github.com> Date: Wed, 21 Feb 2018 19:44:57 +0100 Subject: [PATCH 03/13] Update index Added line for juniper screenos --- templates/index | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/index b/templates/index index 2ae2af4848..7de90a494b 100644 --- a/templates/index +++ b/templates/index @@ -214,6 +214,8 @@ juniper_junos_show_isis_adjacency.template, .*, juniper_junos, sh[[ow]] is[[is]] juniper_junos_show_ospf_neighbor.template, .*, juniper_junos, sh[[ow]] ospf n[[eighbor]] juniper_junos_show_interfaces.template, .*, juniper_junos, sh[[ow]] inte[[rfaces]] +juniper_screenos_get_route.template, .*, juniper_screenos, get route + paloalto_panos_show_running_security-policy.template, .*, paloalto_panos, sh[[ow]] runn[[ing]] security[[-policy]] paloalto_panos_show_high-availability_all.template, .*, paloalto_panos, sh[[ow]] high[[-availability]] all paloalto_panos_show_interface_hardware.template, .*, paloalto_panos, sh[[ow]] int[[erface]] hard[[ware]] From 7bdf5a4171c0f8c7d9a3e4214095f5ae7ba34892 Mon Sep 17 00:00:00 2001 From: burningnode <19718295+burningnode@users.noreply.github.com> Date: Thu, 22 Feb 2018 08:22:00 +0100 Subject: [PATCH 04/13] Update juniper_screenos_get_route.template --- templates/juniper_screenos_get_route.template | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/juniper_screenos_get_route.template b/templates/juniper_screenos_get_route.template index 984470c33b..e8d3b10931 100644 --- a/templates/juniper_screenos_get_route.template +++ b/templates/juniper_screenos_get_route.template @@ -10,9 +10,9 @@ Value METRIC (\d+) Value VSYS (\w+) Start - # Match the VR - ^IPv\d\s+Dest-routes\s+for\s+<${VR}> - # Match route line - ^${BEST}\s+${ID}\s+${PREFIX}\s+${OUTINTERFACE}\s+${NEXTHOP}\s+${PROTOCOL}\s+${PREF}\s+${METRIC}\s+${VSYS} -> Record + # Match the VR + ^IPv\d\s+Dest-routes\s+for\s+<${VR}> + # Match route line + ^${BEST}\s+${ID}\s+${PREFIX}\s+${OUTINTERFACE}\s+${NEXTHOP}\s+${PROTOCOL}\s+${PREF}\s+${METRIC}\s+${VSYS} -> Record -EOF \ No newline at end of file +EOF From 77cb6bd8d2e7587500c21581e676d9d99cf3634a Mon Sep 17 00:00:00 2001 From: burningnode <19718295+burningnode@users.noreply.github.com> Date: Thu, 22 Feb 2018 08:31:43 +0100 Subject: [PATCH 05/13] Update juniper_screenos_get_route.template --- templates/juniper_screenos_get_route.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/juniper_screenos_get_route.template b/templates/juniper_screenos_get_route.template index e8d3b10931..9fbd4abd0c 100644 --- a/templates/juniper_screenos_get_route.template +++ b/templates/juniper_screenos_get_route.template @@ -11,7 +11,7 @@ Value VSYS (\w+) Start # Match the VR - ^IPv\d\s+Dest-routes\s+for\s+<${VR}> + ^IPv\d\s+Dest-Routes\s+for\s+<${VR}> # Match route line ^${BEST}\s+${ID}\s+${PREFIX}\s+${OUTINTERFACE}\s+${NEXTHOP}\s+${PROTOCOL}\s+${PREF}\s+${METRIC}\s+${VSYS} -> Record From 72edf3d3d07cce544b595a318b91a9412a23d613 Mon Sep 17 00:00:00 2001 From: burningnode <19718295+burningnode@users.noreply.github.com> Date: Thu, 22 Feb 2018 08:40:49 +0100 Subject: [PATCH 06/13] Update juniper_screenos_get_route.parsed Updated full parsed output --- .../juniper_screenos_get_route.parsed | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/juniper_screenos/get_route/juniper_screenos_get_route.parsed b/tests/juniper_screenos/get_route/juniper_screenos_get_route.parsed index fa7412fff1..b470ef9c77 100644 --- a/tests/juniper_screenos/get_route/juniper_screenos_get_route.parsed +++ b/tests/juniper_screenos/get_route/juniper_screenos_get_route.parsed @@ -11,3 +11,36 @@ parsed_sample: pref: '0' metric: '0' vsys: 'Root' + +- vr: 'trust-vr' + best: '*' + id: '2' + prefix: '192.168.1.1/32' + outinterface: 'eth0/0' + nexthop: '0.0.0.0' + protocol: 'H' + pref: '0' + metric: '0' + vsys: 'Root' + +- vr: 'trust-vr' + best: '*' + id: '1' + prefix: '192.168.1.0/24' + outinterface: 'eth0/0' + nexthop: '0.0.0.0' + protocol: 'C' + pref: '0' + metric: '0' + vsys: 'Root' + +- vr: 'trust-vr' + best: '*' + id: '3' + prefix: '1.1.1.0/24' + outinterface: 'eth0/1' + nexthop: '0.0.0.0' + protocol: 'C' + pref: '0' + metric: '0' + vsys: 'Root' From 01c8c752c079f9e875fcdd055b877404e1ddaf8d Mon Sep 17 00:00:00 2001 From: burningnode <19718295+burningnode@users.noreply.github.com> Date: Fri, 8 Jun 2018 19:40:19 +0200 Subject: [PATCH 07/13] Update juniper_screenos_get_route.template Added a few catching rules for garbage entries and the required catch all at the end. --- templates/juniper_screenos_get_route.template | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/juniper_screenos_get_route.template b/templates/juniper_screenos_get_route.template index 9fbd4abd0c..e32213c183 100644 --- a/templates/juniper_screenos_get_route.template +++ b/templates/juniper_screenos_get_route.template @@ -14,5 +14,9 @@ Start ^IPv\d\s+Dest-Routes\s+for\s+<${VR}> # Match route line ^${BEST}\s+${ID}\s+${PREFIX}\s+${OUTINTERFACE}\s+${NEXTHOP}\s+${PROTOCOL}\s+${PREF}\s+${METRIC}\s+${VSYS} -> Record - + ^--- + ^\w+ + ^\s+ + ^.+ -> Error "Line not found" + EOF From cad317605576c2f8dcef7e89918c078a2efd5545 Mon Sep 17 00:00:00 2001 From: Jacob McGill Date: Tue, 19 Jun 2018 13:13:02 -0400 Subject: [PATCH 08/13] Add escape character for matching literal '.' instead of anything --- templates/juniper_screenos_get_route.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/juniper_screenos_get_route.template b/templates/juniper_screenos_get_route.template index e32213c183..804cee1df0 100644 --- a/templates/juniper_screenos_get_route.template +++ b/templates/juniper_screenos_get_route.template @@ -3,7 +3,7 @@ Value BEST (\S) Value ID (\d+) Value Required PREFIX (\S+) Value OUTINTERFACE (\S+) -Value NEXTHOP (\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}) +Value NEXTHOP (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) Value PROTOCOL (\w{1,2}) Value PREF (\d+) Value METRIC (\d+) From 647ec67d9b527b98822edb952ae2109a07c080f4 Mon Sep 17 00:00:00 2001 From: Jacob McGill Date: Tue, 19 Jun 2018 13:14:12 -0400 Subject: [PATCH 09/13] Update matching of uninteresting lines to be more specific --- templates/juniper_screenos_get_route.template | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/templates/juniper_screenos_get_route.template b/templates/juniper_screenos_get_route.template index 804cee1df0..8ce662e6ec 100644 --- a/templates/juniper_screenos_get_route.template +++ b/templates/juniper_screenos_get_route.template @@ -14,9 +14,12 @@ Start ^IPv\d\s+Dest-Routes\s+for\s+<${VR}> # Match route line ^${BEST}\s+${ID}\s+${PREFIX}\s+${OUTINTERFACE}\s+${NEXTHOP}\s+${PROTOCOL}\s+${PREF}\s+${METRIC}\s+${VSYS} -> Record - ^--- - ^\w+ - ^\s+ - ^.+ -> Error "Line not found" + # Match table separator + ^-+\s*$$ + # Match route type keys + ^\S+:\s+ + # Match lines that are just space + ^\s+$$ + # ^.+ -> Error "Line not found" EOF From 6fb01428f0b27307200511585303cba783d3e678 Mon Sep 17 00:00:00 2001 From: Jacob McGill Date: Tue, 19 Jun 2018 13:17:46 -0400 Subject: [PATCH 10/13] Update capture groups to use preferred '\S' instead of '\w' --- templates/juniper_screenos_get_route.template | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/juniper_screenos_get_route.template b/templates/juniper_screenos_get_route.template index 8ce662e6ec..7c19f416e2 100644 --- a/templates/juniper_screenos_get_route.template +++ b/templates/juniper_screenos_get_route.template @@ -1,13 +1,13 @@ Value Filldown VR (\S+) -Value BEST (\S) +Value BEST (\S+) Value ID (\d+) Value Required PREFIX (\S+) Value OUTINTERFACE (\S+) Value NEXTHOP (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) -Value PROTOCOL (\w{1,2}) +Value PROTOCOL (\S+) Value PREF (\d+) Value METRIC (\d+) -Value VSYS (\w+) +Value VSYS (\S+) Start # Match the VR From 68abf33971020ed54857cfb4ba89102b598fd63b Mon Sep 17 00:00:00 2001 From: Jacob McGill Date: Mon, 25 Jun 2018 09:28:40 -0400 Subject: [PATCH 11/13] Uncomment error line --- templates/juniper_screenos_get_route.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/juniper_screenos_get_route.template b/templates/juniper_screenos_get_route.template index 7c19f416e2..9098f93a6c 100644 --- a/templates/juniper_screenos_get_route.template +++ b/templates/juniper_screenos_get_route.template @@ -20,6 +20,6 @@ Start ^\S+:\s+ # Match lines that are just space ^\s+$$ - # ^.+ -> Error "Line not found" + ^.+ -> Error "Line not found" EOF From a551cd2ca8f9a0aded2abce880f186cb0bda3777 Mon Sep 17 00:00:00 2001 From: Jacob McGill Date: Mon, 25 Jun 2018 09:29:06 -0400 Subject: [PATCH 12/13] add trailing newline --- tests/juniper_screenos/get_route/juniper_screenos_get_route.raw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/juniper_screenos/get_route/juniper_screenos_get_route.raw b/tests/juniper_screenos/get_route/juniper_screenos_get_route.raw index bbc7e31fb3..598c60128d 100644 --- a/tests/juniper_screenos/get_route/juniper_screenos_get_route.raw +++ b/tests/juniper_screenos/get_route/juniper_screenos_get_route.raw @@ -12,4 +12,4 @@ IPv4 Dest-Routes for (4 entries) * 4 1.1.1.2/32 eth0/1 0.0.0.0 H 0 0 Root * 2 192.168.1.1/32 eth0/0 0.0.0.0 H 0 0 Root * 1 192.168.1.0/24 eth0/0 0.0.0.0 C 0 0 Root -* 3 1.1.1.0/24 eth0/1 0.0.0.0 C 0 0 Root \ No newline at end of file +* 3 1.1.1.0/24 eth0/1 0.0.0.0 C 0 0 Root From 654bb41131cadee0eb9b107a3087e5c29a7a3bd0 Mon Sep 17 00:00:00 2001 From: Jacob McGill Date: Mon, 25 Jun 2018 09:44:53 -0400 Subject: [PATCH 13/13] Add match for table header --- templates/juniper_screenos_get_route.template | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/juniper_screenos_get_route.template b/templates/juniper_screenos_get_route.template index 9098f93a6c..6d1f363d62 100644 --- a/templates/juniper_screenos_get_route.template +++ b/templates/juniper_screenos_get_route.template @@ -20,6 +20,9 @@ Start ^\S+:\s+ # Match lines that are just space ^\s+$$ + # Match table header + ^\s+ID\s+IP-Prefix\s+Interface\s+Gateway\s+P\s+Pref\s+Mtr\s+Vsys\s*$$ + # Error out if line does not match any expressions ^.+ -> Error "Line not found" EOF