mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
add ufw to docs
This commit is contained in:
@ -102,7 +102,7 @@ pip3 install jc
|
|||||||
| FreeBSD | `portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean` |
|
| FreeBSD | `portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean` |
|
||||||
| Ansible filter plugin | `ansible-galaxy collection install community.general` |
|
| Ansible filter plugin | `ansible-galaxy collection install community.general` |
|
||||||
|
|
||||||
> For more packages and binaries, see https://kellyjonbrazil.github.io/jc-packaging/.
|
> For more packages and binaries, see the [jc packaging](https://kellyjonbrazil.github.io/jc-packaging/) site.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
`jc` accepts piped input from `STDIN` and outputs a JSON representation of the previous command's output to `STDOUT`.
|
`jc` accepts piped input from `STDIN` and outputs a JSON representation of the previous command's output to `STDOUT`.
|
||||||
@ -182,6 +182,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
|
|||||||
- `--timedatectl` enables the `timedatectl status` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/timedatectl))
|
- `--timedatectl` enables the `timedatectl status` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/timedatectl))
|
||||||
- `--tracepath` enables the `tracepath` and `tracepath6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath))
|
- `--tracepath` enables the `tracepath` and `tracepath6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath))
|
||||||
- `--traceroute` enables the `traceroute` and `traceroute6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute))
|
- `--traceroute` enables the `traceroute` and `traceroute6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute))
|
||||||
|
- `--ufw` enables the `ufw status` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw))
|
||||||
- `--uname` enables the `uname -a` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uname))
|
- `--uname` enables the `uname -a` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uname))
|
||||||
- `--upower` enables the `upower` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/upower))
|
- `--upower` enables the `upower` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/upower))
|
||||||
- `--uptime` enables the `uptime` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime))
|
- `--uptime` enables the `uptime` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime))
|
||||||
|
@ -97,7 +97,6 @@ Examples:
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$ ping -c 3 -p ff cnn.com | jc --ping -p -r
|
$ ping -c 3 -p ff cnn.com | jc --ping -p -r
|
||||||
{
|
{
|
||||||
"destination_ip": "151.101.129.67",
|
"destination_ip": "151.101.129.67",
|
||||||
|
302
docs/parsers/ufw.md
Normal file
302
docs/parsers/ufw.md
Normal file
@ -0,0 +1,302 @@
|
|||||||
|
[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,
|
||||||
|
"to_transport": string, # null if to_service is set
|
||||||
|
"to_start_port": integer, # null if to_service is set
|
||||||
|
"to_end_port": integer, # null if to_service is set
|
||||||
|
"to_service": string, # null if any above are set
|
||||||
|
"from_ip": string,
|
||||||
|
"from_ip_prefix": integer,
|
||||||
|
"from_interface": string,
|
||||||
|
"from_transport": string, # null if from_service is set
|
||||||
|
"from_start_port": integer, # null if from_service is set
|
||||||
|
"from_end_port": integer, # null if from_service is set
|
||||||
|
"from_service": string, # null if any above are set
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ ufw status verbose numbered | jc --ufw -p
|
||||||
|
{
|
||||||
|
"status": "active",
|
||||||
|
"logging": "on",
|
||||||
|
"logging_level": "low",
|
||||||
|
"default": "deny (incoming), allow (outgoing), deny (routed)",
|
||||||
|
"new_profiles": "skip",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"action": "ALLOW",
|
||||||
|
"action_direction": "IN",
|
||||||
|
"index": 1,
|
||||||
|
"network_protocol": "ipv4",
|
||||||
|
"to_interface": "any",
|
||||||
|
"to_transport": "tcp",
|
||||||
|
"to_start_port": 22,
|
||||||
|
"to_end_port": 22,
|
||||||
|
"to_service": null,
|
||||||
|
"to_ip": "0.0.0.0",
|
||||||
|
"to_ip_prefix": "0",
|
||||||
|
"from_ip": "0.0.0.0",
|
||||||
|
"from_ip_prefix": "0",
|
||||||
|
"from_interface": "any",
|
||||||
|
"from_transport": "any",
|
||||||
|
"from_start_port": 0,
|
||||||
|
"from_end_port": 65535,
|
||||||
|
"from_service": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "ALLOW",
|
||||||
|
"action_direction": "IN",
|
||||||
|
"index": 2,
|
||||||
|
"network_protocol": "ipv6",
|
||||||
|
"to_interface": "any",
|
||||||
|
"to_transport": "tcp",
|
||||||
|
"to_start_port": 22,
|
||||||
|
"to_end_port": 22,
|
||||||
|
"to_service": null,
|
||||||
|
"to_ip": "::",
|
||||||
|
"to_ip_prefix": "0",
|
||||||
|
"from_ip": "::",
|
||||||
|
"from_ip_prefix": "0",
|
||||||
|
"from_interface": "any",
|
||||||
|
"from_transport": "any",
|
||||||
|
"from_start_port": 0,
|
||||||
|
"from_end_port": 65535,
|
||||||
|
"from_service": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "ALLOW",
|
||||||
|
"action_direction": "IN",
|
||||||
|
"index": 3,
|
||||||
|
"network_protocol": "ipv4",
|
||||||
|
"to_interface": "any",
|
||||||
|
"to_transport": null,
|
||||||
|
"to_service": "Apache Full",
|
||||||
|
"to_start_port": null,
|
||||||
|
"to_end_port": null,
|
||||||
|
"to_ip": "0.0.0.0",
|
||||||
|
"to_ip_prefix": "0",
|
||||||
|
"from_ip": "0.0.0.0",
|
||||||
|
"from_ip_prefix": "0",
|
||||||
|
"from_interface": "any",
|
||||||
|
"from_transport": "any",
|
||||||
|
"from_start_port": 0,
|
||||||
|
"from_end_port": 65535,
|
||||||
|
"from_service": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "ALLOW",
|
||||||
|
"action_direction": "IN",
|
||||||
|
"index": 4,
|
||||||
|
"network_protocol": "ipv6",
|
||||||
|
"to_interface": "any",
|
||||||
|
"to_ip": "2405:204:7449:49fc:f09a:6f4a:bc93:1955",
|
||||||
|
"to_ip_prefix": "128",
|
||||||
|
"to_transport": "any",
|
||||||
|
"to_start_port": 0,
|
||||||
|
"to_end_port": 65535,
|
||||||
|
"to_service": null,
|
||||||
|
"from_ip": "::",
|
||||||
|
"from_ip_prefix": "0",
|
||||||
|
"from_interface": "any",
|
||||||
|
"from_transport": "any",
|
||||||
|
"from_start_port": 0,
|
||||||
|
"from_end_port": 65535,
|
||||||
|
"from_service": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "ALLOW",
|
||||||
|
"action_direction": "IN",
|
||||||
|
"index": 5,
|
||||||
|
"network_protocol": "ipv4",
|
||||||
|
"to_interface": "en0",
|
||||||
|
"to_ip": "10.10.10.10",
|
||||||
|
"to_ip_prefix": "32",
|
||||||
|
"to_transport": "any",
|
||||||
|
"to_start_port": 0,
|
||||||
|
"to_end_port": 65535,
|
||||||
|
"to_service": null,
|
||||||
|
"from_ip": "0.0.0.0",
|
||||||
|
"from_ip_prefix": "0",
|
||||||
|
"from_interface": "any",
|
||||||
|
"from_transport": "any",
|
||||||
|
"from_start_port": 0,
|
||||||
|
"from_end_port": 65535,
|
||||||
|
"from_service": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
$ ufw status verbose numbered | jc --ufw -p -r
|
||||||
|
{
|
||||||
|
"status": "active",
|
||||||
|
"logging": "on",
|
||||||
|
"logging_level": "low",
|
||||||
|
"default": "deny (incoming), allow (outgoing), deny (routed)",
|
||||||
|
"new_profiles": "skip",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"action": "ALLOW",
|
||||||
|
"action_direction": "IN",
|
||||||
|
"index": "1",
|
||||||
|
"network_protocol": "ipv4",
|
||||||
|
"to_interface": "any",
|
||||||
|
"to_transport": "tcp",
|
||||||
|
"to_start_port": "22",
|
||||||
|
"to_end_port": "22",
|
||||||
|
"to_service": null,
|
||||||
|
"to_ip": "0.0.0.0",
|
||||||
|
"to_ip_prefix": "0",
|
||||||
|
"from_ip": "0.0.0.0",
|
||||||
|
"from_ip_prefix": "0",
|
||||||
|
"from_interface": "any",
|
||||||
|
"from_transport": "any",
|
||||||
|
"from_start_port": "0",
|
||||||
|
"from_end_port": "65535",
|
||||||
|
"from_service": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "ALLOW",
|
||||||
|
"action_direction": "IN",
|
||||||
|
"index": "2",
|
||||||
|
"network_protocol": "ipv6",
|
||||||
|
"to_interface": "any",
|
||||||
|
"to_transport": "tcp",
|
||||||
|
"to_start_port": "22",
|
||||||
|
"to_end_port": "22",
|
||||||
|
"to_service": null,
|
||||||
|
"to_ip": "::",
|
||||||
|
"to_ip_prefix": "0",
|
||||||
|
"from_ip": "::",
|
||||||
|
"from_ip_prefix": "0",
|
||||||
|
"from_interface": "any",
|
||||||
|
"from_transport": "any",
|
||||||
|
"from_start_port": "0",
|
||||||
|
"from_end_port": "65535",
|
||||||
|
"from_service": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "ALLOW",
|
||||||
|
"action_direction": "IN",
|
||||||
|
"index": "3",
|
||||||
|
"network_protocol": "ipv4",
|
||||||
|
"to_interface": "any",
|
||||||
|
"to_transport": null,
|
||||||
|
"to_service": "Apache Full",
|
||||||
|
"to_start_port": null,
|
||||||
|
"to_end_port": null,
|
||||||
|
"to_ip": "0.0.0.0",
|
||||||
|
"to_ip_prefix": "0",
|
||||||
|
"from_ip": "0.0.0.0",
|
||||||
|
"from_ip_prefix": "0",
|
||||||
|
"from_interface": "any",
|
||||||
|
"from_transport": "any",
|
||||||
|
"from_start_port": "0",
|
||||||
|
"from_end_port": "65535",
|
||||||
|
"from_service": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "ALLOW",
|
||||||
|
"action_direction": "IN",
|
||||||
|
"index": "4",
|
||||||
|
"network_protocol": "ipv6",
|
||||||
|
"to_interface": "any",
|
||||||
|
"to_ip": "2405:204:7449:49fc:f09a:6f4a:bc93:1955",
|
||||||
|
"to_ip_prefix": "128",
|
||||||
|
"to_transport": "any",
|
||||||
|
"to_start_port": "0",
|
||||||
|
"to_end_port": "65535",
|
||||||
|
"to_service": null,
|
||||||
|
"from_ip": "::",
|
||||||
|
"from_ip_prefix": "0",
|
||||||
|
"from_interface": "any",
|
||||||
|
"from_transport": "any",
|
||||||
|
"from_start_port": "0",
|
||||||
|
"from_end_port": "65535",
|
||||||
|
"from_service": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "ALLOW",
|
||||||
|
"action_direction": "IN",
|
||||||
|
"index": "5",
|
||||||
|
"network_protocol": "ipv4",
|
||||||
|
"to_interface": "en0",
|
||||||
|
"to_ip": "10.10.10.10",
|
||||||
|
"to_ip_prefix": "32",
|
||||||
|
"to_transport": "any",
|
||||||
|
"to_start_port": "0",
|
||||||
|
"to_end_port": "65535",
|
||||||
|
"to_service": null,
|
||||||
|
"from_ip": "0.0.0.0",
|
||||||
|
"from_ip_prefix": "0",
|
||||||
|
"from_interface": "any",
|
||||||
|
"from_transport": "any",
|
||||||
|
"from_start_port": "0",
|
||||||
|
"from_end_port": "65535",
|
||||||
|
"from_service": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
## 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)
|
@ -74,7 +74,7 @@ Returns:
|
|||||||
convert_to_int(value)
|
convert_to_int(value)
|
||||||
```
|
```
|
||||||
|
|
||||||
Converts string input to integer by stripping all non-numeric characters
|
Converts string and float input to int. Strips all non-numeric characters from strings.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ Returns:
|
|||||||
convert_to_float(value)
|
convert_to_float(value)
|
||||||
```
|
```
|
||||||
|
|
||||||
Converts string input to float by stripping all non-numeric characters
|
Converts string and int input to float. Strips all non-numeric characters from strings.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
|
BIN
jc/man/jc.1.gz
BIN
jc/man/jc.1.gz
Binary file not shown.
BIN
man/jc.1.gz
BIN
man/jc.1.gz
Binary file not shown.
Reference in New Issue
Block a user