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

226 lines
5.6 KiB
Markdown
Raw Normal View History

2021-04-21 07:51:32 -07:00
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.ufw
jc - JSON CLI output utility `ufw status` command output parser
Usage (cli):
$ ufw status | jc --ufw
or
$ jc ufw status
Usage (module):
import jc.parsers.ufw
result = jc.parsers.ufw.parse(ufw_command_output)
Schema:
{
"status": string,
"logging": string,
"logging_level": string,
"default": string,
"new_profiles": string,
"rules": [
{
"action": string,
"action_direction": string, # null if blank
"index": integer, # null if blank
"network_protocol": string,
"to_ip": string,
"to_ip_prefix": integer,
"to_interface": string,
2021-04-25 20:49:35 -07:00
"to_transport": string,
"to_ports": [
integer
],
"to_port_ranges": [
{
"start": integer,
"end": integer
}
],
"to_service": string, # null if any to ports or port_ranges are set
2021-04-21 07:51:32 -07:00
"from_ip": string,
"from_ip_prefix": integer,
"from_interface": string,
2021-04-25 20:49:35 -07:00
"from_transport": string,
"from_ports": [
integer
],
"from_port_ranges": [
{
"start": integer,
"end": integer
}
],
"from_service": string, # null if any from ports or port_ranges are set
"comment": string # null if no comment
2021-04-21 07:51:32 -07:00
}
]
}
Examples:
2021-04-23 16:14:53 -07:00
$ ufw status verbose | jc --ufw -p
2021-04-21 07:51:32 -07:00
{
"status": "active",
"logging": "on",
"logging_level": "low",
2021-04-25 20:49:35 -07:00
"default": "deny (incoming), allow (outgoing), disabled (routed)",
2021-04-21 07:51:32 -07:00
"new_profiles": "skip",
"rules": [
{
"action": "ALLOW",
"action_direction": "IN",
2021-04-23 16:14:53 -07:00
"index": null,
2021-04-21 07:51:32 -07:00
"network_protocol": "ipv4",
"to_interface": "any",
2021-04-25 20:49:35 -07:00
"to_transport": "any",
2021-04-21 07:51:32 -07:00
"to_service": null,
2021-04-25 20:49:35 -07:00
"to_ports": [
22
],
2021-04-21 07:51:32 -07:00
"to_ip": "0.0.0.0",
"to_ip_prefix": 0,
"comment": null,
2021-04-21 07:51:32 -07:00
"from_ip": "0.0.0.0",
"from_ip_prefix": 0,
2021-04-21 07:51:32 -07:00
"from_interface": "any",
"from_transport": "any",
2021-04-25 20:49:35 -07:00
"from_port_ranges": [
{
"start": 0,
"end": 65535
}
],
2021-04-21 07:51:32 -07:00
"from_service": null
},
{
"action": "ALLOW",
"action_direction": "IN",
2021-04-23 16:14:53 -07:00
"index": null,
2021-04-25 20:49:35 -07:00
"network_protocol": "ipv4",
2021-04-21 07:51:32 -07:00
"to_interface": "any",
"to_transport": "tcp",
"to_service": null,
2021-04-25 20:49:35 -07:00
"to_ports": [
80,
443
],
2021-04-21 07:51:32 -07:00
"to_ip": "0.0.0.0",
"to_ip_prefix": 0,
"comment": null,
2021-04-21 07:51:32 -07:00
"from_ip": "0.0.0.0",
"from_ip_prefix": 0,
2021-04-21 07:51:32 -07:00
"from_interface": "any",
"from_transport": "any",
2021-04-25 20:49:35 -07:00
"from_port_ranges": [
{
"start": 0,
"end": 65535
}
],
2021-04-21 07:51:32 -07:00
"from_service": null
},
2021-04-25 20:49:35 -07:00
...
2021-04-21 07:51:32 -07:00
]
}
2021-04-23 16:14:53 -07:00
$ ufw status verbose | jc --ufw -p -r
2021-04-21 07:51:32 -07:00
{
"status": "active",
"logging": "on",
"logging_level": "low",
2021-04-25 20:49:35 -07:00
"default": "deny (incoming), allow (outgoing), disabled (routed)",
2021-04-21 07:51:32 -07:00
"new_profiles": "skip",
"rules": [
{
"action": "ALLOW",
"action_direction": "IN",
2021-04-23 16:14:53 -07:00
"index": null,
2021-04-21 07:51:32 -07:00
"network_protocol": "ipv4",
"to_interface": "any",
2021-04-25 20:49:35 -07:00
"to_transport": "any",
2021-04-21 07:51:32 -07:00
"to_service": null,
2021-04-25 20:49:35 -07:00
"to_ports": [
"22"
],
2021-04-21 07:51:32 -07:00
"to_ip": "0.0.0.0",
"to_ip_prefix": "0",
"comment": null,
2021-04-21 07:51:32 -07:00
"from_ip": "0.0.0.0",
"from_ip_prefix": "0",
"from_interface": "any",
"from_transport": "any",
2021-04-25 20:49:35 -07:00
"from_port_ranges": [
{
"start": "0",
"end": "65535"
}
],
2021-04-21 07:51:32 -07:00
"from_service": null
},
{
"action": "ALLOW",
"action_direction": "IN",
2021-04-23 16:14:53 -07:00
"index": null,
2021-04-25 20:49:35 -07:00
"network_protocol": "ipv4",
2021-04-21 07:51:32 -07:00
"to_interface": "any",
"to_transport": "tcp",
"to_service": null,
2021-04-25 20:49:35 -07:00
"to_ports": [
"80",
"443"
],
2021-04-21 07:51:32 -07:00
"to_ip": "0.0.0.0",
"to_ip_prefix": "0",
"comment": null,
2021-04-21 07:51:32 -07:00
"from_ip": "0.0.0.0",
"from_ip_prefix": "0",
"from_interface": "any",
"from_transport": "any",
2021-04-25 20:49:35 -07:00
"from_port_ranges": [
{
"start": "0",
"end": "65535"
}
],
2021-04-21 07:51:32 -07:00
"from_service": null
},
2021-04-25 20:49:35 -07:00
...
2021-04-21 07:51:32 -07:00
]
}
## 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
2021-12-01 16:12:51 -08:00
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)