1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/ufw_appinfo.md

165 lines
3.6 KiB
Markdown
Raw Normal View History

2021-04-23 08:26:00 -07:00
[Home](https://kellyjonbrazil.github.io/jc/)
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.ufw_appinfo"></a>
# jc.parsers.ufw\_appinfo
2021-04-23 08:26:00 -07:00
2022-03-04 13:27:39 -08:00
jc - JSON Convert `ufw app info [application]` command
2022-01-19 17:30:14 -08:00
output parser
2021-04-23 08:26:00 -07:00
2022-01-19 17:30:14 -08:00
Supports individual apps via `ufw app info [application]` and all apps list
via `ufw app info all`.
2022-01-19 17:30:14 -08:00
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.
2021-04-23 08:26:00 -07:00
Usage (cli):
2022-01-25 18:03:34 -08:00
$ ufw app info OpenSSH | jc --ufw-appinfo
2021-04-23 08:26:00 -07:00
2022-01-25 18:03:34 -08:00
or
2021-04-23 08:26:00 -07:00
2022-01-25 18:03:34 -08:00
$ jc ufw app info OpenSSH
2021-04-23 08:26:00 -07:00
Usage (module):
2022-01-25 18:03:34 -08:00
import jc
result = jc.parse('ufw_appinfo', ufw_appinfo_command_output)
2022-01-18 15:38:03 -08:00
2021-04-23 08:26:00 -07:00
Schema:
2022-01-25 18:03:34 -08:00
[
{
"profile": string,
"title": string,
"description": string,
"tcp_list": [
integer
],
"tcp_ranges": [
{
"start": integer, # [0]
"end": integer
}
],
"udp_list": [
integer
],
"udp_ranges": [
{
"start": integer, # [0]
"end": integer
}
],
"normalized_tcp_list": [
integers # [1]
],
"normalized_tcp_ranges": [
{
"start": integer, # [0]
"end": integers # [2]
}
],
"normalized_udp_list": [
integers # [1]
],
"normalized_udp_ranges": [
{
"start": integer, # [0]
"end": integers # [2]
}
]
}
]
[0] 'any' is converted to start/end: 0/65535
[1] duplicates and overlapping are removed
[2] overlapping are merged
Examples:
$ ufw app info MSN | jc --ufw-appinfo -p
[
{
"profile": "MSN",
"title": "MSN Chat",
"description": "MSN chat protocol (with file transfer and voice)",
"tcp_list": [
1863,
6901
],
"udp_list": [
1863,
6901
],
"tcp_ranges": [
{
"start": 6891,
"end": 6900
}
],
"normalized_tcp_list": [
1863,
6901
],
"normalized_tcp_ranges": [
{
"start": 6891,
"end": 6900
}
],
"normalized_udp_list": [
1863,
6901
]
}
]
$ ufw app info MSN | jc --ufw-appinfo -p -r
[
{
"profile": "MSN",
"title": "MSN Chat",
"description": "MSN chat protocol (with file transfer and voice)",
"tcp_list": [
"1863",
"6901"
],
"udp_list": [
"1863",
"6901"
],
"tcp_ranges": [
{
"start": "6891",
"end": "6900"
}
]
}
]
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.ufw_appinfo.parse"></a>
2022-03-05 12:15:14 -08:00
### parse
2022-01-25 17:07:47 -08:00
2021-04-23 08:26:00 -07:00
```python
2022-01-25 17:07:47 -08:00
def parse(data, raw=False, quiet=False)
2021-04-23 08:26:00 -07:00
```
Main text parsing function
2022-01-25 18:03:34 -08:00
Parameters:
2021-04-23 08:26:00 -07:00
2022-01-25 18:03:34 -08:00
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
2021-04-23 08:26:00 -07:00
2022-01-25 18:03:34 -08:00
Returns:
2021-04-23 08:26:00 -07:00
2022-01-25 18:03:34 -08:00
List of Dictionaries. Raw or processed structured data.
2021-04-23 08:26:00 -07:00
2022-01-25 19:18:54 -08:00
### Parser Information
2021-04-23 08:26:00 -07:00
Compatibility: linux
2022-07-16 20:52:19 -07:00
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)