From 4c98fd4b877c54e1cf7d285a29e178321be12f7e Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Fri, 23 Apr 2021 08:26:00 -0700 Subject: [PATCH] doc update --- docs/parsers/ufw_appinfo.md | 100 ++++++++++++++++++++++++++++++++++++ jc/parsers/ufw_appinfo.py | 2 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 docs/parsers/ufw_appinfo.md diff --git a/docs/parsers/ufw_appinfo.md b/docs/parsers/ufw_appinfo.md new file mode 100644 index 00000000..99b00694 --- /dev/null +++ b/docs/parsers/ufw_appinfo.md @@ -0,0 +1,100 @@ +[Home](https://kellyjonbrazil.github.io/jc/) + +# jc.parsers.ufw_appinfo +jc - JSON CLI output utility `ufw app info [application]` command output parser + +Because `ufw` application definitions allow overlapping ports and port ranges, this parser preserves that behavior, but also provides `normalized` lists and ranges that remove duplicate ports and merge overlapping ranges. + +Usage (cli): + + $ ufw app info OpenSSH | jc --ufw-appinfo + + or + + $ jc ufw app info OpenSSH + +Usage (module): + + import jc.parsers.ufw_appinfo + result = jc.parsers.ufw_appinfo.parse(ufw_appinfo_command_output) + +Schema: + + { + "profile": string, + "title": string, + "description": string, + "tcp_list": [ + integer + ], + "tcp_ranges": [ + { + "start": integer, # 'any' is converted to start/end: 0/65535 + "end": integer + } + ], + "udp_list": [ + integer + ], + "udp_ranges": [ + { + "start": integer, # 'any' is converted to start/end: 0/65535 + "end": integer + } + ], + "normalized_tcp_list": [ + integers # duplicates and overlapping are removed + ], + "normalized_tcp_ranges": [ + { + "start": integer, # 'any' is converted to start/end: 0/65535 + "end": integers # overlapping are merged + } + ], + "normalized_udp_list": [ + integers # duplicates and overlapping are removed + ], + "normalized_udp_ranges": [ + { + "start": integer, # 'any' is converted to start/end: 0/65535 + "end": integers # overlapping are merged + } + ] + } + +Examples: + + $ ufw app info OpenSSH | jc --ufw-appinfo -p + [] + + $ ufw app info OpenSSH | jc --ufw-appinfo -p -r + [] + + +## info +```python +info() +``` +Provides parser metadata (version, author, etc.) + +## parse +```python +parse(data, raw=False, quiet=False) +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + +Returns: + + Dictionary. Raw or processed structured data. + +## Parser Information +Compatibility: linux + +Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/jc/parsers/ufw_appinfo.py b/jc/parsers/ufw_appinfo.py index 52ab6cc5..161c67bc 100644 --- a/jc/parsers/ufw_appinfo.py +++ b/jc/parsers/ufw_appinfo.py @@ -49,7 +49,7 @@ Schema: } ], "normalized_udp_list": [ - integer + integers # duplicates and overlapping are removed ], "normalized_udp_ranges": [ {