mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
20
CHANGELOG
20
CHANGELOG
@ -1,5 +1,25 @@
|
|||||||
jc changelog
|
jc changelog
|
||||||
|
|
||||||
|
20221107 v1.22.2
|
||||||
|
- add `sshd_conf` parser for `sshd` configuration files and `sshd -T` output
|
||||||
|
- add `findmnt` command parser
|
||||||
|
- add `git ls-remote` command parser
|
||||||
|
- add `os-prober` command parser
|
||||||
|
- add SemVer string parser
|
||||||
|
- enhance the `ifconfig` parser so it can output multiple IPv4 and IPv6 addresses
|
||||||
|
- enhance the `ifconfig` parser so it can output additional fields common on BSD
|
||||||
|
- enhance `xml` parser with optional `_` prefix for attributes instead of
|
||||||
|
`@` by using the `--raw` option. This can make it easier to filter the
|
||||||
|
JSON output in some tools.
|
||||||
|
- fix the `xml` parser to output a normal Dictionary instead of OrderdDict.
|
||||||
|
This cleans up YAML output. (No `!!omap` comments)
|
||||||
|
- fix `csv` and `csv-s` parsers for UTF-8 encoded CSV files with leading BOM bytes
|
||||||
|
- fix exit code to be non-zero on interrupt
|
||||||
|
- allow parser module objects to be used as arguments to `jc.get_help()` and `jc.parser_info()`
|
||||||
|
- catch unexpected exceptions in the CLI
|
||||||
|
- add error message on interrupt to STDERR
|
||||||
|
- add python 3.11 tests to github actions
|
||||||
|
|
||||||
20221024 v1.22.1
|
20221024 v1.22.1
|
||||||
- add `udevadm` command parser
|
- add `udevadm` command parser
|
||||||
- add `lspci` command parser
|
- add `lspci` command parser
|
||||||
|
@ -180,11 +180,13 @@ option.
|
|||||||
| `--email-address` | Email Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/email_address) |
|
| `--email-address` | Email Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/email_address) |
|
||||||
| ` --env` | `env` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/env) |
|
| ` --env` | `env` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/env) |
|
||||||
| ` --file` | `file` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/file) |
|
| ` --file` | `file` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/file) |
|
||||||
|
| ` --findmnt` | `findmnt` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/findmnt) |
|
||||||
| ` --finger` | `finger` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/finger) |
|
| ` --finger` | `finger` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/finger) |
|
||||||
| ` --free` | `free` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/free) |
|
| ` --free` | `free` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/free) |
|
||||||
| ` --fstab` | `/etc/fstab` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/fstab) |
|
| ` --fstab` | `/etc/fstab` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/fstab) |
|
||||||
| ` --git-log` | `git log` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/git_log) |
|
| ` --git-log` | `git log` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/git_log) |
|
||||||
| ` --git-log-s` | `git log` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/git_log_s) |
|
| ` --git-log-s` | `git log` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/git_log_s) |
|
||||||
|
| `--git-ls-remote` | `git ls-remote` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/git_ls_remote) |
|
||||||
| ` --gpg` | `gpg --with-colons` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/gpg) |
|
| ` --gpg` | `gpg --with-colons` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/gpg) |
|
||||||
| ` --group` | `/etc/group` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/group) |
|
| ` --group` | `/etc/group` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/group) |
|
||||||
| ` --gshadow` | `/etc/gshadow` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/gshadow) |
|
| ` --gshadow` | `/etc/gshadow` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/gshadow) |
|
||||||
@ -221,6 +223,7 @@ option.
|
|||||||
| ` --netstat` | `netstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat) |
|
| ` --netstat` | `netstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat) |
|
||||||
| ` --nmcli` | `nmcli` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/nmcli) |
|
| ` --nmcli` | `nmcli` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/nmcli) |
|
||||||
| ` --ntpq` | `ntpq -p` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq) |
|
| ` --ntpq` | `ntpq -p` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq) |
|
||||||
|
| ` --os-prober` | `os-prober` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/os_prober) |
|
||||||
| ` --passwd` | `/etc/passwd` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd) |
|
| ` --passwd` | `/etc/passwd` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd) |
|
||||||
| ` --pci-ids` | `pci.ids` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pci_ids) |
|
| ` --pci-ids` | `pci.ids` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pci_ids) |
|
||||||
| ` --pidstat` | `pidstat -H` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat) |
|
| ` --pidstat` | `pidstat -H` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat) |
|
||||||
@ -237,9 +240,11 @@ option.
|
|||||||
| ` --rpm-qi` | `rpm -qi` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rpm_qi) |
|
| ` --rpm-qi` | `rpm -qi` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rpm_qi) |
|
||||||
| ` --rsync` | `rsync` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync) |
|
| ` --rsync` | `rsync` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync) |
|
||||||
| ` --rsync-s` | `rsync` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync_s) |
|
| ` --rsync-s` | `rsync` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/rsync_s) |
|
||||||
|
| ` --semver` | Semantic Version string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/semver) |
|
||||||
| ` --sfdisk` | `sfdisk` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sfdisk) |
|
| ` --sfdisk` | `sfdisk` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sfdisk) |
|
||||||
| ` --shadow` | `/etc/shadow` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/shadow) |
|
| ` --shadow` | `/etc/shadow` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/shadow) |
|
||||||
| ` --ss` | `ss` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ss) |
|
| ` --ss` | `ss` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ss) |
|
||||||
|
| ` --sshd-conf` | sshd config file and `sshd -T` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sshd_conf) |
|
||||||
| ` --stat` | `stat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/stat) |
|
| ` --stat` | `stat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/stat) |
|
||||||
| ` --stat-s` | `stat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/stat_s) |
|
| ` --stat-s` | `stat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/stat_s) |
|
||||||
| ` --sysctl` | `sysctl` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sysctl) |
|
| ` --sysctl` | `sysctl` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/sysctl) |
|
||||||
|
@ -3,8 +3,8 @@ _jc()
|
|||||||
local cur prev words cword jc_commands jc_parsers jc_options \
|
local cur prev words cword jc_commands jc_parsers jc_options \
|
||||||
jc_about_options jc_about_mod_options jc_help_options jc_special_options
|
jc_about_options jc_about_mod_options jc_help_options jc_special_options
|
||||||
|
|
||||||
jc_commands=(acpi airport arp blkid chage cksum crontab date df dig dmidecode dpkg du env file finger free git gpg hciconfig id ifconfig iostat iptables iw jobs last lastb ls lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli ntpq pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo)
|
jc_commands=(acpi airport arp blkid chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig id ifconfig iostat iptables iw jobs last lastb ls lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo)
|
||||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --cef --cef-s --chage --cksum --crontab --crontab-u --csv --csv-s --date --datetime-iso --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --finger --free --fstab --git-log --git-log-s --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --ip-address --iptables --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --passwd --pci-ids --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --route --rpm-qi --rsync --rsync-s --sfdisk --shadow --ss --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --cef --cef-s --chage --cksum --crontab --crontab-u --csv --csv-s --date --datetime-iso --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --ip-address --iptables --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --os-prober --passwd --pci-ids --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --ss --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
||||||
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
|
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
|
||||||
jc_about_options=(--about -a)
|
jc_about_options=(--about -a)
|
||||||
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
||||||
|
@ -9,7 +9,7 @@ _jc() {
|
|||||||
jc_help_options jc_help_options_describe \
|
jc_help_options jc_help_options_describe \
|
||||||
jc_special_options jc_special_options_describe
|
jc_special_options jc_special_options_describe
|
||||||
|
|
||||||
jc_commands=(acpi airport arp blkid chage cksum crontab date df dig dmidecode dpkg du env file finger free git gpg hciconfig id ifconfig iostat iptables iw jobs last lastb ls lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli ntpq pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo)
|
jc_commands=(acpi airport arp blkid chage cksum crontab date df dig dmidecode dpkg du env file findmnt finger free git gpg hciconfig id ifconfig iostat iptables iw jobs last lastb ls lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss sshd stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 udevadm ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo)
|
||||||
jc_commands_describe=(
|
jc_commands_describe=(
|
||||||
'acpi:run "acpi" command with magic syntax.'
|
'acpi:run "acpi" command with magic syntax.'
|
||||||
'airport:run "airport" command with magic syntax.'
|
'airport:run "airport" command with magic syntax.'
|
||||||
@ -26,6 +26,7 @@ _jc() {
|
|||||||
'du:run "du" command with magic syntax.'
|
'du:run "du" command with magic syntax.'
|
||||||
'env:run "env" command with magic syntax.'
|
'env:run "env" command with magic syntax.'
|
||||||
'file:run "file" command with magic syntax.'
|
'file:run "file" command with magic syntax.'
|
||||||
|
'findmnt:run "findmnt" command with magic syntax.'
|
||||||
'finger:run "finger" command with magic syntax.'
|
'finger:run "finger" command with magic syntax.'
|
||||||
'free:run "free" command with magic syntax.'
|
'free:run "free" command with magic syntax.'
|
||||||
'git:run "git" command with magic syntax.'
|
'git:run "git" command with magic syntax.'
|
||||||
@ -53,6 +54,7 @@ _jc() {
|
|||||||
'netstat:run "netstat" command with magic syntax.'
|
'netstat:run "netstat" command with magic syntax.'
|
||||||
'nmcli:run "nmcli" command with magic syntax.'
|
'nmcli:run "nmcli" command with magic syntax.'
|
||||||
'ntpq:run "ntpq" command with magic syntax.'
|
'ntpq:run "ntpq" command with magic syntax.'
|
||||||
|
'os-prober:run "os-prober" command with magic syntax.'
|
||||||
'pidstat:run "pidstat" command with magic syntax.'
|
'pidstat:run "pidstat" command with magic syntax.'
|
||||||
'ping:run "ping" command with magic syntax.'
|
'ping:run "ping" command with magic syntax.'
|
||||||
'ping6:run "ping6" command with magic syntax.'
|
'ping6:run "ping6" command with magic syntax.'
|
||||||
@ -72,6 +74,7 @@ _jc() {
|
|||||||
'sha512sum:run "sha512sum" command with magic syntax.'
|
'sha512sum:run "sha512sum" command with magic syntax.'
|
||||||
'shasum:run "shasum" command with magic syntax.'
|
'shasum:run "shasum" command with magic syntax.'
|
||||||
'ss:run "ss" command with magic syntax.'
|
'ss:run "ss" command with magic syntax.'
|
||||||
|
'sshd:run "sshd" command with magic syntax.'
|
||||||
'stat:run "stat" command with magic syntax.'
|
'stat:run "stat" command with magic syntax.'
|
||||||
'sum:run "sum" command with magic syntax.'
|
'sum:run "sum" command with magic syntax.'
|
||||||
'sysctl:run "sysctl" command with magic syntax.'
|
'sysctl:run "sysctl" command with magic syntax.'
|
||||||
@ -97,7 +100,7 @@ _jc() {
|
|||||||
'xrandr:run "xrandr" command with magic syntax.'
|
'xrandr:run "xrandr" command with magic syntax.'
|
||||||
'zipinfo:run "zipinfo" command with magic syntax.'
|
'zipinfo:run "zipinfo" command with magic syntax.'
|
||||||
)
|
)
|
||||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --cef --cef-s --chage --cksum --crontab --crontab-u --csv --csv-s --date --datetime-iso --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --finger --free --fstab --git-log --git-log-s --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --ip-address --iptables --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --passwd --pci-ids --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --route --rpm-qi --rsync --rsync-s --sfdisk --shadow --ss --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --cef --cef-s --chage --cksum --crontab --crontab-u --csv --csv-s --date --datetime-iso --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --ip-address --iptables --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --os-prober --passwd --pci-ids --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --plist --postconf --proc --proc-buddyinfo --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --ss --sshd-conf --stat --stat-s --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
|
||||||
jc_parsers_describe=(
|
jc_parsers_describe=(
|
||||||
'--acpi:`acpi` command parser'
|
'--acpi:`acpi` command parser'
|
||||||
'--airport:`airport -I` command parser'
|
'--airport:`airport -I` command parser'
|
||||||
@ -125,11 +128,13 @@ _jc() {
|
|||||||
'--email-address:Email Address string parser'
|
'--email-address:Email Address string parser'
|
||||||
'--env:`env` command parser'
|
'--env:`env` command parser'
|
||||||
'--file:`file` command parser'
|
'--file:`file` command parser'
|
||||||
|
'--findmnt:`findmnt` command parser'
|
||||||
'--finger:`finger` command parser'
|
'--finger:`finger` command parser'
|
||||||
'--free:`free` command parser'
|
'--free:`free` command parser'
|
||||||
'--fstab:`/etc/fstab` file parser'
|
'--fstab:`/etc/fstab` file parser'
|
||||||
'--git-log:`git log` command parser'
|
'--git-log:`git log` command parser'
|
||||||
'--git-log-s:`git log` command streaming parser'
|
'--git-log-s:`git log` command streaming parser'
|
||||||
|
'--git-ls-remote:`git ls-remote` command parser'
|
||||||
'--gpg:`gpg --with-colons` command parser'
|
'--gpg:`gpg --with-colons` command parser'
|
||||||
'--group:`/etc/group` file parser'
|
'--group:`/etc/group` file parser'
|
||||||
'--gshadow:`/etc/gshadow` file parser'
|
'--gshadow:`/etc/gshadow` file parser'
|
||||||
@ -166,6 +171,7 @@ _jc() {
|
|||||||
'--netstat:`netstat` command parser'
|
'--netstat:`netstat` command parser'
|
||||||
'--nmcli:`nmcli` command parser'
|
'--nmcli:`nmcli` command parser'
|
||||||
'--ntpq:`ntpq -p` command parser'
|
'--ntpq:`ntpq -p` command parser'
|
||||||
|
'--os-prober:`os-prober` command parser'
|
||||||
'--passwd:`/etc/passwd` file parser'
|
'--passwd:`/etc/passwd` file parser'
|
||||||
'--pci-ids:`pci.ids` file parser'
|
'--pci-ids:`pci.ids` file parser'
|
||||||
'--pidstat:`pidstat -H` command parser'
|
'--pidstat:`pidstat -H` command parser'
|
||||||
@ -231,9 +237,11 @@ _jc() {
|
|||||||
'--rpm-qi:`rpm -qi` command parser'
|
'--rpm-qi:`rpm -qi` command parser'
|
||||||
'--rsync:`rsync` command parser'
|
'--rsync:`rsync` command parser'
|
||||||
'--rsync-s:`rsync` command streaming parser'
|
'--rsync-s:`rsync` command streaming parser'
|
||||||
|
'--semver:Semantic Version string parser'
|
||||||
'--sfdisk:`sfdisk` command parser'
|
'--sfdisk:`sfdisk` command parser'
|
||||||
'--shadow:`/etc/shadow` file parser'
|
'--shadow:`/etc/shadow` file parser'
|
||||||
'--ss:`ss` command parser'
|
'--ss:`ss` command parser'
|
||||||
|
'--sshd-conf:sshd config file and `sshd -T` command parser'
|
||||||
'--stat:`stat` command parser'
|
'--stat:`stat` command parser'
|
||||||
'--stat-s:`stat` command streaming parser'
|
'--stat-s:`stat` command streaming parser'
|
||||||
'--sysctl:`sysctl` command parser'
|
'--sysctl:`sysctl` command parser'
|
||||||
|
14
docs/lib.md
14
docs/lib.md
@ -161,7 +161,7 @@ subset of `parser_mod_list()`.
|
|||||||
### parser\_info
|
### parser\_info
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def parser_info(parser_mod_name: str,
|
def parser_info(parser_mod_name: Union[str, ModuleType],
|
||||||
documentation: bool = False) -> ParserInfoType
|
documentation: bool = False) -> ParserInfoType
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -169,10 +169,11 @@ Returns a dictionary that includes the parser module metadata.
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
parser_mod_name: (string) name of the parser module. This
|
parser_mod_name: (string or name of the parser module. This
|
||||||
function will accept module_name,
|
Module) function will accept module_name,
|
||||||
cli-name, and --argument-name
|
cli-name, and --argument-name
|
||||||
variants of the module name.
|
variants of the module name as well
|
||||||
|
as a parser module object.
|
||||||
|
|
||||||
documentation: (boolean) include parser docstring if True
|
documentation: (boolean) include parser docstring if True
|
||||||
|
|
||||||
@ -203,11 +204,12 @@ Parameters:
|
|||||||
### get\_help
|
### get\_help
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def get_help(parser_mod_name: str) -> None
|
def get_help(parser_mod_name: Union[str, ModuleType]) -> None
|
||||||
```
|
```
|
||||||
|
|
||||||
Show help screen for the selected parser.
|
Show help screen for the selected parser.
|
||||||
|
|
||||||
This function will accept **module_name**, **cli-name**, and
|
This function will accept **module_name**, **cli-name**, and
|
||||||
**--argument-name** variants of the module name string.
|
**--argument-name** variants of the module name string as well as a
|
||||||
|
parser module object.
|
||||||
|
|
||||||
|
@ -82,7 +82,9 @@ Examples:
|
|||||||
### parse
|
### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def parse(data, raw=False, quiet=False)
|
def parse(data: Union[str, bytes],
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False) -> List[JSONDictType]
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
@ -100,4 +102,4 @@ Returns:
|
|||||||
### Parser Information
|
### Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
|
||||||
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||||
|
@ -86,4 +86,4 @@ Returns:
|
|||||||
### Parser Information
|
### Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
|
||||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
jc - JSON Convert `du` command output parser
|
jc - JSON Convert `du` command output parser
|
||||||
|
|
||||||
|
The `du -h` option is not supported with the default output. If you
|
||||||
|
would like to use `du -h` or other options that change the output, be sure
|
||||||
|
to use `jc --raw` (cli) or `raw=True` (module).
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ du | jc --du
|
$ du | jc --du
|
||||||
|
118
docs/parsers/findmnt.md
Normal file
118
docs/parsers/findmnt.md
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.findmnt"></a>
|
||||||
|
|
||||||
|
# jc.parsers.findmnt
|
||||||
|
|
||||||
|
jc - JSON Convert `findmnt` command output parser
|
||||||
|
|
||||||
|
Supports `-a`, `-l`, or no `findmnt` options.
|
||||||
|
|
||||||
|
> Note: Newer versions of `findmnt` have a JSON output option.
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ findmnt | jc --findmnt
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ jc findmnt
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('findmnt', findmnt_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"target": string,
|
||||||
|
"source": string,
|
||||||
|
"fstype": string,
|
||||||
|
"options": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"kv_options": {
|
||||||
|
"<key_name>": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ findmnt | jc --findmnt -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"target": "/",
|
||||||
|
"source": "/dev/mapper/centos-root",
|
||||||
|
"fstype": "xfs",
|
||||||
|
"options": [
|
||||||
|
"rw",
|
||||||
|
"relatime",
|
||||||
|
"seclabel",
|
||||||
|
"attr2",
|
||||||
|
"inode64",
|
||||||
|
"noquota"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target": "/sys/fs/cgroup",
|
||||||
|
"source": "tmpfs",
|
||||||
|
"fstype": "tmpfs",
|
||||||
|
"options": [
|
||||||
|
"ro",
|
||||||
|
"nosuid",
|
||||||
|
"nodev",
|
||||||
|
"noexec",
|
||||||
|
"seclabel"
|
||||||
|
],
|
||||||
|
"kv_options": {
|
||||||
|
"mode": "755"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
$ findmnt | jc --findmnt -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"target": "/",
|
||||||
|
"source": "/dev/mapper/centos-root",
|
||||||
|
"fstype": "xfs",
|
||||||
|
"options": "rw,relatime,seclabel,attr2,inode64,noquota"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target": "/sys/fs/cgroup",
|
||||||
|
"source": "tmpfs",
|
||||||
|
"fstype": "tmpfs",
|
||||||
|
"options": "ro,nosuid,nodev,noexec,seclabel,mode=755"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.findmnt.parse"></a>
|
||||||
|
|
||||||
|
### parse
|
||||||
|
|
||||||
|
```python
|
||||||
|
def parse(data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False) -> List[JSONDictType]
|
||||||
|
```
|
||||||
|
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
|
### Parser Information
|
||||||
|
Compatibility: linux
|
||||||
|
|
||||||
|
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
92
docs/parsers/git_ls_remote.md
Normal file
92
docs/parsers/git_ls_remote.md
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.git_ls_remote"></a>
|
||||||
|
|
||||||
|
# jc.parsers.git\_ls\_remote
|
||||||
|
|
||||||
|
jc - JSON Convert `git ls-remote` command output parser
|
||||||
|
|
||||||
|
This parser outputs two schemas:
|
||||||
|
|
||||||
|
- Default: A single object with key/value pairs
|
||||||
|
- Raw: An array of objects (`--raw` (cli) or `raw=True (module))
|
||||||
|
|
||||||
|
See the Schema section for more details
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ git ls-remote | jc --git-ls-remote
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ jc git ls-remote
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('git_ls_remote', git_ls_remote_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
Default:
|
||||||
|
{
|
||||||
|
<reference>: string
|
||||||
|
}
|
||||||
|
|
||||||
|
Raw:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"reference": string,
|
||||||
|
"commit": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ git ls-remote | jc --git-ls-remote -p
|
||||||
|
{
|
||||||
|
"HEAD": "214cd6b9e09603b3c4fa02203b24fb2bc3d4e338",
|
||||||
|
"refs/heads/dev": "b884f6aacca39e05994596d8fdfa7e7c4f1e0389",
|
||||||
|
"refs/heads/master": "214cd6b9e09603b3c4fa02203b24fb2bc3d4e338",
|
||||||
|
"refs/pull/1/head": "e416c77bed1267254da972b0f95b7ff1d43fccef",
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
$ git ls-remote | jc --git-ls-remote -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"reference": "HEAD",
|
||||||
|
"commit": "214cd6b9e09603b3c4fa02203b24fb2bc3d4e338"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"reference": "refs/heads/dev",
|
||||||
|
"commit": "b884f6aacca39e05994596d8fdfa7e7c4f1e0389"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.git_ls_remote.parse"></a>
|
||||||
|
|
||||||
|
### parse
|
||||||
|
|
||||||
|
```python
|
||||||
|
def parse(data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False) -> List[JSONDictType]
|
||||||
|
```
|
||||||
|
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary (default) or List of Dictionaries (raw)
|
||||||
|
|
||||||
|
### Parser Information
|
||||||
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
|
||||||
|
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
@ -3,9 +3,12 @@
|
|||||||
|
|
||||||
# jc.parsers.ifconfig
|
# jc.parsers.ifconfig
|
||||||
|
|
||||||
jc - JSON Convert `ifconfig` command output parser
|
jc - JSON Convert `foo` command output parser
|
||||||
|
|
||||||
> Note: No `ifconfig` options are supported.
|
No `ifconfig` options are supported.
|
||||||
|
|
||||||
|
Consider using the `ip` command instead of `ifconfig` as it supports native
|
||||||
|
JSON output.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -25,19 +28,21 @@ Schema:
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
|
"type": string,
|
||||||
|
"metric": integer
|
||||||
"flags": integer,
|
"flags": integer,
|
||||||
"state": [
|
"state": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"mtu": integer,
|
"mtu": integer,
|
||||||
"ipv4_addr": string,
|
|
||||||
"ipv4_mask": string,
|
|
||||||
"ipv4_bcast": string,
|
|
||||||
"ipv6_addr": string,
|
|
||||||
"ipv6_mask": integer,
|
|
||||||
"ipv6_scope": string,
|
|
||||||
"mac_addr": string,
|
"mac_addr": string,
|
||||||
"type": string,
|
"ipv4_addr": string, # [0]
|
||||||
|
"ipv4_mask": string, # [0]
|
||||||
|
"ipv4_bcast": string, # [0]
|
||||||
|
"ipv6_addr": string, # [0]
|
||||||
|
"ipv6_mask": integer, # [0]
|
||||||
|
"ipv6_scope": string, # [0]
|
||||||
|
"ipv6_type": string, # [0]
|
||||||
"rx_packets": integer,
|
"rx_packets": integer,
|
||||||
"rx_bytes": integer,
|
"rx_bytes": integer,
|
||||||
"rx_errors": integer,
|
"rx_errors": integer,
|
||||||
@ -51,13 +56,53 @@ Schema:
|
|||||||
"tx_overruns": integer,
|
"tx_overruns": integer,
|
||||||
"tx_carrier": integer,
|
"tx_carrier": integer,
|
||||||
"tx_collisions": integer,
|
"tx_collisions": integer,
|
||||||
"metric": integer
|
"options": string,
|
||||||
|
"options_flags": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"status": string,
|
||||||
|
"hw_address": string,
|
||||||
|
"media": string,
|
||||||
|
"media_flags": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"nd6_options": integer,
|
||||||
|
"nd6_flags": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"plugged": string,
|
||||||
|
"vendor": string,
|
||||||
|
"vendor_pn": string,
|
||||||
|
"vendor_sn": string,
|
||||||
|
"vendor_date": string,
|
||||||
|
"module_temperature": string,
|
||||||
|
"module_voltage": string
|
||||||
|
"ipv4": [
|
||||||
|
{
|
||||||
|
"address": string,
|
||||||
|
"mask": string,
|
||||||
|
"broadcast": string
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ipv6: [
|
||||||
|
{
|
||||||
|
"address": string,
|
||||||
|
"mask": integer,
|
||||||
|
"scope": string,
|
||||||
|
"type": string
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[0] these fields only pick up the last IP address in the interface
|
||||||
|
output and are here for backwards compatibility. For information on
|
||||||
|
all IP addresses, use the `ipv4` and `ipv6` objects which contain an
|
||||||
|
array of IP address objects.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ ifconfig | jc --ifconfig -p
|
$ ifconfig ens33 | jc --ifconfig -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "ens33",
|
"name": "ens33",
|
||||||
@ -69,120 +114,92 @@ Examples:
|
|||||||
"MULTICAST"
|
"MULTICAST"
|
||||||
],
|
],
|
||||||
"mtu": 1500,
|
"mtu": 1500,
|
||||||
|
"type": "Ethernet",
|
||||||
|
"mac_addr": "00:0c:29:3b:58:0e",
|
||||||
"ipv4_addr": "192.168.71.137",
|
"ipv4_addr": "192.168.71.137",
|
||||||
"ipv4_mask": "255.255.255.0",
|
"ipv4_mask": "255.255.255.0",
|
||||||
"ipv4_bcast": "192.168.71.255",
|
"ipv4_bcast": "192.168.71.255",
|
||||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
"ipv6_mask": 64,
|
"ipv6_mask": 64,
|
||||||
"ipv6_scope": "0x20",
|
"ipv6_scope": "0x20",
|
||||||
"mac_addr": "00:0c:29:3b:58:0e",
|
"ipv6_type": "link",
|
||||||
"type": "Ethernet",
|
"metric": null,
|
||||||
"rx_packets": 8061,
|
"rx_packets": 8061,
|
||||||
"rx_bytes": 1514413,
|
|
||||||
"rx_errors": 0,
|
"rx_errors": 0,
|
||||||
"rx_dropped": 0,
|
"rx_dropped": 0,
|
||||||
"rx_overruns": 0,
|
"rx_overruns": 0,
|
||||||
"rx_frame": 0,
|
"rx_frame": 0,
|
||||||
"tx_packets": 4502,
|
"tx_packets": 4502,
|
||||||
|
"tx_errors": 0,
|
||||||
|
"tx_dropped": 0,
|
||||||
|
"tx_overruns": 0,
|
||||||
|
"tx_carrier": 0,
|
||||||
|
"tx_collisions": 0,
|
||||||
|
"rx_bytes": 1514413,
|
||||||
"tx_bytes": 866622,
|
"tx_bytes": 866622,
|
||||||
"tx_errors": 0,
|
"ipv4": [
|
||||||
"tx_dropped": 0,
|
|
||||||
"tx_overruns": 0,
|
|
||||||
"tx_carrier": 0,
|
|
||||||
"tx_collisions": 0,
|
|
||||||
"metric": null
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "lo",
|
"address": "192.168.71.137",
|
||||||
"flags": 73,
|
"mask": "255.255.255.0",
|
||||||
"state": [
|
"broadcast": "192.168.71.255"
|
||||||
"UP",
|
}
|
||||||
"LOOPBACK",
|
|
||||||
"RUNNING"
|
|
||||||
],
|
],
|
||||||
"mtu": 65536,
|
"ipv6": [
|
||||||
"ipv4_addr": "127.0.0.1",
|
{
|
||||||
"ipv4_mask": "255.0.0.0",
|
"address": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
"ipv4_bcast": null,
|
"mask": 64,
|
||||||
"ipv6_addr": "::1",
|
"scope": "0x20",
|
||||||
"ipv6_mask": 128,
|
"type": "link"
|
||||||
"ipv6_scope": "0x10",
|
}
|
||||||
"mac_addr": null,
|
]
|
||||||
"type": "Local Loopback",
|
|
||||||
"rx_packets": 73,
|
|
||||||
"rx_bytes": 6009,
|
|
||||||
"rx_errors": 0,
|
|
||||||
"rx_dropped": 0,
|
|
||||||
"rx_overruns": 0,
|
|
||||||
"rx_frame": 0,
|
|
||||||
"tx_packets": 73,
|
|
||||||
"tx_bytes": 6009,
|
|
||||||
"tx_errors": 0,
|
|
||||||
"tx_dropped": 0,
|
|
||||||
"tx_overruns": 0,
|
|
||||||
"tx_carrier": 0,
|
|
||||||
"tx_collisions": 0,
|
|
||||||
"metric": null
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
$ ifconfig | jc --ifconfig -p -r
|
$ ifconfig ens33 | jc --ifconfig -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "ens33",
|
"name": "ens33",
|
||||||
"flags": "4163",
|
"flags": "4163",
|
||||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||||
"mtu": "1500",
|
"mtu": "1500",
|
||||||
|
"type": "Ethernet",
|
||||||
|
"mac_addr": "00:0c:29:3b:58:0e",
|
||||||
"ipv4_addr": "192.168.71.137",
|
"ipv4_addr": "192.168.71.137",
|
||||||
"ipv4_mask": "255.255.255.0",
|
"ipv4_mask": "255.255.255.0",
|
||||||
"ipv4_bcast": "192.168.71.255",
|
"ipv4_bcast": "192.168.71.255",
|
||||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
"ipv6_mask": "64",
|
"ipv6_mask": "64",
|
||||||
"ipv6_scope": "0x20",
|
"ipv6_scope": "0x20",
|
||||||
"mac_addr": "00:0c:29:3b:58:0e",
|
"ipv6_type": "link",
|
||||||
"type": "Ethernet",
|
"metric": null,
|
||||||
"rx_packets": "8061",
|
"rx_packets": "8061",
|
||||||
"rx_bytes": "1514413",
|
|
||||||
"rx_errors": "0",
|
"rx_errors": "0",
|
||||||
"rx_dropped": "0",
|
"rx_dropped": "0",
|
||||||
"rx_overruns": "0",
|
"rx_overruns": "0",
|
||||||
"rx_frame": "0",
|
"rx_frame": "0",
|
||||||
"tx_packets": "4502",
|
"tx_packets": "4502",
|
||||||
|
"tx_errors": "0",
|
||||||
|
"tx_dropped": "0",
|
||||||
|
"tx_overruns": "0",
|
||||||
|
"tx_carrier": "0",
|
||||||
|
"tx_collisions": "0",
|
||||||
|
"rx_bytes": "1514413",
|
||||||
"tx_bytes": "866622",
|
"tx_bytes": "866622",
|
||||||
"tx_errors": "0",
|
"ipv4": [
|
||||||
"tx_dropped": "0",
|
|
||||||
"tx_overruns": "0",
|
|
||||||
"tx_carrier": "0",
|
|
||||||
"tx_collisions": "0",
|
|
||||||
"metric": null
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "lo",
|
"address": "192.168.71.137",
|
||||||
"flags": "73",
|
"mask": "255.255.255.0",
|
||||||
"state": "UP,LOOPBACK,RUNNING",
|
"broadcast": "192.168.71.255"
|
||||||
"mtu": "65536",
|
}
|
||||||
"ipv4_addr": "127.0.0.1",
|
],
|
||||||
"ipv4_mask": "255.0.0.0",
|
"ipv6": [
|
||||||
"ipv4_bcast": null,
|
{
|
||||||
"ipv6_addr": "::1",
|
"address": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
"ipv6_mask": "128",
|
"mask": "64",
|
||||||
"ipv6_scope": "0x10",
|
"scope": "0x20",
|
||||||
"mac_addr": null,
|
"type": "link"
|
||||||
"type": "Local Loopback",
|
}
|
||||||
"rx_packets": "73",
|
]
|
||||||
"rx_bytes": "6009",
|
|
||||||
"rx_errors": "0",
|
|
||||||
"rx_dropped": "0",
|
|
||||||
"rx_overruns": "0",
|
|
||||||
"rx_frame": "0",
|
|
||||||
"tx_packets": "73",
|
|
||||||
"tx_bytes": "6009",
|
|
||||||
"tx_errors": "0",
|
|
||||||
"tx_dropped": "0",
|
|
||||||
"tx_overruns": "0",
|
|
||||||
"tx_carrier": "0",
|
|
||||||
"tx_collisions": "0",
|
|
||||||
"metric": null
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -191,7 +208,9 @@ Examples:
|
|||||||
### parse
|
### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def parse(data, raw=False, quiet=False)
|
def parse(data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False) -> List[JSONDictType]
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
@ -209,4 +228,4 @@ Returns:
|
|||||||
### Parser Information
|
### Parser Information
|
||||||
Compatibility: linux, aix, freebsd, darwin
|
Compatibility: linux, aix, freebsd, darwin
|
||||||
|
|
||||||
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
Version 2.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||||
|
63
docs/parsers/os_prober.md
Normal file
63
docs/parsers/os_prober.md
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.os_prober"></a>
|
||||||
|
|
||||||
|
# jc.parsers.os\_prober
|
||||||
|
|
||||||
|
jc - JSON Convert `os-prober` command output parser
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ os-prober | jc --os-prober
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ jc os-prober
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('os_prober', os_prober_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
'partition': string,
|
||||||
|
'name': string,
|
||||||
|
'short_name': string,
|
||||||
|
'type': string
|
||||||
|
}
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ os-prober | jc --os-prober -p
|
||||||
|
{
|
||||||
|
"partition": "/dev/sda1",
|
||||||
|
"name": "Windows 10",
|
||||||
|
"short_name": "Windows",
|
||||||
|
"type": "chain"
|
||||||
|
}
|
||||||
|
|
||||||
|
<a id="jc.parsers.os_prober.parse"></a>
|
||||||
|
|
||||||
|
### parse
|
||||||
|
|
||||||
|
```python
|
||||||
|
def parse(data: str, raw: bool = False, quiet: bool = False) -> JSONDictType
|
||||||
|
```
|
||||||
|
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output 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)
|
@ -85,7 +85,7 @@ Examples:
|
|||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ proc_modules | jc --proc_modules -p -r
|
$ cat /proc/modules | jc --proc-modules -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"module": "binfmt_misc",
|
"module": "binfmt_misc",
|
||||||
|
75
docs/parsers/semver.md
Normal file
75
docs/parsers/semver.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.semver"></a>
|
||||||
|
|
||||||
|
# jc.parsers.semver
|
||||||
|
|
||||||
|
jc - JSON Convert Semantic Version string parser
|
||||||
|
|
||||||
|
This parser conforms to the specification at https://semver.org/
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ echo 1.2.3-rc.1+44837 | jc --semver
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('semver', semver_string)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
Strings that do not strictly conform to the specification will return an
|
||||||
|
empty object.
|
||||||
|
|
||||||
|
{
|
||||||
|
"major": integer,
|
||||||
|
"minor": integer,
|
||||||
|
"patch": integer,
|
||||||
|
"prerelease": string/null,
|
||||||
|
"build": string/null
|
||||||
|
}
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ echo 1.2.3-rc.1+44837 | jc --semver -p
|
||||||
|
{
|
||||||
|
"major": 1,
|
||||||
|
"minor": 2,
|
||||||
|
"patch": 3,
|
||||||
|
"prerelease": "rc.1",
|
||||||
|
"build": "44837"
|
||||||
|
}
|
||||||
|
|
||||||
|
$ echo 1.2.3-rc.1+44837 | jc --semver -p -r
|
||||||
|
{
|
||||||
|
"major": "1",
|
||||||
|
"minor": "2",
|
||||||
|
"patch": "3",
|
||||||
|
"prerelease": "rc.1",
|
||||||
|
"build": "44837"
|
||||||
|
}
|
||||||
|
|
||||||
|
<a id="jc.parsers.semver.parse"></a>
|
||||||
|
|
||||||
|
### parse
|
||||||
|
|
||||||
|
```python
|
||||||
|
def parse(data: str, raw: bool = False, quiet: bool = False) -> JSONDictType
|
||||||
|
```
|
||||||
|
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
|
### Parser Information
|
||||||
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
|
||||||
|
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
507
docs/parsers/sshd_conf.md
Normal file
507
docs/parsers/sshd_conf.md
Normal file
@ -0,0 +1,507 @@
|
|||||||
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.sshd_conf"></a>
|
||||||
|
|
||||||
|
# jc.parsers.sshd\_conf
|
||||||
|
|
||||||
|
jc - JSON Convert sshd configuration file and `sshd -T` command output parser
|
||||||
|
|
||||||
|
This parser will work with `sshd` configuration files or the output of
|
||||||
|
`sshd -T`. Any `Match` blocks in the `sshd` configuration file will be
|
||||||
|
ignored.
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ sshd -T | jc --sshd-conf
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ jc sshd -T
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ cat sshd_conf | jc --sshd-conf
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('sshd_conf', sshd_conf_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"acceptenv": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"addressfamily": string,
|
||||||
|
"allowagentforwarding": string,
|
||||||
|
"allowstreamlocalforwarding": string,
|
||||||
|
"allowtcpforwarding": string,
|
||||||
|
"authenticationmethods": string,
|
||||||
|
"authorizedkeyscommand": string,
|
||||||
|
"authorizedkeyscommanduser": string,
|
||||||
|
"authorizedkeysfile": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"authorizedprincipalscommand": string,
|
||||||
|
"authorizedprincipalscommanduser": string,
|
||||||
|
"authorizedprincipalsfile": string,
|
||||||
|
"banner": string,
|
||||||
|
"casignaturealgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"chrootdirectory": string,
|
||||||
|
"ciphers": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"ciphers_strategy": string,
|
||||||
|
"clientalivecountmax": integer,
|
||||||
|
"clientaliveinterval": integer,
|
||||||
|
"compression": string,
|
||||||
|
"disableforwarding": string,
|
||||||
|
"exposeauthinfo": string,
|
||||||
|
"fingerprinthash": string,
|
||||||
|
"forcecommand": string,
|
||||||
|
"gatewayports": string,
|
||||||
|
"gssapiauthentication": string,
|
||||||
|
"gssapicleanupcredentials": string,
|
||||||
|
"gssapikexalgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"gssapikeyexchange": string,
|
||||||
|
"gssapistorecredentialsonrekey": string,
|
||||||
|
"gssapistrictacceptorcheck": string,
|
||||||
|
"hostbasedacceptedalgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"hostbasedauthentication": string,
|
||||||
|
"hostbasedusesnamefrompacketonly": string,
|
||||||
|
"hostkeyagent": string,
|
||||||
|
"hostkeyalgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"hostkey": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"ignorerhosts": string,
|
||||||
|
"ignoreuserknownhosts": string,
|
||||||
|
"include": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"ipqos": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"kbdinteractiveauthentication": string,
|
||||||
|
"kerberosauthentication": string,
|
||||||
|
"kerberosorlocalpasswd": string,
|
||||||
|
"kerberosticketcleanup": sttring,
|
||||||
|
"kexalgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"listenaddress": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"logingracetime": integer,
|
||||||
|
"loglevel": string,
|
||||||
|
"macs": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"macs_strategy": string,
|
||||||
|
"maxauthtries": integer,
|
||||||
|
"maxsessions": integer,
|
||||||
|
"maxstartups": integer,
|
||||||
|
"maxstartups_rate": integer,
|
||||||
|
"maxstartups_full": integer,
|
||||||
|
"modulifile": string,
|
||||||
|
"passwordauthentication": string,
|
||||||
|
"permitemptypasswords": string,
|
||||||
|
"permitlisten": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"permitopen": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"permitrootlogin": string,
|
||||||
|
"permittty": string,
|
||||||
|
"permittunnel": string,
|
||||||
|
"permituserenvironment": string,
|
||||||
|
"permituserrc": string,
|
||||||
|
"persourcemaxstartups": string,
|
||||||
|
"persourcenetblocksize": string,
|
||||||
|
"pidfile": string,
|
||||||
|
"port": [
|
||||||
|
integer
|
||||||
|
],
|
||||||
|
"printlastlog": string,
|
||||||
|
"printmotd": string,
|
||||||
|
"pubkeyacceptedalgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"pubkeyauthentication": string,
|
||||||
|
"pubkeyauthoptions": string,
|
||||||
|
"rekeylimit": integer,
|
||||||
|
"rekeylimit_time": integer,
|
||||||
|
"revokedkeys": string,
|
||||||
|
"securitykeyprovider": string,
|
||||||
|
"streamlocalbindmask": string,
|
||||||
|
"streamlocalbindunlink": string,
|
||||||
|
"strictmodes": string,
|
||||||
|
"subsystem": string,
|
||||||
|
"subsystem_command": string
|
||||||
|
"syslogfacility": string,
|
||||||
|
"tcpkeepalive": string,
|
||||||
|
"trustedusercakeys": string,
|
||||||
|
"usedns": string,
|
||||||
|
"usepam": string,
|
||||||
|
"versionaddendum": string,
|
||||||
|
"x11displayoffset": integer,
|
||||||
|
"x11forwarding": string,
|
||||||
|
"x11uselocalhost": string,
|
||||||
|
"xauthlocation": string
|
||||||
|
}
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ sshd -T | jc --sshd_conf -p
|
||||||
|
{
|
||||||
|
"acceptenv": [
|
||||||
|
"LANG",
|
||||||
|
"LC_*"
|
||||||
|
],
|
||||||
|
"addressfamily": "any",
|
||||||
|
"allowagentforwarding": "yes",
|
||||||
|
"allowstreamlocalforwarding": "yes",
|
||||||
|
"allowtcpforwarding": "yes",
|
||||||
|
"authenticationmethods": "any",
|
||||||
|
"authorizedkeyscommand": "none",
|
||||||
|
"authorizedkeyscommanduser": "none",
|
||||||
|
"authorizedkeysfile": [
|
||||||
|
".ssh/authorized_keys",
|
||||||
|
".ssh/authorized_keys2"
|
||||||
|
],
|
||||||
|
"authorizedprincipalscommand": "none",
|
||||||
|
"authorizedprincipalscommanduser": "none",
|
||||||
|
"authorizedprincipalsfile": "none",
|
||||||
|
"banner": "none",
|
||||||
|
"casignaturealgorithms": [
|
||||||
|
"ssh-ed25519",
|
||||||
|
"ecdsa-sha2-nistp256",
|
||||||
|
"ecdsa-sha2-nistp384",
|
||||||
|
"ecdsa-sha2-nistp521",
|
||||||
|
"sk-ssh-ed25519@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256@openssh.com",
|
||||||
|
"rsa-sha2-512",
|
||||||
|
"rsa-sha2-256"
|
||||||
|
],
|
||||||
|
"chrootdirectory": "none",
|
||||||
|
"ciphers": [
|
||||||
|
"chacha20-poly1305@openssh.com",
|
||||||
|
"aes128-ctr",
|
||||||
|
"aes192-ctr",
|
||||||
|
"aes256-ctr",
|
||||||
|
"aes128-gcm@openssh.com",
|
||||||
|
"aes256-gcm@openssh.com"
|
||||||
|
],
|
||||||
|
"ciphers_strategy": "+",
|
||||||
|
"clientalivecountmax": 3,
|
||||||
|
"clientaliveinterval": 0,
|
||||||
|
"compression": "yes",
|
||||||
|
"disableforwarding": "no",
|
||||||
|
"exposeauthinfo": "no",
|
||||||
|
"fingerprinthash": "SHA256",
|
||||||
|
"forcecommand": "none",
|
||||||
|
"gatewayports": "no",
|
||||||
|
"gssapiauthentication": "no",
|
||||||
|
"gssapicleanupcredentials": "yes",
|
||||||
|
"gssapikexalgorithms": [
|
||||||
|
"gss-group14-sha256-",
|
||||||
|
"gss-group16-sha512-",
|
||||||
|
"gss-nistp256-sha256-",
|
||||||
|
"gss-curve25519-sha256-",
|
||||||
|
"gss-group14-sha1-",
|
||||||
|
"gss-gex-sha1-"
|
||||||
|
],
|
||||||
|
"gssapikeyexchange": "no",
|
||||||
|
"gssapistorecredentialsonrekey": "no",
|
||||||
|
"gssapistrictacceptorcheck": "yes",
|
||||||
|
"hostbasedacceptedalgorithms": [
|
||||||
|
"ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp384-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp521-cert-v01@openssh.com",
|
||||||
|
"sk-ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-512-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-256-cert-v01@openssh.com",
|
||||||
|
"ssh-ed25519",
|
||||||
|
"ecdsa-sha2-nistp256",
|
||||||
|
"ecdsa-sha2-nistp384",
|
||||||
|
"ecdsa-sha2-nistp521",
|
||||||
|
"sk-ssh-ed25519@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256@openssh.com",
|
||||||
|
"rsa-sha2-512",
|
||||||
|
"rsa-sha2-256"
|
||||||
|
],
|
||||||
|
"hostbasedauthentication": "no",
|
||||||
|
"hostbasedusesnamefrompacketonly": "no",
|
||||||
|
"hostkeyagent": "none",
|
||||||
|
"hostkeyalgorithms": [
|
||||||
|
"ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp384-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp521-cert-v01@openssh.com",
|
||||||
|
"sk-ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-512-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-256-cert-v01@openssh.com",
|
||||||
|
"ssh-ed25519",
|
||||||
|
"ecdsa-sha2-nistp256",
|
||||||
|
"ecdsa-sha2-nistp384",
|
||||||
|
"ecdsa-sha2-nistp521",
|
||||||
|
"sk-ssh-ed25519@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256@openssh.com",
|
||||||
|
"rsa-sha2-512",
|
||||||
|
"rsa-sha2-256"
|
||||||
|
],
|
||||||
|
"hostkey": [
|
||||||
|
"/etc/ssh/ssh_host_ecdsa_key",
|
||||||
|
"/etc/ssh/ssh_host_ed25519_key",
|
||||||
|
"/etc/ssh/ssh_host_rsa_key"
|
||||||
|
],
|
||||||
|
"ignorerhosts": "yes",
|
||||||
|
"ignoreuserknownhosts": "no",
|
||||||
|
"ipqos": [
|
||||||
|
"lowdelay",
|
||||||
|
"throughput"
|
||||||
|
],
|
||||||
|
"kbdinteractiveauthentication": "no",
|
||||||
|
"kerberosauthentication": "no",
|
||||||
|
"kerberosorlocalpasswd": "yes",
|
||||||
|
"kerberosticketcleanup": "yes",
|
||||||
|
"kexalgorithms": [
|
||||||
|
"sntrup761x25519-sha512@openssh.com",
|
||||||
|
"curve25519-sha256",
|
||||||
|
"curve25519-sha256@libssh.org",
|
||||||
|
"ecdh-sha2-nistp256",
|
||||||
|
"ecdh-sha2-nistp384",
|
||||||
|
"ecdh-sha2-nistp521",
|
||||||
|
"diffie-hellman-group-exchange-sha256",
|
||||||
|
"diffie-hellman-group16-sha512",
|
||||||
|
"diffie-hellman-group18-sha512",
|
||||||
|
"diffie-hellman-group14-sha256"
|
||||||
|
],
|
||||||
|
"listenaddress": [
|
||||||
|
"0.0.0.0:22",
|
||||||
|
"[::]:22"
|
||||||
|
],
|
||||||
|
"logingracetime": 120,
|
||||||
|
"loglevel": "INFO",
|
||||||
|
"macs": [
|
||||||
|
"umac-64-etm@openssh.com",
|
||||||
|
"umac-128-etm@openssh.com",
|
||||||
|
"hmac-sha2-256-etm@openssh.com",
|
||||||
|
"hmac-sha2-512-etm@openssh.com",
|
||||||
|
"hmac-sha1-etm@openssh.com",
|
||||||
|
"umac-64@openssh.com",
|
||||||
|
"umac-128@openssh.com",
|
||||||
|
"hmac-sha2-256",
|
||||||
|
"hmac-sha2-512",
|
||||||
|
"hmac-sha1"
|
||||||
|
],
|
||||||
|
"macs_strategy": "^",
|
||||||
|
"maxauthtries": 6,
|
||||||
|
"maxsessions": 10,
|
||||||
|
"maxstartups": 10,
|
||||||
|
"modulifile": "/etc/ssh/moduli",
|
||||||
|
"passwordauthentication": "yes",
|
||||||
|
"permitemptypasswords": "no",
|
||||||
|
"permitlisten": [
|
||||||
|
"any"
|
||||||
|
],
|
||||||
|
"permitopen": [
|
||||||
|
"any"
|
||||||
|
],
|
||||||
|
"permitrootlogin": "without-password",
|
||||||
|
"permittty": "yes",
|
||||||
|
"permittunnel": "no",
|
||||||
|
"permituserenvironment": "no",
|
||||||
|
"permituserrc": "yes",
|
||||||
|
"persourcemaxstartups": "none",
|
||||||
|
"persourcenetblocksize": "32:128",
|
||||||
|
"pidfile": "/run/sshd.pid",
|
||||||
|
"port": [
|
||||||
|
22
|
||||||
|
],
|
||||||
|
"printlastlog": "yes",
|
||||||
|
"printmotd": "no",
|
||||||
|
"pubkeyacceptedalgorithms": [
|
||||||
|
"ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp384-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp521-cert-v01@openssh.com",
|
||||||
|
"sk-ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-512-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-256-cert-v01@openssh.com",
|
||||||
|
"ssh-ed25519",
|
||||||
|
"ecdsa-sha2-nistp256",
|
||||||
|
"ecdsa-sha2-nistp384",
|
||||||
|
"ecdsa-sha2-nistp521",
|
||||||
|
"sk-ssh-ed25519@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256@openssh.com",
|
||||||
|
"rsa-sha2-512",
|
||||||
|
"rsa-sha2-256"
|
||||||
|
],
|
||||||
|
"pubkeyauthentication": "yes",
|
||||||
|
"pubkeyauthoptions": "none",
|
||||||
|
"rekeylimit": 0,
|
||||||
|
"revokedkeys": "none",
|
||||||
|
"securitykeyprovider": "internal",
|
||||||
|
"streamlocalbindmask": "0177",
|
||||||
|
"streamlocalbindunlink": "no",
|
||||||
|
"strictmodes": "yes",
|
||||||
|
"subsystem": "sftp",
|
||||||
|
"syslogfacility": "AUTH",
|
||||||
|
"tcpkeepalive": "yes",
|
||||||
|
"trustedusercakeys": "none",
|
||||||
|
"usedns": "no",
|
||||||
|
"usepam": "yes",
|
||||||
|
"versionaddendum": "none",
|
||||||
|
"x11displayoffset": 10,
|
||||||
|
"x11forwarding": "yes",
|
||||||
|
"x11uselocalhost": "yes",
|
||||||
|
"xauthlocation": "/usr/bin/xauth",
|
||||||
|
"maxstartups_rate": 30,
|
||||||
|
"maxstartups_full": 100,
|
||||||
|
"rekeylimit_time": 0,
|
||||||
|
"subsystem_command": "/usr/lib/openssh/sftp-server"
|
||||||
|
}
|
||||||
|
|
||||||
|
$ sshd -T | jc --sshd_conf -p -r
|
||||||
|
{
|
||||||
|
"acceptenv": [
|
||||||
|
"LANG",
|
||||||
|
"LC_*"
|
||||||
|
],
|
||||||
|
"addressfamily": "any",
|
||||||
|
"allowagentforwarding": "yes",
|
||||||
|
"allowstreamlocalforwarding": "yes",
|
||||||
|
"allowtcpforwarding": "yes",
|
||||||
|
"authenticationmethods": "any",
|
||||||
|
"authorizedkeyscommand": "none",
|
||||||
|
"authorizedkeyscommanduser": "none",
|
||||||
|
"authorizedkeysfile": ".ssh/authorized_keys .ssh/authorized_keys2",
|
||||||
|
"authorizedprincipalscommand": "none",
|
||||||
|
"authorizedprincipalscommanduser": "none",
|
||||||
|
"authorizedprincipalsfile": "none",
|
||||||
|
"banner": "none",
|
||||||
|
"casignaturealgorithms": "ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-s...",
|
||||||
|
"chrootdirectory": "none",
|
||||||
|
"ciphers": "chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,...",
|
||||||
|
"ciphers_strategy": "+",
|
||||||
|
"clientalivecountmax": "3",
|
||||||
|
"clientaliveinterval": "0",
|
||||||
|
"compression": "yes",
|
||||||
|
"disableforwarding": "no",
|
||||||
|
"exposeauthinfo": "no",
|
||||||
|
"fingerprinthash": "SHA256",
|
||||||
|
"forcecommand": "none",
|
||||||
|
"gatewayports": "no",
|
||||||
|
"gssapiauthentication": "no",
|
||||||
|
"gssapicleanupcredentials": "yes",
|
||||||
|
"gssapikexalgorithms": "gss-group14-sha256-,gss-group16-sha512-,...",
|
||||||
|
"gssapikeyexchange": "no",
|
||||||
|
"gssapistorecredentialsonrekey": "no",
|
||||||
|
"gssapistrictacceptorcheck": "yes",
|
||||||
|
"hostbasedacceptedalgorithms": "ssh-ed25519-cert-v01@openssh.co...",
|
||||||
|
"hostbasedauthentication": "no",
|
||||||
|
"hostbasedusesnamefrompacketonly": "no",
|
||||||
|
"hostkeyagent": "none",
|
||||||
|
"hostkeyalgorithms": "ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2...",
|
||||||
|
"hostkey": [
|
||||||
|
"/etc/ssh/ssh_host_ecdsa_key",
|
||||||
|
"/etc/ssh/ssh_host_ed25519_key",
|
||||||
|
"/etc/ssh/ssh_host_rsa_key"
|
||||||
|
],
|
||||||
|
"ignorerhosts": "yes",
|
||||||
|
"ignoreuserknownhosts": "no",
|
||||||
|
"ipqos": "lowdelay throughput",
|
||||||
|
"kbdinteractiveauthentication": "no",
|
||||||
|
"kerberosauthentication": "no",
|
||||||
|
"kerberosorlocalpasswd": "yes",
|
||||||
|
"kerberosticketcleanup": "yes",
|
||||||
|
"kexalgorithms": "sntrup761x25519-sha512@openssh.com,curve25519...",
|
||||||
|
"listenaddress": [
|
||||||
|
"0.0.0.0:22",
|
||||||
|
"[::]:22"
|
||||||
|
],
|
||||||
|
"logingracetime": "120",
|
||||||
|
"loglevel": "INFO",
|
||||||
|
"macs": "umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac...",
|
||||||
|
"macs_strategy": "^",
|
||||||
|
"maxauthtries": "6",
|
||||||
|
"maxsessions": "10",
|
||||||
|
"maxstartups": "10:30:100",
|
||||||
|
"modulifile": "/etc/ssh/moduli",
|
||||||
|
"passwordauthentication": "yes",
|
||||||
|
"permitemptypasswords": "no",
|
||||||
|
"permitlisten": "any",
|
||||||
|
"permitopen": "any",
|
||||||
|
"permitrootlogin": "without-password",
|
||||||
|
"permittty": "yes",
|
||||||
|
"permittunnel": "no",
|
||||||
|
"permituserenvironment": "no",
|
||||||
|
"permituserrc": "yes",
|
||||||
|
"persourcemaxstartups": "none",
|
||||||
|
"persourcenetblocksize": "32:128",
|
||||||
|
"pidfile": "/run/sshd.pid",
|
||||||
|
"port": [
|
||||||
|
"22"
|
||||||
|
],
|
||||||
|
"printlastlog": "yes",
|
||||||
|
"printmotd": "no",
|
||||||
|
"pubkeyacceptedalgorithms": "ssh-ed25519-cert-v01@openssh.com,...",
|
||||||
|
"pubkeyauthentication": "yes",
|
||||||
|
"pubkeyauthoptions": "none",
|
||||||
|
"rekeylimit": "0 0",
|
||||||
|
"revokedkeys": "none",
|
||||||
|
"securitykeyprovider": "internal",
|
||||||
|
"streamlocalbindmask": "0177",
|
||||||
|
"streamlocalbindunlink": "no",
|
||||||
|
"strictmodes": "yes",
|
||||||
|
"subsystem": "sftp /usr/lib/openssh/sftp-server",
|
||||||
|
"syslogfacility": "AUTH",
|
||||||
|
"tcpkeepalive": "yes",
|
||||||
|
"trustedusercakeys": "none",
|
||||||
|
"usedns": "no",
|
||||||
|
"usepam": "yes",
|
||||||
|
"versionaddendum": "none",
|
||||||
|
"x11displayoffset": "10",
|
||||||
|
"x11forwarding": "yes",
|
||||||
|
"x11uselocalhost": "yes",
|
||||||
|
"xauthlocation": "/usr/bin/xauth"
|
||||||
|
}
|
||||||
|
|
||||||
|
<a id="jc.parsers.sshd_conf.parse"></a>
|
||||||
|
|
||||||
|
### parse
|
||||||
|
|
||||||
|
```python
|
||||||
|
def parse(data: str, raw: bool = False, quiet: bool = False) -> JSONDictType
|
||||||
|
```
|
||||||
|
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
|
### Parser Information
|
||||||
|
Compatibility: linux, darwin, freebsd
|
||||||
|
|
||||||
|
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
@ -5,6 +5,11 @@
|
|||||||
|
|
||||||
jc - JSON Convert `XML` file parser
|
jc - JSON Convert `XML` file parser
|
||||||
|
|
||||||
|
This parser adds a `@` prefix to attributes by default. This can be changed
|
||||||
|
to a `_` prefix by using the `-r` (cli) or `raw=True` (module) option.
|
||||||
|
|
||||||
|
Text values for nodes will have the key-name of `#text`.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat foo.xml | jc --xml
|
$ cat foo.xml | jc --xml
|
||||||
@ -93,4 +98,4 @@ Returns:
|
|||||||
### Parser Information
|
### Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
|
||||||
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||||
|
@ -183,7 +183,7 @@ Returns:
|
|||||||
### input\_type\_check
|
### input\_type\_check
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def input_type_check(data: str) -> None
|
def input_type_check(data: object) -> None
|
||||||
```
|
```
|
||||||
|
|
||||||
Ensure input data is a string. Raises `TypeError` if not.
|
Ensure input data is a string. Raises `TypeError` if not.
|
||||||
|
40
jc/cli.py
40
jc/cli.py
@ -7,7 +7,6 @@ import sys
|
|||||||
import os
|
import os
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
import textwrap
|
import textwrap
|
||||||
import signal
|
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
from typing import List, Union, Optional, TextIO
|
from typing import List, Union, Optional, TextIO
|
||||||
@ -629,20 +628,7 @@ class JcCli():
|
|||||||
utils.error_message(['Parser returned an unsupported object type.'])
|
utils.error_message(['Parser returned an unsupported object type.'])
|
||||||
self.exit_error()
|
self.exit_error()
|
||||||
|
|
||||||
def ctrlc(self, signum, frame) -> None:
|
def _run(self) -> None:
|
||||||
"""Exit on SIGINT"""
|
|
||||||
self.exit_clean()
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
# break on ctrl-c keyboard interrupt
|
|
||||||
signal.signal(signal.SIGINT, self.ctrlc)
|
|
||||||
|
|
||||||
# break on pipe error. need try/except for windows compatibility
|
|
||||||
try:
|
|
||||||
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# enable colors for Windows cmd.exe terminal
|
# enable colors for Windows cmd.exe terminal
|
||||||
if sys.platform.startswith('win32'):
|
if sys.platform.startswith('win32'):
|
||||||
os.system('')
|
os.system('')
|
||||||
@ -724,12 +710,16 @@ class JcCli():
|
|||||||
self.standard_parse_and_print()
|
self.standard_parse_and_print()
|
||||||
self.exit_clean()
|
self.exit_clean()
|
||||||
|
|
||||||
|
except BrokenPipeError:
|
||||||
|
sys.stdout = None # type: ignore
|
||||||
|
|
||||||
except (ParseError, LibraryNotInstalled) as e:
|
except (ParseError, LibraryNotInstalled) as e:
|
||||||
if self.debug:
|
if self.debug:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
utils.error_message([
|
utils.error_message([
|
||||||
f'Parser issue with {self.parser_name}:', f'{e.__class__.__name__}: {e}',
|
f'Parser issue with {self.parser_name}:',
|
||||||
|
f'{e.__class__.__name__}: {e}',
|
||||||
'If this is the correct parser, try setting the locale to C (LC_ALL=C).',
|
'If this is the correct parser, try setting the locale to C (LC_ALL=C).',
|
||||||
f'For details use the -d or -dd option. Use "jc -h --{self.parser_name}" for help.'
|
f'For details use the -d or -dd option. Use "jc -h --{self.parser_name}" for help.'
|
||||||
])
|
])
|
||||||
@ -751,6 +741,24 @@ class JcCli():
|
|||||||
])
|
])
|
||||||
self.exit_error()
|
self.exit_error()
|
||||||
|
|
||||||
|
def run(self) -> None:
|
||||||
|
try:
|
||||||
|
self._run()
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
utils.error_message(['Exit due to SIGINT.'])
|
||||||
|
self.exit_error()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
if self.debug:
|
||||||
|
raise
|
||||||
|
|
||||||
|
utils.error_message([
|
||||||
|
'Exit due to unexpected error:',
|
||||||
|
f'{e.__class__.__name__}: {e}'
|
||||||
|
])
|
||||||
|
self.exit_error()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
JcCli().run()
|
JcCli().run()
|
||||||
|
36
jc/lib.py
36
jc/lib.py
@ -9,7 +9,7 @@ from .jc_types import ParserInfoType, JSONDictType
|
|||||||
from jc import appdirs
|
from jc import appdirs
|
||||||
|
|
||||||
|
|
||||||
__version__ = '1.22.1'
|
__version__ = '1.22.2'
|
||||||
|
|
||||||
parsers: List[str] = [
|
parsers: List[str] = [
|
||||||
'acpi',
|
'acpi',
|
||||||
@ -38,11 +38,13 @@ parsers: List[str] = [
|
|||||||
'email-address',
|
'email-address',
|
||||||
'env',
|
'env',
|
||||||
'file',
|
'file',
|
||||||
|
'findmnt',
|
||||||
'finger',
|
'finger',
|
||||||
'free',
|
'free',
|
||||||
'fstab',
|
'fstab',
|
||||||
'git-log',
|
'git-log',
|
||||||
'git-log-s',
|
'git-log-s',
|
||||||
|
'git-ls-remote',
|
||||||
'gpg',
|
'gpg',
|
||||||
'group',
|
'group',
|
||||||
'gshadow',
|
'gshadow',
|
||||||
@ -80,6 +82,7 @@ parsers: List[str] = [
|
|||||||
'netstat',
|
'netstat',
|
||||||
'nmcli',
|
'nmcli',
|
||||||
'ntpq',
|
'ntpq',
|
||||||
|
'os-prober',
|
||||||
'passwd',
|
'passwd',
|
||||||
'pci-ids',
|
'pci-ids',
|
||||||
'pidstat',
|
'pidstat',
|
||||||
@ -145,9 +148,11 @@ parsers: List[str] = [
|
|||||||
'rpm-qi',
|
'rpm-qi',
|
||||||
'rsync',
|
'rsync',
|
||||||
'rsync-s',
|
'rsync-s',
|
||||||
|
'semver',
|
||||||
'sfdisk',
|
'sfdisk',
|
||||||
'shadow',
|
'shadow',
|
||||||
'ss',
|
'ss',
|
||||||
|
'sshd-conf',
|
||||||
'stat',
|
'stat',
|
||||||
'stat-s',
|
'stat-s',
|
||||||
'sysctl',
|
'sysctl',
|
||||||
@ -453,22 +458,31 @@ def streaming_parser_mod_list(
|
|||||||
|
|
||||||
return plist
|
return plist
|
||||||
|
|
||||||
def parser_info(parser_mod_name: str, documentation: bool = False) -> ParserInfoType:
|
def parser_info(
|
||||||
|
parser_mod_name: Union[str, ModuleType],
|
||||||
|
documentation: bool = False
|
||||||
|
) -> ParserInfoType:
|
||||||
"""
|
"""
|
||||||
Returns a dictionary that includes the parser module metadata.
|
Returns a dictionary that includes the parser module metadata.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
parser_mod_name: (string) name of the parser module. This
|
parser_mod_name: (string or name of the parser module. This
|
||||||
function will accept module_name,
|
Module) function will accept module_name,
|
||||||
cli-name, and --argument-name
|
cli-name, and --argument-name
|
||||||
variants of the module name.
|
variants of the module name as well
|
||||||
|
as a parser module object.
|
||||||
|
|
||||||
documentation: (boolean) include parser docstring if True
|
documentation: (boolean) include parser docstring if True
|
||||||
"""
|
"""
|
||||||
|
if isinstance(parser_mod_name, ModuleType):
|
||||||
|
parser_mod = parser_mod_name
|
||||||
|
parser_mod_name = parser_mod.__name__.split('.')[-1]
|
||||||
|
else:
|
||||||
# ensure parser_mod_name is a true module name and not a cli name
|
# ensure parser_mod_name is a true module name and not a cli name
|
||||||
parser_mod_name = _cliname_to_modname(parser_mod_name)
|
parser_mod_name = _cliname_to_modname(parser_mod_name)
|
||||||
parser_mod = _get_parser(parser_mod_name)
|
parser_mod = _get_parser(parser_mod_name)
|
||||||
|
|
||||||
info_dict: ParserInfoType = {}
|
info_dict: ParserInfoType = {}
|
||||||
|
|
||||||
if hasattr(parser_mod, 'info'):
|
if hasattr(parser_mod, 'info'):
|
||||||
@ -525,11 +539,17 @@ def all_parser_info(
|
|||||||
|
|
||||||
return p_info_list
|
return p_info_list
|
||||||
|
|
||||||
def get_help(parser_mod_name: str) -> None:
|
def get_help(parser_mod_name: Union[str, ModuleType]) -> None:
|
||||||
"""
|
"""
|
||||||
Show help screen for the selected parser.
|
Show help screen for the selected parser.
|
||||||
|
|
||||||
This function will accept **module_name**, **cli-name**, and
|
This function will accept **module_name**, **cli-name**, and
|
||||||
**--argument-name** variants of the module name string.
|
**--argument-name** variants of the module name string as well as a
|
||||||
|
parser module object.
|
||||||
"""
|
"""
|
||||||
help(_get_parser(parser_mod_name))
|
if isinstance(parser_mod_name, ModuleType):
|
||||||
|
jc_parser = parser_mod_name
|
||||||
|
else:
|
||||||
|
jc_parser = _get_parser(parser_mod_name)
|
||||||
|
|
||||||
|
help(jc_parser)
|
||||||
|
@ -72,13 +72,15 @@ Examples:
|
|||||||
...
|
...
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
|
from typing import List, Union, Type
|
||||||
|
from jc.jc_types import JSONDictType
|
||||||
import jc.utils
|
import jc.utils
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.4'
|
version = '1.5'
|
||||||
description = 'CSV file parser'
|
description = 'CSV file parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -89,7 +91,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def _process(proc_data):
|
def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]:
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -107,7 +109,11 @@ def _process(proc_data):
|
|||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(
|
||||||
|
data: Union[str, bytes],
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False
|
||||||
|
) -> List[JSONDictType]:
|
||||||
"""
|
"""
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
@ -124,6 +130,12 @@ def parse(data, raw=False, quiet=False):
|
|||||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
jc.utils.input_type_check(data)
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
|
# remove BOM bytes, if present
|
||||||
|
if isinstance(data, str):
|
||||||
|
data = data.encode('utf-8')
|
||||||
|
|
||||||
|
data = data.decode('utf-8-sig')
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
|
|
||||||
@ -132,7 +144,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
if jc.utils.has_data(data):
|
if jc.utils.has_data(data):
|
||||||
|
|
||||||
dialect = 'excel' # default in csv module
|
dialect: Union[str, Type[csv.Dialect]] = 'excel' # default in csv module
|
||||||
try:
|
try:
|
||||||
dialect = csv.Sniffer().sniff(data[:1024])
|
dialect = csv.Sniffer().sniff(data[:1024])
|
||||||
if '""' in data:
|
if '""' in data:
|
||||||
@ -145,7 +157,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
for row in reader:
|
for row in reader:
|
||||||
raw_output.append(row)
|
raw_output.append(row)
|
||||||
|
|
||||||
if raw:
|
return raw_output if raw else _process(raw_output)
|
||||||
return raw_output
|
|
||||||
else:
|
|
||||||
return _process(raw_output)
|
|
||||||
|
@ -63,7 +63,7 @@ from jc.exceptions import ParseError
|
|||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.3'
|
version = '1.4'
|
||||||
description = 'CSV file streaming parser'
|
description = 'CSV file streaming parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -127,7 +127,14 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
|||||||
if len(temp_list) == 1:
|
if len(temp_list) == 1:
|
||||||
raise ParseError('Unable to detect line endings. Please try the non-streaming CSV parser instead.')
|
raise ParseError('Unable to detect line endings. Please try the non-streaming CSV parser instead.')
|
||||||
|
|
||||||
sniffdata = '\n'.join(temp_list)[:1024]
|
# remove BOM bytes from first row, if present
|
||||||
|
if temp_list:
|
||||||
|
if isinstance(temp_list[0], str):
|
||||||
|
temp_list[0] = temp_list[0].encode('utf-8')
|
||||||
|
|
||||||
|
temp_list[0] = temp_list[0].decode('utf-8-sig')
|
||||||
|
|
||||||
|
sniffdata = '\r\n'.join(temp_list)[:1024]
|
||||||
dialect = 'excel' # default in csv module
|
dialect = 'excel' # default in csv module
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
"""jc - JSON Convert `du` command output parser
|
"""jc - JSON Convert `du` command output parser
|
||||||
|
|
||||||
|
The `du -h` option is not supported with the default output. If you
|
||||||
|
would like to use `du -h` or other options that change the output, be sure
|
||||||
|
to use `jc --raw` (cli) or `raw=True` (module).
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ du | jc --du
|
$ du | jc --du
|
||||||
|
185
jc/parsers/findmnt.py
Normal file
185
jc/parsers/findmnt.py
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
"""jc - JSON Convert `findmnt` command output parser
|
||||||
|
|
||||||
|
Supports `-a`, `-l`, or no `findmnt` options.
|
||||||
|
|
||||||
|
> Note: Newer versions of `findmnt` have a JSON output option.
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ findmnt | jc --findmnt
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ jc findmnt
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('findmnt', findmnt_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"target": string,
|
||||||
|
"source": string,
|
||||||
|
"fstype": string,
|
||||||
|
"options": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"kv_options": {
|
||||||
|
"<key_name>": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ findmnt | jc --findmnt -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"target": "/",
|
||||||
|
"source": "/dev/mapper/centos-root",
|
||||||
|
"fstype": "xfs",
|
||||||
|
"options": [
|
||||||
|
"rw",
|
||||||
|
"relatime",
|
||||||
|
"seclabel",
|
||||||
|
"attr2",
|
||||||
|
"inode64",
|
||||||
|
"noquota"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target": "/sys/fs/cgroup",
|
||||||
|
"source": "tmpfs",
|
||||||
|
"fstype": "tmpfs",
|
||||||
|
"options": [
|
||||||
|
"ro",
|
||||||
|
"nosuid",
|
||||||
|
"nodev",
|
||||||
|
"noexec",
|
||||||
|
"seclabel"
|
||||||
|
],
|
||||||
|
"kv_options": {
|
||||||
|
"mode": "755"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
$ findmnt | jc --findmnt -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"target": "/",
|
||||||
|
"source": "/dev/mapper/centos-root",
|
||||||
|
"fstype": "xfs",
|
||||||
|
"options": "rw,relatime,seclabel,attr2,inode64,noquota"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target": "/sys/fs/cgroup",
|
||||||
|
"source": "tmpfs",
|
||||||
|
"fstype": "tmpfs",
|
||||||
|
"options": "ro,nosuid,nodev,noexec,seclabel,mode=755"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
import re
|
||||||
|
from typing import List, Dict
|
||||||
|
from jc.jc_types import JSONDictType
|
||||||
|
from jc.parsers.universal import simple_table_parse
|
||||||
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
|
class info():
|
||||||
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.0'
|
||||||
|
description = '`findmnt` command parser'
|
||||||
|
author = 'Kelly Brazil'
|
||||||
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
|
compatible = ['linux']
|
||||||
|
magic_commands = ['findmnt']
|
||||||
|
|
||||||
|
|
||||||
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
|
def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]:
|
||||||
|
"""
|
||||||
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
proc_data: (List of Dictionaries) raw structured data to process
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
List of Dictionaries. Structured to conform to the schema.
|
||||||
|
"""
|
||||||
|
# split normal options and k/v options
|
||||||
|
for item in proc_data:
|
||||||
|
reg_options = []
|
||||||
|
kv_options = {}
|
||||||
|
|
||||||
|
if 'options' in item:
|
||||||
|
opt_list = item['options'].split(',') # type: ignore
|
||||||
|
|
||||||
|
for option in opt_list:
|
||||||
|
if '=' in option:
|
||||||
|
k, v = option.split('=', maxsplit=1)
|
||||||
|
kv_options[k] = v
|
||||||
|
|
||||||
|
else:
|
||||||
|
reg_options.append(option)
|
||||||
|
|
||||||
|
if reg_options:
|
||||||
|
item['options'] = reg_options
|
||||||
|
if kv_options:
|
||||||
|
item['kv_options'] = kv_options
|
||||||
|
|
||||||
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
|
def _replace(matchobj: re.Match) -> str:
|
||||||
|
if matchobj:
|
||||||
|
matchlen = len(matchobj.group(1))
|
||||||
|
return ' ' * matchlen + '/'
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
def parse(
|
||||||
|
data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False
|
||||||
|
) -> List[JSONDictType]:
|
||||||
|
"""
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
"""
|
||||||
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
|
raw_output: List[Dict] = []
|
||||||
|
table: List[str] = []
|
||||||
|
|
||||||
|
if jc.utils.has_data(data):
|
||||||
|
|
||||||
|
for line in filter(None, data.splitlines()):
|
||||||
|
# remove initial drawing characters
|
||||||
|
line = re.sub(r'^([│ ├─└─|`-]+)/', _replace, line, count=1)
|
||||||
|
table.append(line)
|
||||||
|
|
||||||
|
table[0] = table[0].lower()
|
||||||
|
raw_output = simple_table_parse(table)
|
||||||
|
|
||||||
|
return raw_output if raw else _process(raw_output)
|
138
jc/parsers/git_ls_remote.py
Normal file
138
jc/parsers/git_ls_remote.py
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
"""jc - JSON Convert `git ls-remote` command output parser
|
||||||
|
|
||||||
|
This parser outputs two schemas:
|
||||||
|
|
||||||
|
- Default: A single object with key/value pairs
|
||||||
|
- Raw: An array of objects (`--raw` (cli) or `raw=True (module))
|
||||||
|
|
||||||
|
See the Schema section for more details
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ git ls-remote | jc --git-ls-remote
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ jc git ls-remote
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('git_ls_remote', git_ls_remote_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
Default:
|
||||||
|
{
|
||||||
|
<reference>: string
|
||||||
|
}
|
||||||
|
|
||||||
|
Raw:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"reference": string,
|
||||||
|
"commit": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ git ls-remote | jc --git-ls-remote -p
|
||||||
|
{
|
||||||
|
"HEAD": "214cd6b9e09603b3c4fa02203b24fb2bc3d4e338",
|
||||||
|
"refs/heads/dev": "b884f6aacca39e05994596d8fdfa7e7c4f1e0389",
|
||||||
|
"refs/heads/master": "214cd6b9e09603b3c4fa02203b24fb2bc3d4e338",
|
||||||
|
"refs/pull/1/head": "e416c77bed1267254da972b0f95b7ff1d43fccef",
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
$ git ls-remote | jc --git-ls-remote -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"reference": "HEAD",
|
||||||
|
"commit": "214cd6b9e09603b3c4fa02203b24fb2bc3d4e338"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"reference": "refs/heads/dev",
|
||||||
|
"commit": "b884f6aacca39e05994596d8fdfa7e7c4f1e0389"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
from typing import List, Dict
|
||||||
|
from jc.jc_types import JSONDictType
|
||||||
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
|
class info():
|
||||||
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.0'
|
||||||
|
description = '`git ls-remote` command parser'
|
||||||
|
author = 'Kelly Brazil'
|
||||||
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
|
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||||
|
magic_commands = ['git ls-remote']
|
||||||
|
|
||||||
|
|
||||||
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
|
def _process(proc_data: List[JSONDictType]) -> JSONDictType:
|
||||||
|
"""
|
||||||
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
proc_data: (List of Dictionaries) raw structured data to process
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary. Structured to conform to the schema.
|
||||||
|
"""
|
||||||
|
new_dict: JSONDictType = {}
|
||||||
|
|
||||||
|
for item in proc_data:
|
||||||
|
new_dict.update(
|
||||||
|
{
|
||||||
|
item['reference']: item['commit'] # type: ignore
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return new_dict
|
||||||
|
|
||||||
|
|
||||||
|
def parse(
|
||||||
|
data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False
|
||||||
|
) -> List[JSONDictType]:
|
||||||
|
"""
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary (default) or List of Dictionaries (raw)
|
||||||
|
"""
|
||||||
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
|
raw_output: List[Dict] = []
|
||||||
|
|
||||||
|
if jc.utils.has_data(data):
|
||||||
|
|
||||||
|
for line in filter(None, data.splitlines()):
|
||||||
|
|
||||||
|
commit, reference = line.split()
|
||||||
|
output_line = {
|
||||||
|
'reference': reference,
|
||||||
|
'commit': commit
|
||||||
|
}
|
||||||
|
raw_output.append(output_line)
|
||||||
|
|
||||||
|
return raw_output if raw else _process(raw_output) # type: ignore
|
@ -1,6 +1,9 @@
|
|||||||
"""jc - JSON Convert `ifconfig` command output parser
|
"""jc - JSON Convert `foo` command output parser
|
||||||
|
|
||||||
> Note: No `ifconfig` options are supported.
|
No `ifconfig` options are supported.
|
||||||
|
|
||||||
|
Consider using the `ip` command instead of `ifconfig` as it supports native
|
||||||
|
JSON output.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -20,19 +23,21 @@ Schema:
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
|
"type": string,
|
||||||
|
"metric": integer
|
||||||
"flags": integer,
|
"flags": integer,
|
||||||
"state": [
|
"state": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"mtu": integer,
|
"mtu": integer,
|
||||||
"ipv4_addr": string,
|
|
||||||
"ipv4_mask": string,
|
|
||||||
"ipv4_bcast": string,
|
|
||||||
"ipv6_addr": string,
|
|
||||||
"ipv6_mask": integer,
|
|
||||||
"ipv6_scope": string,
|
|
||||||
"mac_addr": string,
|
"mac_addr": string,
|
||||||
"type": string,
|
"ipv4_addr": string, # [0]
|
||||||
|
"ipv4_mask": string, # [0]
|
||||||
|
"ipv4_bcast": string, # [0]
|
||||||
|
"ipv6_addr": string, # [0]
|
||||||
|
"ipv6_mask": integer, # [0]
|
||||||
|
"ipv6_scope": string, # [0]
|
||||||
|
"ipv6_type": string, # [0]
|
||||||
"rx_packets": integer,
|
"rx_packets": integer,
|
||||||
"rx_bytes": integer,
|
"rx_bytes": integer,
|
||||||
"rx_errors": integer,
|
"rx_errors": integer,
|
||||||
@ -46,13 +51,53 @@ Schema:
|
|||||||
"tx_overruns": integer,
|
"tx_overruns": integer,
|
||||||
"tx_carrier": integer,
|
"tx_carrier": integer,
|
||||||
"tx_collisions": integer,
|
"tx_collisions": integer,
|
||||||
"metric": integer
|
"options": string,
|
||||||
|
"options_flags": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"status": string,
|
||||||
|
"hw_address": string,
|
||||||
|
"media": string,
|
||||||
|
"media_flags": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"nd6_options": integer,
|
||||||
|
"nd6_flags": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"plugged": string,
|
||||||
|
"vendor": string,
|
||||||
|
"vendor_pn": string,
|
||||||
|
"vendor_sn": string,
|
||||||
|
"vendor_date": string,
|
||||||
|
"module_temperature": string,
|
||||||
|
"module_voltage": string
|
||||||
|
"ipv4": [
|
||||||
|
{
|
||||||
|
"address": string,
|
||||||
|
"mask": string,
|
||||||
|
"broadcast": string
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ipv6: [
|
||||||
|
{
|
||||||
|
"address": string,
|
||||||
|
"mask": integer,
|
||||||
|
"scope": string,
|
||||||
|
"type": string
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[0] these fields only pick up the last IP address in the interface
|
||||||
|
output and are here for backwards compatibility. For information on
|
||||||
|
all IP addresses, use the `ipv4` and `ipv6` objects which contain an
|
||||||
|
array of IP address objects.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ ifconfig | jc --ifconfig -p
|
$ ifconfig ens33 | jc --ifconfig -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "ens33",
|
"name": "ens33",
|
||||||
@ -64,135 +109,108 @@ Examples:
|
|||||||
"MULTICAST"
|
"MULTICAST"
|
||||||
],
|
],
|
||||||
"mtu": 1500,
|
"mtu": 1500,
|
||||||
|
"type": "Ethernet",
|
||||||
|
"mac_addr": "00:0c:29:3b:58:0e",
|
||||||
"ipv4_addr": "192.168.71.137",
|
"ipv4_addr": "192.168.71.137",
|
||||||
"ipv4_mask": "255.255.255.0",
|
"ipv4_mask": "255.255.255.0",
|
||||||
"ipv4_bcast": "192.168.71.255",
|
"ipv4_bcast": "192.168.71.255",
|
||||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
"ipv6_mask": 64,
|
"ipv6_mask": 64,
|
||||||
"ipv6_scope": "0x20",
|
"ipv6_scope": "0x20",
|
||||||
"mac_addr": "00:0c:29:3b:58:0e",
|
"ipv6_type": "link",
|
||||||
"type": "Ethernet",
|
"metric": null,
|
||||||
"rx_packets": 8061,
|
"rx_packets": 8061,
|
||||||
"rx_bytes": 1514413,
|
|
||||||
"rx_errors": 0,
|
"rx_errors": 0,
|
||||||
"rx_dropped": 0,
|
"rx_dropped": 0,
|
||||||
"rx_overruns": 0,
|
"rx_overruns": 0,
|
||||||
"rx_frame": 0,
|
"rx_frame": 0,
|
||||||
"tx_packets": 4502,
|
"tx_packets": 4502,
|
||||||
|
"tx_errors": 0,
|
||||||
|
"tx_dropped": 0,
|
||||||
|
"tx_overruns": 0,
|
||||||
|
"tx_carrier": 0,
|
||||||
|
"tx_collisions": 0,
|
||||||
|
"rx_bytes": 1514413,
|
||||||
"tx_bytes": 866622,
|
"tx_bytes": 866622,
|
||||||
"tx_errors": 0,
|
"ipv4": [
|
||||||
"tx_dropped": 0,
|
|
||||||
"tx_overruns": 0,
|
|
||||||
"tx_carrier": 0,
|
|
||||||
"tx_collisions": 0,
|
|
||||||
"metric": null
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "lo",
|
"address": "192.168.71.137",
|
||||||
"flags": 73,
|
"mask": "255.255.255.0",
|
||||||
"state": [
|
"broadcast": "192.168.71.255"
|
||||||
"UP",
|
}
|
||||||
"LOOPBACK",
|
|
||||||
"RUNNING"
|
|
||||||
],
|
],
|
||||||
"mtu": 65536,
|
"ipv6": [
|
||||||
"ipv4_addr": "127.0.0.1",
|
{
|
||||||
"ipv4_mask": "255.0.0.0",
|
"address": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
"ipv4_bcast": null,
|
"mask": 64,
|
||||||
"ipv6_addr": "::1",
|
"scope": "0x20",
|
||||||
"ipv6_mask": 128,
|
"type": "link"
|
||||||
"ipv6_scope": "0x10",
|
}
|
||||||
"mac_addr": null,
|
]
|
||||||
"type": "Local Loopback",
|
|
||||||
"rx_packets": 73,
|
|
||||||
"rx_bytes": 6009,
|
|
||||||
"rx_errors": 0,
|
|
||||||
"rx_dropped": 0,
|
|
||||||
"rx_overruns": 0,
|
|
||||||
"rx_frame": 0,
|
|
||||||
"tx_packets": 73,
|
|
||||||
"tx_bytes": 6009,
|
|
||||||
"tx_errors": 0,
|
|
||||||
"tx_dropped": 0,
|
|
||||||
"tx_overruns": 0,
|
|
||||||
"tx_carrier": 0,
|
|
||||||
"tx_collisions": 0,
|
|
||||||
"metric": null
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
$ ifconfig | jc --ifconfig -p -r
|
$ ifconfig ens33 | jc --ifconfig -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "ens33",
|
"name": "ens33",
|
||||||
"flags": "4163",
|
"flags": "4163",
|
||||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||||
"mtu": "1500",
|
"mtu": "1500",
|
||||||
|
"type": "Ethernet",
|
||||||
|
"mac_addr": "00:0c:29:3b:58:0e",
|
||||||
"ipv4_addr": "192.168.71.137",
|
"ipv4_addr": "192.168.71.137",
|
||||||
"ipv4_mask": "255.255.255.0",
|
"ipv4_mask": "255.255.255.0",
|
||||||
"ipv4_bcast": "192.168.71.255",
|
"ipv4_bcast": "192.168.71.255",
|
||||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
"ipv6_mask": "64",
|
"ipv6_mask": "64",
|
||||||
"ipv6_scope": "0x20",
|
"ipv6_scope": "0x20",
|
||||||
"mac_addr": "00:0c:29:3b:58:0e",
|
"ipv6_type": "link",
|
||||||
"type": "Ethernet",
|
"metric": null,
|
||||||
"rx_packets": "8061",
|
"rx_packets": "8061",
|
||||||
"rx_bytes": "1514413",
|
|
||||||
"rx_errors": "0",
|
"rx_errors": "0",
|
||||||
"rx_dropped": "0",
|
"rx_dropped": "0",
|
||||||
"rx_overruns": "0",
|
"rx_overruns": "0",
|
||||||
"rx_frame": "0",
|
"rx_frame": "0",
|
||||||
"tx_packets": "4502",
|
"tx_packets": "4502",
|
||||||
|
"tx_errors": "0",
|
||||||
|
"tx_dropped": "0",
|
||||||
|
"tx_overruns": "0",
|
||||||
|
"tx_carrier": "0",
|
||||||
|
"tx_collisions": "0",
|
||||||
|
"rx_bytes": "1514413",
|
||||||
"tx_bytes": "866622",
|
"tx_bytes": "866622",
|
||||||
"tx_errors": "0",
|
"ipv4": [
|
||||||
"tx_dropped": "0",
|
|
||||||
"tx_overruns": "0",
|
|
||||||
"tx_carrier": "0",
|
|
||||||
"tx_collisions": "0",
|
|
||||||
"metric": null
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "lo",
|
"address": "192.168.71.137",
|
||||||
"flags": "73",
|
"mask": "255.255.255.0",
|
||||||
"state": "UP,LOOPBACK,RUNNING",
|
"broadcast": "192.168.71.255"
|
||||||
"mtu": "65536",
|
}
|
||||||
"ipv4_addr": "127.0.0.1",
|
],
|
||||||
"ipv4_mask": "255.0.0.0",
|
"ipv6": [
|
||||||
"ipv4_bcast": null,
|
{
|
||||||
"ipv6_addr": "::1",
|
"address": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
"ipv6_mask": "128",
|
"mask": "64",
|
||||||
"ipv6_scope": "0x10",
|
"scope": "0x20",
|
||||||
"mac_addr": null,
|
"type": "link"
|
||||||
"type": "Local Loopback",
|
}
|
||||||
"rx_packets": "73",
|
]
|
||||||
"rx_bytes": "6009",
|
|
||||||
"rx_errors": "0",
|
|
||||||
"rx_dropped": "0",
|
|
||||||
"rx_overruns": "0",
|
|
||||||
"rx_frame": "0",
|
|
||||||
"tx_packets": "73",
|
|
||||||
"tx_bytes": "6009",
|
|
||||||
"tx_errors": "0",
|
|
||||||
"tx_dropped": "0",
|
|
||||||
"tx_overruns": "0",
|
|
||||||
"tx_carrier": "0",
|
|
||||||
"tx_collisions": "0",
|
|
||||||
"metric": null
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
from collections import namedtuple
|
from ipaddress import IPv4Network
|
||||||
|
from typing import List, Dict
|
||||||
|
from jc.jc_types import JSONDictType
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.12'
|
version = '2.0'
|
||||||
description = '`ifconfig` command parser'
|
description = '`ifconfig` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
details = 'Using ifconfig-parser from https://github.com/KnightWhoSayNi/ifconfig-parser'
|
|
||||||
compatible = ['linux', 'aix', 'freebsd', 'darwin']
|
compatible = ['linux', 'aix', 'freebsd', 'darwin']
|
||||||
magic_commands = ['ifconfig']
|
magic_commands = ['ifconfig']
|
||||||
|
|
||||||
@ -200,11 +218,163 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
class _IfconfigParser(object):
|
def _convert_cidr_to_quad(string):
|
||||||
"""ifconfig parser module written by threeheadedknight@protonmail.com"""
|
return str(IPv4Network('0.0.0.0/' + string).netmask)
|
||||||
|
|
||||||
|
|
||||||
|
def _process(proc_data: List[JSONDictType]) -> List[JSONDictType]:
|
||||||
|
"""
|
||||||
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
proc_data: (List of Dictionaries) raw structured data to process
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
List of Dictionaries. Structured to conform to the schema.
|
||||||
|
"""
|
||||||
|
int_list = {
|
||||||
|
'flags', 'mtu', 'ipv6_mask', 'rx_packets', 'rx_bytes', 'rx_errors', 'rx_dropped',
|
||||||
|
'rx_overruns', 'rx_frame', 'tx_packets', 'tx_bytes', 'tx_errors', 'tx_dropped',
|
||||||
|
'tx_overruns', 'tx_carrier', 'tx_collisions', 'metric', 'nd6_options'
|
||||||
|
}
|
||||||
|
|
||||||
|
for entry in proc_data:
|
||||||
|
for key in entry:
|
||||||
|
if key in int_list:
|
||||||
|
entry[key] = jc.utils.convert_to_int(entry[key])
|
||||||
|
|
||||||
|
# convert OSX-style subnet mask to dotted quad
|
||||||
|
if 'ipv4_mask' in entry:
|
||||||
|
try:
|
||||||
|
if entry['ipv4_mask'].startswith('0x'): # type: ignore
|
||||||
|
new_mask = entry['ipv4_mask']
|
||||||
|
new_mask = new_mask.lstrip('0x') # type: ignore
|
||||||
|
new_mask = '.'.join(str(int(i, 16)) for i in [new_mask[i:i + 2] for i in range(0, len(new_mask), 2)])
|
||||||
|
entry['ipv4_mask'] = new_mask
|
||||||
|
except (ValueError, TypeError, AttributeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# for new-style freebsd output convert CIDR mask to dotted-quad to match other output
|
||||||
|
if entry['ipv4_mask'] and not '.' in entry['ipv4_mask']: # type: ignore
|
||||||
|
entry['ipv4_mask'] = _convert_cidr_to_quad(entry['ipv4_mask'])
|
||||||
|
|
||||||
|
# convert state value to an array
|
||||||
|
if 'state' in entry:
|
||||||
|
try:
|
||||||
|
new_state = entry['state'].split(',') # type: ignore
|
||||||
|
entry['state'] = new_state
|
||||||
|
except (ValueError, TypeError, AttributeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# conversions for list of ipv4 addresses
|
||||||
|
if 'ipv4' in entry:
|
||||||
|
for ip_address in entry['ipv4']: # type: ignore
|
||||||
|
if 'mask' in ip_address:
|
||||||
|
try:
|
||||||
|
if ip_address['mask'].startswith('0x'): # type: ignore
|
||||||
|
new_mask = ip_address['mask'] # type: ignore
|
||||||
|
new_mask = new_mask.lstrip('0x')
|
||||||
|
new_mask = '.'.join(str(int(i, 16)) for i in [new_mask[i:i + 2] for i in range(0, len(new_mask), 2)])
|
||||||
|
ip_address['mask'] = new_mask # type: ignore
|
||||||
|
except (ValueError, TypeError, AttributeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# for new-style freebsd output convert CIDR mask to dotted-quad to match other output
|
||||||
|
if ip_address['mask'] and not '.' in ip_address['mask']: # type: ignore
|
||||||
|
ip_address['mask'] = _convert_cidr_to_quad(ip_address['mask']) # type: ignore
|
||||||
|
|
||||||
|
# conversions for list of ipv6 addresses
|
||||||
|
if 'ipv6' in entry:
|
||||||
|
for ip_address in entry['ipv6']: # type: ignore
|
||||||
|
if 'mask' in ip_address:
|
||||||
|
ip_address['mask'] = jc.utils.convert_to_int(ip_address['mask']) # type: ignore
|
||||||
|
|
||||||
|
# final conversions
|
||||||
|
if entry.get('media_flags', None):
|
||||||
|
entry['media_flags'] = entry['media_flags'].split(',') # type: ignore
|
||||||
|
|
||||||
|
if entry.get('nd6_flags', None):
|
||||||
|
entry['nd6_flags'] = entry['nd6_flags'].split(',') # type: ignore
|
||||||
|
|
||||||
|
if entry.get('options_flags', None):
|
||||||
|
entry['options_flags'] = entry['options_flags'].split(',') # type: ignore
|
||||||
|
|
||||||
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
|
def _bundle_match(pattern_list, string):
|
||||||
|
"""Returns a match object if a string matches one of a list of patterns.
|
||||||
|
If no match is found, returns None"""
|
||||||
|
for pattern in pattern_list:
|
||||||
|
match = re.search(pattern, string)
|
||||||
|
if match:
|
||||||
|
return match
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def parse(
|
||||||
|
data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False
|
||||||
|
) -> List[JSONDictType]:
|
||||||
|
"""
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
"""
|
||||||
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
|
raw_output: List[Dict] = []
|
||||||
|
|
||||||
|
# for backwards compatibility, preset all fields to None
|
||||||
|
interface_obj: Dict = {
|
||||||
|
"name": None,
|
||||||
|
"flags": None,
|
||||||
|
"state": None,
|
||||||
|
"mtu": None,
|
||||||
|
"type": None,
|
||||||
|
"mac_addr": None,
|
||||||
|
"ipv4_addr": None,
|
||||||
|
"ipv4_mask": None,
|
||||||
|
"ipv4_bcast": None,
|
||||||
|
"ipv6_addr": None,
|
||||||
|
"ipv6_mask": None,
|
||||||
|
"ipv6_scope": None,
|
||||||
|
"ipv6_type": None,
|
||||||
|
"metric": None,
|
||||||
|
"rx_packets": None,
|
||||||
|
"rx_errors": None,
|
||||||
|
"rx_dropped": None,
|
||||||
|
"rx_overruns": None,
|
||||||
|
"rx_frame": None,
|
||||||
|
"tx_packets": None,
|
||||||
|
"tx_errors": None,
|
||||||
|
"tx_dropped": None,
|
||||||
|
"tx_overruns": None,
|
||||||
|
"tx_carrier": None,
|
||||||
|
"tx_collisions": None,
|
||||||
|
"rx_bytes": None,
|
||||||
|
"tx_bytes": None
|
||||||
|
}
|
||||||
|
|
||||||
|
interface_item: Dict = interface_obj.copy()
|
||||||
|
ipv4_info: List = []
|
||||||
|
ipv6_info: List = []
|
||||||
|
|
||||||
|
# Below regular expression patterns are based off of the work of:
|
||||||
|
# https://github.com/KnightWhoSayNi/ifconfig-parser
|
||||||
# Author: threeheadedknight@protonmail.com
|
# Author: threeheadedknight@protonmail.com
|
||||||
# Date created: 30.06.2018 17:03
|
|
||||||
# Python Version: 3.7
|
|
||||||
|
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
@ -228,272 +398,285 @@ class _IfconfigParser(object):
|
|||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
attributes = [
|
|
||||||
'name', 'type', 'mac_addr', 'ipv4_addr', 'ipv4_bcast', 'ipv4_mask', 'ipv6_addr',
|
|
||||||
'ipv6_mask', 'ipv6_scope', 'state', 'mtu', 'metric', 'rx_packets', 'rx_errors',
|
|
||||||
'rx_dropped', 'rx_overruns', 'rx_frame', 'tx_packets', 'tx_errors', 'tx_dropped',
|
|
||||||
'tx_overruns', 'tx_carrier', 'tx_collisions', 'rx_bytes', 'tx_bytes'
|
|
||||||
]
|
|
||||||
|
|
||||||
def __init__(self, console_output):
|
|
||||||
"""
|
|
||||||
:param console_output:
|
|
||||||
"""
|
|
||||||
|
|
||||||
if isinstance(console_output, list):
|
|
||||||
source_data = " ".join(console_output)
|
|
||||||
else:
|
|
||||||
source_data = console_output.replace("\n", " ")
|
|
||||||
self.interfaces = self.parser(source_data=source_data)
|
|
||||||
|
|
||||||
def list_interfaces(self):
|
|
||||||
"""
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return sorted(self.interfaces.keys())
|
|
||||||
|
|
||||||
def count_interfaces(self):
|
|
||||||
"""
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return len(self.interfaces.keys())
|
|
||||||
|
|
||||||
def filter_interfaces(self, **kwargs):
|
|
||||||
"""
|
|
||||||
:param kwargs:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
for attr in kwargs.keys():
|
|
||||||
if attr not in _IfconfigParser.attributes:
|
|
||||||
raise ValueError("Attribute [{}] not supported.".format(attr))
|
|
||||||
|
|
||||||
filtered_interfaces = []
|
|
||||||
for name, details in self.interfaces.items():
|
|
||||||
|
|
||||||
if all(getattr(details, attr) == kwargs[attr] for attr in kwargs.keys()):
|
|
||||||
filtered_interfaces.append(name)
|
|
||||||
|
|
||||||
return sorted(filtered_interfaces)
|
|
||||||
|
|
||||||
def get_interface(self, name):
|
|
||||||
"""
|
|
||||||
:param name:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
if name in self.list_interfaces():
|
|
||||||
return self.interfaces[name]
|
|
||||||
else:
|
|
||||||
raise InterfaceNotFound("Interface [{}] not found.".format(name))
|
|
||||||
|
|
||||||
def get_interfaces(self):
|
|
||||||
"""
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return self.interfaces
|
|
||||||
|
|
||||||
def is_available(self, name):
|
|
||||||
"""
|
|
||||||
:param name:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return name in self.interfaces
|
|
||||||
|
|
||||||
def parser(self, source_data):
|
|
||||||
"""
|
|
||||||
:param source_data:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Linux syntax
|
# Linux syntax
|
||||||
re_linux_interface = re.compile(
|
re_linux_interface = re.compile(r'''
|
||||||
r"(?P<name>[a-zA-Z0-9:._-]+)\s+Link encap:(?P<type>\S+\s?\S+)(\s+HWaddr\s+\b"
|
(?P<name>[a-zA-Z0-9:._-]+)\s+
|
||||||
r"(?P<mac_addr>[0-9A-Fa-f:?]+))?",
|
Link encap:(?P<type>\S+\s?\S+)
|
||||||
re.I)
|
(\s+HWaddr\s+\b(?P<mac_addr>[0-9A-Fa-f:?]+))?
|
||||||
re_linux_ipv4 = re.compile(
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
r"inet addr:(?P<ipv4_addr>(?:[0-9]{1,3}\.){3}[0-9]{1,3})(\s+Bcast:"
|
)
|
||||||
r"(?P<ipv4_bcast>(?:[0-9]{1,3}\.){3}[0-9]{1,3}))?\s+Mask:(?P<ipv4_mask>(?:[0-9]{1,3}\.){3}[0-9]{1,3})",
|
re_linux_ipv4 = re.compile(r'''
|
||||||
re.I)
|
inet addr:(?P<address>(?:[0-9]{1,3}\.){3}[0-9]{1,3})(\s+
|
||||||
re_linux_ipv6 = re.compile(
|
Bcast:(?P<broadcast>(?:[0-9]{1,3}\.){3}[0-9]{1,3}))?\s+
|
||||||
r"inet6 addr:\s+(?P<ipv6_addr>\S+)/(?P<ipv6_mask>[0-9]+)\s+Scope:(?P<ipv6_scope>Link|Host)",
|
Mask:(?P<mask>(?:[0-9]{1,3}\.){3}[0-9]{1,3})
|
||||||
re.I)
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
re_linux_state = re.compile(
|
)
|
||||||
r"\W+(?P<state>(?:\w+\s)+)(?:\s+)?MTU:(?P<mtu>[0-9]+)\s+Metric:(?P<metric>[0-9]+)", re.I)
|
re_linux_ipv6 = re.compile(r'''
|
||||||
re_linux_rx = re.compile(
|
inet6 addr:\s+(?P<address>\S+)/
|
||||||
r"RX packets:(?P<rx_packets>[0-9]+)\s+errors:(?P<rx_errors>[0-9]+)\s+dropped:"
|
(?P<mask>[0-9]+)\s+
|
||||||
r"(?P<rx_dropped>[0-9]+)\s+overruns:(?P<rx_overruns>[0-9]+)\s+frame:(?P<rx_frame>[0-9]+)",
|
Scope:(?P<scope>Link|Host)
|
||||||
re.I)
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
re_linux_tx = re.compile(
|
)
|
||||||
r"TX packets:(?P<tx_packets>[0-9]+)\s+errors:(?P<tx_errors>[0-9]+)\s+dropped:"
|
re_linux_state = re.compile(r'''
|
||||||
r"(?P<tx_dropped>[0-9]+)\s+overruns:(?P<tx_overruns>[0-9]+)\s+carrier:(?P<tx_carrier>[0-9]+)",
|
\W+(?P<state>(?:\w+\s)+)(?:\s+)?
|
||||||
re.I)
|
MTU:(?P<mtu>[0-9]+)\s+
|
||||||
re_linux_bytes = re.compile(r"\W+RX bytes:(?P<rx_bytes>\d+)\s+\(.*\)\s+TX bytes:(?P<tx_bytes>\d+)\s+\(.*\)", re.I)
|
Metric:(?P<metric>[0-9]+)
|
||||||
re_linux_tx_stats = re.compile(r"collisions:(?P<tx_collisions>[0-9]+)\s+txqueuelen:[0-9]+", re.I)
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
re_linux = [re_linux_interface, re_linux_ipv4, re_linux_ipv6, re_linux_state, re_linux_rx, re_linux_tx,
|
)
|
||||||
re_linux_bytes, re_linux_tx_stats]
|
re_linux_rx = re.compile(r'''
|
||||||
|
RX packets:(?P<rx_packets>[0-9]+)\s+
|
||||||
|
errors:(?P<rx_errors>[0-9]+)\s+
|
||||||
|
dropped:(?P<rx_dropped>[0-9]+)\s+
|
||||||
|
overruns:(?P<rx_overruns>[0-9]+)\s+
|
||||||
|
frame:(?P<rx_frame>[0-9]+)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_linux_tx = re.compile(r'''
|
||||||
|
TX packets:(?P<tx_packets>[0-9]+)\s+
|
||||||
|
errors:(?P<tx_errors>[0-9]+)\s+
|
||||||
|
dropped:(?P<tx_dropped>[0-9]+)\s+
|
||||||
|
overruns:(?P<tx_overruns>[0-9]+)\s+
|
||||||
|
carrier:(?P<tx_carrier>[0-9]+)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_linux_bytes = re.compile(r'''
|
||||||
|
\W+RX bytes:(?P<rx_bytes>\d+)\s+\(.*\)\s+
|
||||||
|
TX bytes:(?P<tx_bytes>\d+)\s+\(.*\)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_linux_tx_stats = re.compile(r'''
|
||||||
|
collisions:(?P<tx_collisions>[0-9]+)\s+
|
||||||
|
txqueuelen:[0-9]+
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
|
||||||
# OpenBSD syntax
|
# OpenBSD syntax
|
||||||
re_openbsd_interface = re.compile(
|
re_openbsd_interface = re.compile(r'''
|
||||||
r"(?P<name>[a-zA-Z0-9:._-]+):\s+flags=(?P<flags>[0-9]+)<(?P<state>\S+)?>\s+mtu\s+(?P<mtu>[0-9]+)",
|
(?P<name>[a-zA-Z0-9:._-]+):\s+
|
||||||
re.I)
|
flags=(?P<flags>[0-9]+)
|
||||||
re_openbsd_ipv4 = re.compile(
|
<(?P<state>\S+)?>\s+
|
||||||
r"inet (?P<ipv4_addr>(?:[0-9]{1,3}\.){3}[0-9]{1,3})\s+netmask\s+"
|
mtu\s+(?P<mtu>[0-9]+)
|
||||||
r"(?P<ipv4_mask>(?:[0-9]{1,3}\.){3}[0-9]{1,3})(\s+broadcast\s+"
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
r"(?P<ipv4_bcast>(?:[0-9]{1,3}\.){3}[0-9]{1,3}))?",
|
)
|
||||||
re.I)
|
re_openbsd_ipv4 = re.compile(r'''
|
||||||
re_openbsd_ipv6 = re.compile(
|
inet\s(?P<address>(?:[0-9]{1,3}\.){3}[0-9]{1,3})\s+netmask\s+
|
||||||
r"inet6\s+(?P<ipv6_addr>\S+)\s+prefixlen\s+(?P<ipv6_mask>[0-9]+)\s+scopeid\s+(?P<ipv6_scope>\w+x\w+)<"
|
(?P<mask>(?:[0-9]{1,3}\.){3}[0-9]{1,3})(\s+broadcast\s+
|
||||||
r"(?:link|host)>",
|
(?P<broadcast>(?:[0-9]{1,3}\.){3}[0-9]{1,3}))?
|
||||||
re.I)
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
re_openbsd_details = re.compile(
|
)
|
||||||
r"\S+\s+(?:(?P<mac_addr>[0-9A-Fa-f:?]+)\s+)?txqueuelen\s+[0-9]+\s+\((?P<type>\S+\s?\S+)\)", re.I)
|
re_openbsd_ipv6 = re.compile(r'''
|
||||||
re_openbsd_rx = re.compile(r"RX packets (?P<rx_packets>[0-9]+)\s+bytes\s+(?P<rx_bytes>\d+)\s+.*", re.I)
|
inet6\s+(?P<address>\S+)\s+
|
||||||
re_openbsd_rx_stats = re.compile(
|
prefixlen\s+(?P<mask>[0-9]+)\s+
|
||||||
r"RX errors (?P<rx_errors>[0-9]+)\s+dropped\s+(?P<rx_dropped>[0-9]+)\s+overruns\s+"
|
scopeid\s+(?P<scope>\w+x\w+)
|
||||||
r"(?P<rx_overruns>[0-9]+)\s+frame\s+(?P<rx_frame>[0-9]+)",
|
<(?P<type>link|host|global)>
|
||||||
re.I)
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
re_openbsd_tx = re.compile(r"TX packets (?P<tx_packets>[0-9]+)\s+bytes\s+(?P<tx_bytes>\d+)\s+.*", re.I)
|
)
|
||||||
re_openbsd_tx_stats = re.compile(
|
re_openbsd_details = re.compile(r'''
|
||||||
r"TX errors (?P<tx_errors>[0-9]+)\s+dropped\s+(?P<tx_dropped>[0-9]+)\s+overruns\s+"
|
\S+\s+(?:(?P<mac_addr>[0-9A-Fa-f:?]+)\s+)?
|
||||||
r"(?P<tx_overruns>[0-9]+)\s+carrier\s+(?P<tx_carrier>[0-9]+)\s+collisions\s+(?P<tx_collisions>[0-9]+)",
|
txqueuelen\s+[0-9]+\s+
|
||||||
re.I)
|
\((?P<type>\S+\s?\S+)\)
|
||||||
re_openbsd = [re_openbsd_interface, re_openbsd_ipv4, re_openbsd_ipv6, re_openbsd_details, re_openbsd_rx,
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
re_openbsd_rx_stats, re_openbsd_tx, re_openbsd_tx_stats]
|
)
|
||||||
|
re_openbsd_rx = re.compile(r'''
|
||||||
|
RX\spackets\s(?P<rx_packets>[0-9]+)\s+
|
||||||
|
bytes\s+(?P<rx_bytes>\d+)\s+.*
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_openbsd_rx_stats = re.compile(r'''
|
||||||
|
RX\serrors\s(?P<rx_errors>[0-9]+)\s+
|
||||||
|
dropped\s+(?P<rx_dropped>[0-9]+)\s+
|
||||||
|
overruns\s+(?P<rx_overruns>[0-9]+)\s+
|
||||||
|
frame\s+(?P<rx_frame>[0-9]+)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_openbsd_tx = re.compile(r'''
|
||||||
|
TX\spackets\s(?P<tx_packets>[0-9]+)\s+
|
||||||
|
bytes\s+(?P<tx_bytes>\d+)\s+.*
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_openbsd_tx_stats = re.compile(r'''
|
||||||
|
TX\serrors\s(?P<tx_errors>[0-9]+)\s+
|
||||||
|
dropped\s+(?P<tx_dropped>[0-9]+)\s+
|
||||||
|
overruns\s+(?P<tx_overruns>[0-9]+)\s+
|
||||||
|
carrier\s+(?P<tx_carrier>[0-9]+)\s+
|
||||||
|
collisions\s+(?P<tx_collisions>[0-9]+)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
|
||||||
# FreeBSD syntax
|
# FreeBSD syntax
|
||||||
re_freebsd_interface = re.compile(
|
re_freebsd_interface = re.compile(r'''
|
||||||
r"(?P<name>[a-zA-Z0-9:._-]+):\s+flags=(?P<flags>[0-9]+)<(?P<state>\S+)>\s+metric\s+"
|
(?P<name>[a-zA-Z0-9:._-]+):\s+
|
||||||
r"(?P<metric>[0-9]+)\s+mtu\s+(?P<mtu>[0-9]+)",
|
flags=(?P<flags>[0-9]+)
|
||||||
re.I)
|
<(?P<state>\S+)>\s+
|
||||||
re_freebsd_ipv4 = re.compile(
|
metric\s+(?P<metric>[0-9]+)\s+
|
||||||
r"inet (?P<ipv4_addr>(?:[0-9]{1,3}\.){3}[0-9]{1,3})\s+netmask\s+(?P<ipv4_mask>0x\S+)(\s+broadcast\s+"
|
mtu\s+(?P<mtu>[0-9]+)
|
||||||
r"(?P<ipv4_bcast>(?:[0-9]{1,3}\.){3}[0-9]{1,3}))?",
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
re.I)
|
)
|
||||||
re_freebsd_ipv6 = re.compile(r"\s?inet6\s(?P<ipv6_addr>.*)(?:\%\w+\d+)\sprefixlen\s(?P<ipv6_mask>\d+)(?:\s\w+)?\sscopeid\s(?P<ipv6_scope>\w+x\w+)", re.I)
|
re_freebsd_ipv4 = re.compile(r'''
|
||||||
re_freebsd_details = re.compile(r"ether\s+(?P<mac_addr>[0-9A-Fa-f:?]+)", re.I)
|
inet\s(?P<address>(?:[0-9]{1,3}\.){3}[0-9]{1,3})\s+
|
||||||
re_freebsd = [re_freebsd_interface, re_freebsd_ipv4, re_freebsd_ipv6, re_freebsd_details]
|
netmask\s+(?P<mask>0x\S+)(\s+
|
||||||
|
broadcast\s+(?P<broadcast>(?:[0-9]{1,3}\.){3}[0-9]{1,3}))?
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_ipv4_v2 = re.compile(r'''
|
||||||
|
inet\s(?P<address>(?:[0-9]{1,3}\.){3}[0-9]{1,3})\/
|
||||||
|
(?P<mask>\d+)(\s+
|
||||||
|
broadcast\s+(?P<broadcast>(?:[0-9]{1,3}\.){3}[0-9]{1,3}))?
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_ipv6 = re.compile(r'''
|
||||||
|
\s?inet6\s(?P<address>.*)(?:\%\w+\d+)\s
|
||||||
|
prefixlen\s(?P<mask>\d+)(?:\s\w+)?\s
|
||||||
|
scopeid\s(?P<scope>\w+x\w+)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_details = re.compile(r'''
|
||||||
|
ether\s+(?P<mac_addr>[0-9A-Fa-f:?]+)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_status = re.compile(r'''
|
||||||
|
status:\s(?P<status>\w+)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_hwaddr = re.compile(r'''
|
||||||
|
hwaddr\s(?P<hw_address>[0-9A-Fa-f:?]+)
|
||||||
|
(?:\s+media:\s(?P<media>.+)\s
|
||||||
|
<(?P<media_flags>.+)>)?
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_media = re.compile(r'''
|
||||||
|
media:\s(?P<media>.+)
|
||||||
|
(?:\s+?<(?P<media_flags>.+)>)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_nd6_options = re.compile(r'''
|
||||||
|
nd6\soptions=(?P<nd6_options>\d+)
|
||||||
|
<(?P<nd6_flags>\S+)>
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_plugged = re.compile(r'''
|
||||||
|
plugged:\s(?P<plugged>.+)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_vendor_pn_sn_date = re.compile(r'''
|
||||||
|
vendor:\s(?P<vendor>.+)\s
|
||||||
|
PN:\s(?P<vendor_pn>.+)\s
|
||||||
|
SN:\s(?P<vendor_sn>.+)\s
|
||||||
|
DATE:\s(?P<vendor_date>.+)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_temp_volts = re.compile(r'''
|
||||||
|
module\stemperature:\s(?P<module_temperature>.+)\s
|
||||||
|
voltage:\s(?P<module_voltage>.+)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_tx_rx_power = re.compile(r'''
|
||||||
|
RX:\s+(?P<rx_power>.+)\s+
|
||||||
|
TX:\s(?P<tx_pwer>.+)
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
re_freebsd_options = re.compile(r'''
|
||||||
|
options=(?P<options>[0-9A-Fa-f]+)
|
||||||
|
<(?P<options_flags>.+)>
|
||||||
|
''', re.IGNORECASE | re.VERBOSE
|
||||||
|
)
|
||||||
|
|
||||||
available_interfaces = dict()
|
re_linux = [
|
||||||
|
re_linux_interface, re_linux_ipv4, re_linux_ipv6, re_linux_state, re_linux_rx, re_linux_tx,
|
||||||
|
re_linux_bytes, re_linux_tx_stats
|
||||||
|
]
|
||||||
|
re_openbsd = [
|
||||||
|
re_openbsd_interface, re_openbsd_ipv4, re_openbsd_ipv6, re_openbsd_details, re_openbsd_rx,
|
||||||
|
re_openbsd_rx_stats, re_openbsd_tx, re_openbsd_tx_stats
|
||||||
|
]
|
||||||
|
re_freebsd = [
|
||||||
|
re_freebsd_interface, re_freebsd_ipv4, re_freebsd_ipv4_v2, re_freebsd_ipv6,
|
||||||
|
re_freebsd_details, re_freebsd_status, re_freebsd_nd6_options, re_freebsd_plugged,
|
||||||
|
re_freebsd_vendor_pn_sn_date, re_freebsd_temp_volts, re_freebsd_hwaddr, re_freebsd_media,
|
||||||
|
re_freebsd_tx_rx_power, re_freebsd_options
|
||||||
|
]
|
||||||
|
|
||||||
for pattern in [re_linux_interface, re_openbsd_interface, re_freebsd_interface]:
|
interface_patterns = [re_linux_interface, re_openbsd_interface, re_freebsd_interface]
|
||||||
network_interfaces = re.finditer(pattern, source_data)
|
ipv4_patterns = [re_linux_ipv4, re_openbsd_ipv4, re_freebsd_ipv4, re_freebsd_ipv4_v2]
|
||||||
positions = []
|
ipv6_patterns = [re_linux_ipv6, re_openbsd_ipv6, re_freebsd_ipv6]
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
pos = next(network_interfaces)
|
|
||||||
positions.append(max(pos.start() - 1, 0))
|
|
||||||
except StopIteration:
|
|
||||||
break
|
|
||||||
if positions:
|
|
||||||
positions.append(len(source_data))
|
|
||||||
break
|
|
||||||
|
|
||||||
if not positions:
|
|
||||||
return available_interfaces
|
|
||||||
|
|
||||||
for l, r in zip(positions, positions[1:]):
|
|
||||||
chunk = source_data[l:r]
|
|
||||||
_interface = dict()
|
|
||||||
for pattern in re_linux + re_openbsd + re_freebsd:
|
|
||||||
match = re.search(pattern, chunk.replace('\t', '\n'))
|
|
||||||
if match:
|
|
||||||
details = match.groupdict()
|
|
||||||
for k, v in details.items():
|
|
||||||
if isinstance(v, str):
|
|
||||||
details[k] = v.strip()
|
|
||||||
_interface.update(details)
|
|
||||||
if _interface is not None:
|
|
||||||
available_interfaces[_interface['name']] = self.update_interface_details(_interface)
|
|
||||||
|
|
||||||
return available_interfaces
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def update_interface_details(interface):
|
|
||||||
for attr in _IfconfigParser.attributes:
|
|
||||||
if attr not in interface:
|
|
||||||
interface[attr] = None
|
|
||||||
return namedtuple('Interface', interface.keys())(**interface)
|
|
||||||
|
|
||||||
|
|
||||||
class InterfaceNotFound(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def _process(proc_data):
|
|
||||||
"""
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured data to conform to the schema.
|
|
||||||
"""
|
|
||||||
int_list = {
|
|
||||||
'flags', 'mtu', 'ipv6_mask', 'rx_packets', 'rx_bytes', 'rx_errors', 'rx_dropped',
|
|
||||||
'rx_overruns', 'rx_frame', 'tx_packets', 'tx_bytes', 'tx_errors', 'tx_dropped',
|
|
||||||
'tx_overruns', 'tx_carrier', 'tx_collisions', 'metric'
|
|
||||||
}
|
|
||||||
|
|
||||||
for entry in proc_data:
|
|
||||||
for key in entry:
|
|
||||||
if key in int_list:
|
|
||||||
entry[key] = jc.utils.convert_to_int(entry[key])
|
|
||||||
|
|
||||||
# convert OSX-style subnet mask to dotted quad
|
|
||||||
if 'ipv4_mask' in entry:
|
|
||||||
try:
|
|
||||||
if entry['ipv4_mask'].startswith('0x'):
|
|
||||||
new_mask = entry['ipv4_mask']
|
|
||||||
new_mask = new_mask.lstrip('0x')
|
|
||||||
new_mask = '.'.join(str(int(i, 16)) for i in [new_mask[i:i + 2] for i in range(0, len(new_mask), 2)])
|
|
||||||
entry['ipv4_mask'] = new_mask
|
|
||||||
except (ValueError, TypeError, AttributeError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
# convert state value to an array
|
|
||||||
if 'state' in entry:
|
|
||||||
try:
|
|
||||||
new_state = entry['state'].split(',')
|
|
||||||
entry['state'] = new_state
|
|
||||||
except (ValueError, TypeError, AttributeError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
return proc_data
|
|
||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
|
||||||
"""
|
|
||||||
Main text parsing function
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
|
||||||
quiet: (boolean) suppress warning messages if True
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
"""
|
|
||||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
|
||||||
jc.utils.input_type_check(data)
|
|
||||||
|
|
||||||
raw_output = []
|
|
||||||
|
|
||||||
if jc.utils.has_data(data):
|
if jc.utils.has_data(data):
|
||||||
|
for line in filter(None, data.splitlines()):
|
||||||
|
|
||||||
parsed = _IfconfigParser(console_output=data)
|
# Find new interface lines
|
||||||
interfaces = parsed.get_interfaces()
|
interface_match = _bundle_match(interface_patterns, line)
|
||||||
|
if interface_match:
|
||||||
|
if interface_item['name'] is not None:
|
||||||
|
if ipv4_info:
|
||||||
|
interface_item['ipv4'] = ipv4_info
|
||||||
|
if ipv6_info:
|
||||||
|
interface_item['ipv6'] = ipv6_info
|
||||||
|
raw_output.append(interface_item)
|
||||||
|
interface_item = interface_obj.copy()
|
||||||
|
ipv4_info = []
|
||||||
|
ipv6_info = []
|
||||||
|
|
||||||
# convert ifconfigparser output to a dictionary
|
interface_item.update(interface_match.groupdict())
|
||||||
for iface in interfaces:
|
continue
|
||||||
d = interfaces[iface]._asdict()
|
|
||||||
dct = dict(d)
|
|
||||||
raw_output.append(dct)
|
|
||||||
|
|
||||||
if raw:
|
### for backwards compatibility!
|
||||||
return raw_output
|
# add in old ipv4/ipv6 address fields in root of object.
|
||||||
else:
|
# this will only keep the last ip address in the interface output.
|
||||||
return _process(raw_output)
|
# old fieldnames: ipv4_addr, ipv4_mask, ipv4_bcast, ipv6_addr, ipv6_mask, ipv6_scope
|
||||||
|
ipv4_match_legacy = _bundle_match(ipv4_patterns, line)
|
||||||
|
if ipv4_match_legacy:
|
||||||
|
ipv4_dict = ipv4_match_legacy.groupdict()
|
||||||
|
# rename to legacy names
|
||||||
|
name_map = {
|
||||||
|
'address': 'ipv4_addr',
|
||||||
|
'mask': 'ipv4_mask',
|
||||||
|
'broadcast': 'ipv4_bcast'
|
||||||
|
}
|
||||||
|
for k, v in ipv4_dict.copy().items():
|
||||||
|
ipv4_dict[name_map[k]] = v
|
||||||
|
del ipv4_dict[k]
|
||||||
|
interface_item.update(ipv4_dict)
|
||||||
|
|
||||||
|
ipv6_match_legacy = _bundle_match(ipv6_patterns, line)
|
||||||
|
if ipv6_match_legacy:
|
||||||
|
ipv6_dict = ipv6_match_legacy.groupdict()
|
||||||
|
# rename to legacy names
|
||||||
|
name_map = {
|
||||||
|
'address': 'ipv6_addr',
|
||||||
|
'mask': 'ipv6_mask',
|
||||||
|
'broadcast': 'ipv6_bcast',
|
||||||
|
'scope': 'ipv6_scope',
|
||||||
|
'type': 'ipv6_type'
|
||||||
|
}
|
||||||
|
for k, v in ipv6_dict.copy().items():
|
||||||
|
ipv6_dict[name_map[k]] = v
|
||||||
|
del ipv6_dict[k]
|
||||||
|
interface_item.update(ipv6_dict)
|
||||||
|
### Backwards compatibility end
|
||||||
|
|
||||||
|
# ipv4 information lines
|
||||||
|
ipv4_match = _bundle_match(ipv4_patterns, line)
|
||||||
|
if ipv4_match:
|
||||||
|
ipv4_info.append(ipv4_match.groupdict())
|
||||||
|
continue
|
||||||
|
|
||||||
|
# ipv6 information lines
|
||||||
|
ipv6_match = _bundle_match(ipv6_patterns, line)
|
||||||
|
if ipv6_match:
|
||||||
|
ipv6_info.append(ipv6_match.groupdict())
|
||||||
|
continue
|
||||||
|
|
||||||
|
# All other lines
|
||||||
|
other_match = _bundle_match(re_linux + re_openbsd + re_freebsd, line)
|
||||||
|
if other_match:
|
||||||
|
interface_item.update(other_match.groupdict())
|
||||||
|
continue
|
||||||
|
|
||||||
|
if interface_item['name'] is not None:
|
||||||
|
if ipv4_info:
|
||||||
|
interface_item['ipv4'] = ipv4_info
|
||||||
|
if ipv6_info:
|
||||||
|
interface_item['ipv6'] = ipv6_info
|
||||||
|
raw_output.append(interface_item)
|
||||||
|
|
||||||
|
return raw_output if raw else _process(raw_output)
|
||||||
|
109
jc/parsers/os_prober.py
Normal file
109
jc/parsers/os_prober.py
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
"""jc - JSON Convert `os-prober` command output parser
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ os-prober | jc --os-prober
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ jc os-prober
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('os_prober', os_prober_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
'partition': string,
|
||||||
|
'name': string,
|
||||||
|
'short_name': string,
|
||||||
|
'type': string
|
||||||
|
}
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ os-prober | jc --os-prober -p
|
||||||
|
{
|
||||||
|
"partition": "/dev/sda1",
|
||||||
|
"name": "Windows 10",
|
||||||
|
"short_name": "Windows",
|
||||||
|
"type": "chain"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
from typing import Dict
|
||||||
|
from jc.jc_types import JSONDictType
|
||||||
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
|
class info():
|
||||||
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.0'
|
||||||
|
description = '`os-prober` command parser'
|
||||||
|
author = 'Kelly Brazil'
|
||||||
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
|
compatible = ['linux']
|
||||||
|
magic_commands = ['os-prober']
|
||||||
|
|
||||||
|
|
||||||
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
|
def _process(proc_data: JSONDictType) -> JSONDictType:
|
||||||
|
"""
|
||||||
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
proc_data: (List of Dictionaries) raw structured data to process
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary. Structured to conform to the schema.
|
||||||
|
"""
|
||||||
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
|
def parse(
|
||||||
|
data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False
|
||||||
|
) -> JSONDictType:
|
||||||
|
"""
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
"""
|
||||||
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
|
raw_output: Dict = {}
|
||||||
|
|
||||||
|
if jc.utils.has_data(data):
|
||||||
|
|
||||||
|
# /dev/sda1:Windows NT/2000/XP:WinNT:chain
|
||||||
|
# ^-------^ ^----------------^ ^---^ ^---^
|
||||||
|
# part. OS name for boot short May change: type of boot loader
|
||||||
|
# loader's pretty name required. Usually there is only
|
||||||
|
# output a 'linux' style bootloader or
|
||||||
|
# a chain one for other partitions
|
||||||
|
# with their own boot sectors.
|
||||||
|
|
||||||
|
partition, name, short_name, type_ = data.split(':')
|
||||||
|
raw_output = {
|
||||||
|
'partition': partition.strip(),
|
||||||
|
'name': name.strip(),
|
||||||
|
'short_name': short_name.strip(),
|
||||||
|
'type': type_.strip()
|
||||||
|
}
|
||||||
|
|
||||||
|
return raw_output if raw else _process(raw_output)
|
@ -80,7 +80,7 @@ Examples:
|
|||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ proc_modules | jc --proc_modules -p -r
|
$ cat /proc/modules | jc --proc-modules -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"module": "binfmt_misc",
|
"module": "binfmt_misc",
|
||||||
|
121
jc/parsers/semver.py
Normal file
121
jc/parsers/semver.py
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
"""jc - JSON Convert Semantic Version string parser
|
||||||
|
|
||||||
|
This parser conforms to the specification at https://semver.org/
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ echo 1.2.3-rc.1+44837 | jc --semver
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('semver', semver_string)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
Strings that do not strictly conform to the specification will return an
|
||||||
|
empty object.
|
||||||
|
|
||||||
|
{
|
||||||
|
"major": integer,
|
||||||
|
"minor": integer,
|
||||||
|
"patch": integer,
|
||||||
|
"prerelease": string/null,
|
||||||
|
"build": string/null
|
||||||
|
}
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ echo 1.2.3-rc.1+44837 | jc --semver -p
|
||||||
|
{
|
||||||
|
"major": 1,
|
||||||
|
"minor": 2,
|
||||||
|
"patch": 3,
|
||||||
|
"prerelease": "rc.1",
|
||||||
|
"build": "44837"
|
||||||
|
}
|
||||||
|
|
||||||
|
$ echo 1.2.3-rc.1+44837 | jc --semver -p -r
|
||||||
|
{
|
||||||
|
"major": "1",
|
||||||
|
"minor": "2",
|
||||||
|
"patch": "3",
|
||||||
|
"prerelease": "rc.1",
|
||||||
|
"build": "44837"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
import re
|
||||||
|
from typing import Set, Dict
|
||||||
|
from jc.jc_types import JSONDictType
|
||||||
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
|
class info():
|
||||||
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.0'
|
||||||
|
description = 'Semantic Version string parser'
|
||||||
|
author = 'Kelly Brazil'
|
||||||
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
|
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
|
||||||
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
|
def _process(proc_data: JSONDictType) -> JSONDictType:
|
||||||
|
"""
|
||||||
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
proc_data: (List of Dictionaries) raw structured data to process
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary. Structured to conform to the schema.
|
||||||
|
"""
|
||||||
|
int_list: Set[str] = {'major', 'minor', 'patch'}
|
||||||
|
|
||||||
|
for item in int_list:
|
||||||
|
if item in proc_data:
|
||||||
|
proc_data[item] = int(proc_data[item]) # type: ignore
|
||||||
|
|
||||||
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
|
def parse(
|
||||||
|
data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False
|
||||||
|
) -> JSONDictType:
|
||||||
|
"""
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
"""
|
||||||
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
|
raw_output: Dict = {}
|
||||||
|
semver_pattern = re.compile(r'''
|
||||||
|
^(?P<major>0|[1-9]\d*)\.
|
||||||
|
(?P<minor>0|[1-9]\d*)\.
|
||||||
|
(?P<patch>0|[1-9]\d*)
|
||||||
|
(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?
|
||||||
|
(?:\+(?P<build>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
|
||||||
|
''', re.VERBOSE)
|
||||||
|
|
||||||
|
if jc.utils.has_data(data):
|
||||||
|
semver_match = re.match(semver_pattern, data)
|
||||||
|
if semver_match:
|
||||||
|
raw_output = semver_match.groupdict()
|
||||||
|
|
||||||
|
return raw_output if raw else _process(raw_output)
|
660
jc/parsers/sshd_conf.py
Normal file
660
jc/parsers/sshd_conf.py
Normal file
@ -0,0 +1,660 @@
|
|||||||
|
"""jc - JSON Convert sshd configuration file and `sshd -T` command output parser
|
||||||
|
|
||||||
|
This parser will work with `sshd` configuration files or the output of
|
||||||
|
`sshd -T`. Any `Match` blocks in the `sshd` configuration file will be
|
||||||
|
ignored.
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ sshd -T | jc --sshd-conf
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ jc sshd -T
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ cat sshd_conf | jc --sshd-conf
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('sshd_conf', sshd_conf_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"acceptenv": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"addressfamily": string,
|
||||||
|
"allowagentforwarding": string,
|
||||||
|
"allowstreamlocalforwarding": string,
|
||||||
|
"allowtcpforwarding": string,
|
||||||
|
"authenticationmethods": string,
|
||||||
|
"authorizedkeyscommand": string,
|
||||||
|
"authorizedkeyscommanduser": string,
|
||||||
|
"authorizedkeysfile": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"authorizedprincipalscommand": string,
|
||||||
|
"authorizedprincipalscommanduser": string,
|
||||||
|
"authorizedprincipalsfile": string,
|
||||||
|
"banner": string,
|
||||||
|
"casignaturealgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"chrootdirectory": string,
|
||||||
|
"ciphers": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"ciphers_strategy": string,
|
||||||
|
"clientalivecountmax": integer,
|
||||||
|
"clientaliveinterval": integer,
|
||||||
|
"compression": string,
|
||||||
|
"disableforwarding": string,
|
||||||
|
"exposeauthinfo": string,
|
||||||
|
"fingerprinthash": string,
|
||||||
|
"forcecommand": string,
|
||||||
|
"gatewayports": string,
|
||||||
|
"gssapiauthentication": string,
|
||||||
|
"gssapicleanupcredentials": string,
|
||||||
|
"gssapikexalgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"gssapikeyexchange": string,
|
||||||
|
"gssapistorecredentialsonrekey": string,
|
||||||
|
"gssapistrictacceptorcheck": string,
|
||||||
|
"hostbasedacceptedalgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"hostbasedauthentication": string,
|
||||||
|
"hostbasedusesnamefrompacketonly": string,
|
||||||
|
"hostkeyagent": string,
|
||||||
|
"hostkeyalgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"hostkey": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"ignorerhosts": string,
|
||||||
|
"ignoreuserknownhosts": string,
|
||||||
|
"include": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"ipqos": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"kbdinteractiveauthentication": string,
|
||||||
|
"kerberosauthentication": string,
|
||||||
|
"kerberosorlocalpasswd": string,
|
||||||
|
"kerberosticketcleanup": sttring,
|
||||||
|
"kexalgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"listenaddress": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"logingracetime": integer,
|
||||||
|
"loglevel": string,
|
||||||
|
"macs": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"macs_strategy": string,
|
||||||
|
"maxauthtries": integer,
|
||||||
|
"maxsessions": integer,
|
||||||
|
"maxstartups": integer,
|
||||||
|
"maxstartups_rate": integer,
|
||||||
|
"maxstartups_full": integer,
|
||||||
|
"modulifile": string,
|
||||||
|
"passwordauthentication": string,
|
||||||
|
"permitemptypasswords": string,
|
||||||
|
"permitlisten": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"permitopen": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"permitrootlogin": string,
|
||||||
|
"permittty": string,
|
||||||
|
"permittunnel": string,
|
||||||
|
"permituserenvironment": string,
|
||||||
|
"permituserrc": string,
|
||||||
|
"persourcemaxstartups": string,
|
||||||
|
"persourcenetblocksize": string,
|
||||||
|
"pidfile": string,
|
||||||
|
"port": [
|
||||||
|
integer
|
||||||
|
],
|
||||||
|
"printlastlog": string,
|
||||||
|
"printmotd": string,
|
||||||
|
"pubkeyacceptedalgorithms": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"pubkeyauthentication": string,
|
||||||
|
"pubkeyauthoptions": string,
|
||||||
|
"rekeylimit": integer,
|
||||||
|
"rekeylimit_time": integer,
|
||||||
|
"revokedkeys": string,
|
||||||
|
"securitykeyprovider": string,
|
||||||
|
"streamlocalbindmask": string,
|
||||||
|
"streamlocalbindunlink": string,
|
||||||
|
"strictmodes": string,
|
||||||
|
"subsystem": string,
|
||||||
|
"subsystem_command": string
|
||||||
|
"syslogfacility": string,
|
||||||
|
"tcpkeepalive": string,
|
||||||
|
"trustedusercakeys": string,
|
||||||
|
"usedns": string,
|
||||||
|
"usepam": string,
|
||||||
|
"versionaddendum": string,
|
||||||
|
"x11displayoffset": integer,
|
||||||
|
"x11forwarding": string,
|
||||||
|
"x11uselocalhost": string,
|
||||||
|
"xauthlocation": string
|
||||||
|
}
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ sshd -T | jc --sshd_conf -p
|
||||||
|
{
|
||||||
|
"acceptenv": [
|
||||||
|
"LANG",
|
||||||
|
"LC_*"
|
||||||
|
],
|
||||||
|
"addressfamily": "any",
|
||||||
|
"allowagentforwarding": "yes",
|
||||||
|
"allowstreamlocalforwarding": "yes",
|
||||||
|
"allowtcpforwarding": "yes",
|
||||||
|
"authenticationmethods": "any",
|
||||||
|
"authorizedkeyscommand": "none",
|
||||||
|
"authorizedkeyscommanduser": "none",
|
||||||
|
"authorizedkeysfile": [
|
||||||
|
".ssh/authorized_keys",
|
||||||
|
".ssh/authorized_keys2"
|
||||||
|
],
|
||||||
|
"authorizedprincipalscommand": "none",
|
||||||
|
"authorizedprincipalscommanduser": "none",
|
||||||
|
"authorizedprincipalsfile": "none",
|
||||||
|
"banner": "none",
|
||||||
|
"casignaturealgorithms": [
|
||||||
|
"ssh-ed25519",
|
||||||
|
"ecdsa-sha2-nistp256",
|
||||||
|
"ecdsa-sha2-nistp384",
|
||||||
|
"ecdsa-sha2-nistp521",
|
||||||
|
"sk-ssh-ed25519@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256@openssh.com",
|
||||||
|
"rsa-sha2-512",
|
||||||
|
"rsa-sha2-256"
|
||||||
|
],
|
||||||
|
"chrootdirectory": "none",
|
||||||
|
"ciphers": [
|
||||||
|
"chacha20-poly1305@openssh.com",
|
||||||
|
"aes128-ctr",
|
||||||
|
"aes192-ctr",
|
||||||
|
"aes256-ctr",
|
||||||
|
"aes128-gcm@openssh.com",
|
||||||
|
"aes256-gcm@openssh.com"
|
||||||
|
],
|
||||||
|
"ciphers_strategy": "+",
|
||||||
|
"clientalivecountmax": 3,
|
||||||
|
"clientaliveinterval": 0,
|
||||||
|
"compression": "yes",
|
||||||
|
"disableforwarding": "no",
|
||||||
|
"exposeauthinfo": "no",
|
||||||
|
"fingerprinthash": "SHA256",
|
||||||
|
"forcecommand": "none",
|
||||||
|
"gatewayports": "no",
|
||||||
|
"gssapiauthentication": "no",
|
||||||
|
"gssapicleanupcredentials": "yes",
|
||||||
|
"gssapikexalgorithms": [
|
||||||
|
"gss-group14-sha256-",
|
||||||
|
"gss-group16-sha512-",
|
||||||
|
"gss-nistp256-sha256-",
|
||||||
|
"gss-curve25519-sha256-",
|
||||||
|
"gss-group14-sha1-",
|
||||||
|
"gss-gex-sha1-"
|
||||||
|
],
|
||||||
|
"gssapikeyexchange": "no",
|
||||||
|
"gssapistorecredentialsonrekey": "no",
|
||||||
|
"gssapistrictacceptorcheck": "yes",
|
||||||
|
"hostbasedacceptedalgorithms": [
|
||||||
|
"ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp384-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp521-cert-v01@openssh.com",
|
||||||
|
"sk-ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-512-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-256-cert-v01@openssh.com",
|
||||||
|
"ssh-ed25519",
|
||||||
|
"ecdsa-sha2-nistp256",
|
||||||
|
"ecdsa-sha2-nistp384",
|
||||||
|
"ecdsa-sha2-nistp521",
|
||||||
|
"sk-ssh-ed25519@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256@openssh.com",
|
||||||
|
"rsa-sha2-512",
|
||||||
|
"rsa-sha2-256"
|
||||||
|
],
|
||||||
|
"hostbasedauthentication": "no",
|
||||||
|
"hostbasedusesnamefrompacketonly": "no",
|
||||||
|
"hostkeyagent": "none",
|
||||||
|
"hostkeyalgorithms": [
|
||||||
|
"ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp384-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp521-cert-v01@openssh.com",
|
||||||
|
"sk-ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-512-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-256-cert-v01@openssh.com",
|
||||||
|
"ssh-ed25519",
|
||||||
|
"ecdsa-sha2-nistp256",
|
||||||
|
"ecdsa-sha2-nistp384",
|
||||||
|
"ecdsa-sha2-nistp521",
|
||||||
|
"sk-ssh-ed25519@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256@openssh.com",
|
||||||
|
"rsa-sha2-512",
|
||||||
|
"rsa-sha2-256"
|
||||||
|
],
|
||||||
|
"hostkey": [
|
||||||
|
"/etc/ssh/ssh_host_ecdsa_key",
|
||||||
|
"/etc/ssh/ssh_host_ed25519_key",
|
||||||
|
"/etc/ssh/ssh_host_rsa_key"
|
||||||
|
],
|
||||||
|
"ignorerhosts": "yes",
|
||||||
|
"ignoreuserknownhosts": "no",
|
||||||
|
"ipqos": [
|
||||||
|
"lowdelay",
|
||||||
|
"throughput"
|
||||||
|
],
|
||||||
|
"kbdinteractiveauthentication": "no",
|
||||||
|
"kerberosauthentication": "no",
|
||||||
|
"kerberosorlocalpasswd": "yes",
|
||||||
|
"kerberosticketcleanup": "yes",
|
||||||
|
"kexalgorithms": [
|
||||||
|
"sntrup761x25519-sha512@openssh.com",
|
||||||
|
"curve25519-sha256",
|
||||||
|
"curve25519-sha256@libssh.org",
|
||||||
|
"ecdh-sha2-nistp256",
|
||||||
|
"ecdh-sha2-nistp384",
|
||||||
|
"ecdh-sha2-nistp521",
|
||||||
|
"diffie-hellman-group-exchange-sha256",
|
||||||
|
"diffie-hellman-group16-sha512",
|
||||||
|
"diffie-hellman-group18-sha512",
|
||||||
|
"diffie-hellman-group14-sha256"
|
||||||
|
],
|
||||||
|
"listenaddress": [
|
||||||
|
"0.0.0.0:22",
|
||||||
|
"[::]:22"
|
||||||
|
],
|
||||||
|
"logingracetime": 120,
|
||||||
|
"loglevel": "INFO",
|
||||||
|
"macs": [
|
||||||
|
"umac-64-etm@openssh.com",
|
||||||
|
"umac-128-etm@openssh.com",
|
||||||
|
"hmac-sha2-256-etm@openssh.com",
|
||||||
|
"hmac-sha2-512-etm@openssh.com",
|
||||||
|
"hmac-sha1-etm@openssh.com",
|
||||||
|
"umac-64@openssh.com",
|
||||||
|
"umac-128@openssh.com",
|
||||||
|
"hmac-sha2-256",
|
||||||
|
"hmac-sha2-512",
|
||||||
|
"hmac-sha1"
|
||||||
|
],
|
||||||
|
"macs_strategy": "^",
|
||||||
|
"maxauthtries": 6,
|
||||||
|
"maxsessions": 10,
|
||||||
|
"maxstartups": 10,
|
||||||
|
"modulifile": "/etc/ssh/moduli",
|
||||||
|
"passwordauthentication": "yes",
|
||||||
|
"permitemptypasswords": "no",
|
||||||
|
"permitlisten": [
|
||||||
|
"any"
|
||||||
|
],
|
||||||
|
"permitopen": [
|
||||||
|
"any"
|
||||||
|
],
|
||||||
|
"permitrootlogin": "without-password",
|
||||||
|
"permittty": "yes",
|
||||||
|
"permittunnel": "no",
|
||||||
|
"permituserenvironment": "no",
|
||||||
|
"permituserrc": "yes",
|
||||||
|
"persourcemaxstartups": "none",
|
||||||
|
"persourcenetblocksize": "32:128",
|
||||||
|
"pidfile": "/run/sshd.pid",
|
||||||
|
"port": [
|
||||||
|
22
|
||||||
|
],
|
||||||
|
"printlastlog": "yes",
|
||||||
|
"printmotd": "no",
|
||||||
|
"pubkeyacceptedalgorithms": [
|
||||||
|
"ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp384-cert-v01@openssh.com",
|
||||||
|
"ecdsa-sha2-nistp521-cert-v01@openssh.com",
|
||||||
|
"sk-ssh-ed25519-cert-v01@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-512-cert-v01@openssh.com",
|
||||||
|
"rsa-sha2-256-cert-v01@openssh.com",
|
||||||
|
"ssh-ed25519",
|
||||||
|
"ecdsa-sha2-nistp256",
|
||||||
|
"ecdsa-sha2-nistp384",
|
||||||
|
"ecdsa-sha2-nistp521",
|
||||||
|
"sk-ssh-ed25519@openssh.com",
|
||||||
|
"sk-ecdsa-sha2-nistp256@openssh.com",
|
||||||
|
"rsa-sha2-512",
|
||||||
|
"rsa-sha2-256"
|
||||||
|
],
|
||||||
|
"pubkeyauthentication": "yes",
|
||||||
|
"pubkeyauthoptions": "none",
|
||||||
|
"rekeylimit": 0,
|
||||||
|
"revokedkeys": "none",
|
||||||
|
"securitykeyprovider": "internal",
|
||||||
|
"streamlocalbindmask": "0177",
|
||||||
|
"streamlocalbindunlink": "no",
|
||||||
|
"strictmodes": "yes",
|
||||||
|
"subsystem": "sftp",
|
||||||
|
"syslogfacility": "AUTH",
|
||||||
|
"tcpkeepalive": "yes",
|
||||||
|
"trustedusercakeys": "none",
|
||||||
|
"usedns": "no",
|
||||||
|
"usepam": "yes",
|
||||||
|
"versionaddendum": "none",
|
||||||
|
"x11displayoffset": 10,
|
||||||
|
"x11forwarding": "yes",
|
||||||
|
"x11uselocalhost": "yes",
|
||||||
|
"xauthlocation": "/usr/bin/xauth",
|
||||||
|
"maxstartups_rate": 30,
|
||||||
|
"maxstartups_full": 100,
|
||||||
|
"rekeylimit_time": 0,
|
||||||
|
"subsystem_command": "/usr/lib/openssh/sftp-server"
|
||||||
|
}
|
||||||
|
|
||||||
|
$ sshd -T | jc --sshd_conf -p -r
|
||||||
|
{
|
||||||
|
"acceptenv": [
|
||||||
|
"LANG",
|
||||||
|
"LC_*"
|
||||||
|
],
|
||||||
|
"addressfamily": "any",
|
||||||
|
"allowagentforwarding": "yes",
|
||||||
|
"allowstreamlocalforwarding": "yes",
|
||||||
|
"allowtcpforwarding": "yes",
|
||||||
|
"authenticationmethods": "any",
|
||||||
|
"authorizedkeyscommand": "none",
|
||||||
|
"authorizedkeyscommanduser": "none",
|
||||||
|
"authorizedkeysfile": ".ssh/authorized_keys .ssh/authorized_keys2",
|
||||||
|
"authorizedprincipalscommand": "none",
|
||||||
|
"authorizedprincipalscommanduser": "none",
|
||||||
|
"authorizedprincipalsfile": "none",
|
||||||
|
"banner": "none",
|
||||||
|
"casignaturealgorithms": "ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-s...",
|
||||||
|
"chrootdirectory": "none",
|
||||||
|
"ciphers": "chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,...",
|
||||||
|
"ciphers_strategy": "+",
|
||||||
|
"clientalivecountmax": "3",
|
||||||
|
"clientaliveinterval": "0",
|
||||||
|
"compression": "yes",
|
||||||
|
"disableforwarding": "no",
|
||||||
|
"exposeauthinfo": "no",
|
||||||
|
"fingerprinthash": "SHA256",
|
||||||
|
"forcecommand": "none",
|
||||||
|
"gatewayports": "no",
|
||||||
|
"gssapiauthentication": "no",
|
||||||
|
"gssapicleanupcredentials": "yes",
|
||||||
|
"gssapikexalgorithms": "gss-group14-sha256-,gss-group16-sha512-,...",
|
||||||
|
"gssapikeyexchange": "no",
|
||||||
|
"gssapistorecredentialsonrekey": "no",
|
||||||
|
"gssapistrictacceptorcheck": "yes",
|
||||||
|
"hostbasedacceptedalgorithms": "ssh-ed25519-cert-v01@openssh.co...",
|
||||||
|
"hostbasedauthentication": "no",
|
||||||
|
"hostbasedusesnamefrompacketonly": "no",
|
||||||
|
"hostkeyagent": "none",
|
||||||
|
"hostkeyalgorithms": "ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2...",
|
||||||
|
"hostkey": [
|
||||||
|
"/etc/ssh/ssh_host_ecdsa_key",
|
||||||
|
"/etc/ssh/ssh_host_ed25519_key",
|
||||||
|
"/etc/ssh/ssh_host_rsa_key"
|
||||||
|
],
|
||||||
|
"ignorerhosts": "yes",
|
||||||
|
"ignoreuserknownhosts": "no",
|
||||||
|
"ipqos": "lowdelay throughput",
|
||||||
|
"kbdinteractiveauthentication": "no",
|
||||||
|
"kerberosauthentication": "no",
|
||||||
|
"kerberosorlocalpasswd": "yes",
|
||||||
|
"kerberosticketcleanup": "yes",
|
||||||
|
"kexalgorithms": "sntrup761x25519-sha512@openssh.com,curve25519...",
|
||||||
|
"listenaddress": [
|
||||||
|
"0.0.0.0:22",
|
||||||
|
"[::]:22"
|
||||||
|
],
|
||||||
|
"logingracetime": "120",
|
||||||
|
"loglevel": "INFO",
|
||||||
|
"macs": "umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac...",
|
||||||
|
"macs_strategy": "^",
|
||||||
|
"maxauthtries": "6",
|
||||||
|
"maxsessions": "10",
|
||||||
|
"maxstartups": "10:30:100",
|
||||||
|
"modulifile": "/etc/ssh/moduli",
|
||||||
|
"passwordauthentication": "yes",
|
||||||
|
"permitemptypasswords": "no",
|
||||||
|
"permitlisten": "any",
|
||||||
|
"permitopen": "any",
|
||||||
|
"permitrootlogin": "without-password",
|
||||||
|
"permittty": "yes",
|
||||||
|
"permittunnel": "no",
|
||||||
|
"permituserenvironment": "no",
|
||||||
|
"permituserrc": "yes",
|
||||||
|
"persourcemaxstartups": "none",
|
||||||
|
"persourcenetblocksize": "32:128",
|
||||||
|
"pidfile": "/run/sshd.pid",
|
||||||
|
"port": [
|
||||||
|
"22"
|
||||||
|
],
|
||||||
|
"printlastlog": "yes",
|
||||||
|
"printmotd": "no",
|
||||||
|
"pubkeyacceptedalgorithms": "ssh-ed25519-cert-v01@openssh.com,...",
|
||||||
|
"pubkeyauthentication": "yes",
|
||||||
|
"pubkeyauthoptions": "none",
|
||||||
|
"rekeylimit": "0 0",
|
||||||
|
"revokedkeys": "none",
|
||||||
|
"securitykeyprovider": "internal",
|
||||||
|
"streamlocalbindmask": "0177",
|
||||||
|
"streamlocalbindunlink": "no",
|
||||||
|
"strictmodes": "yes",
|
||||||
|
"subsystem": "sftp /usr/lib/openssh/sftp-server",
|
||||||
|
"syslogfacility": "AUTH",
|
||||||
|
"tcpkeepalive": "yes",
|
||||||
|
"trustedusercakeys": "none",
|
||||||
|
"usedns": "no",
|
||||||
|
"usepam": "yes",
|
||||||
|
"versionaddendum": "none",
|
||||||
|
"x11displayoffset": "10",
|
||||||
|
"x11forwarding": "yes",
|
||||||
|
"x11uselocalhost": "yes",
|
||||||
|
"xauthlocation": "/usr/bin/xauth"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
from typing import Set, List, Dict
|
||||||
|
from jc.jc_types import JSONDictType
|
||||||
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
|
class info():
|
||||||
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.0'
|
||||||
|
description = 'sshd config file and `sshd -T` command parser'
|
||||||
|
author = 'Kelly Brazil'
|
||||||
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
|
compatible = ['linux', 'darwin', 'freebsd']
|
||||||
|
magic_commands = ['sshd -T']
|
||||||
|
|
||||||
|
|
||||||
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
|
def _process(proc_data: JSONDictType) -> JSONDictType:
|
||||||
|
"""
|
||||||
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
proc_data: (Dictionary) raw structured data to process
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary. Structured to conform to the schema.
|
||||||
|
"""
|
||||||
|
split_fields_space: Set[str] = {
|
||||||
|
'authorizedkeysfile', 'include', 'ipqos', 'permitlisten', 'permitopen'
|
||||||
|
}
|
||||||
|
|
||||||
|
split_fields_comma: Set[str] = {
|
||||||
|
'casignaturealgorithms', 'ciphers', 'gssapikexalgorithms', 'hostbasedacceptedalgorithms',
|
||||||
|
'hostbasedacceptedkeytypes', 'hostkeyalgorithms', 'kexalgorithms', 'macs',
|
||||||
|
'pubkeyacceptedalgorithms', 'pubkeyacceptedkeytypes'
|
||||||
|
}
|
||||||
|
|
||||||
|
int_list: Set[str] = {'clientalivecountmax', 'clientaliveinterval', 'logingracetime',
|
||||||
|
'maxauthtries', 'maxsessions', 'maxstartups', 'maxstartups_rate', 'maxstartups_full',
|
||||||
|
'rekeylimit', 'rekeylimit_time', 'x11displayoffset', 'x11maxdisplays'
|
||||||
|
}
|
||||||
|
|
||||||
|
dict_copy = proc_data.copy()
|
||||||
|
for key, val in dict_copy.items():
|
||||||
|
# this is a list value
|
||||||
|
if key == 'acceptenv':
|
||||||
|
new_list: List[str] = []
|
||||||
|
for item in val: # type: ignore
|
||||||
|
new_list.extend(item.split())
|
||||||
|
proc_data[key] = new_list
|
||||||
|
continue
|
||||||
|
|
||||||
|
# this is a list value
|
||||||
|
if key == 'include':
|
||||||
|
new_list = []
|
||||||
|
for item in val: # type: ignore
|
||||||
|
new_list.extend(item.split())
|
||||||
|
proc_data[key] = new_list
|
||||||
|
continue
|
||||||
|
|
||||||
|
if key == 'maxstartups':
|
||||||
|
maxstart_split = val.split(':', maxsplit=2) # type: ignore
|
||||||
|
proc_data[key] = maxstart_split[0]
|
||||||
|
if len(maxstart_split) > 1:
|
||||||
|
proc_data[key + '_rate'] = maxstart_split[1]
|
||||||
|
if len(maxstart_split) > 2:
|
||||||
|
proc_data[key + '_full'] = maxstart_split[2]
|
||||||
|
continue
|
||||||
|
|
||||||
|
if key == 'port':
|
||||||
|
port_list: List[int] = []
|
||||||
|
for item in val: # type: ignore
|
||||||
|
port_list.append(int(item))
|
||||||
|
proc_data[key] = port_list
|
||||||
|
continue
|
||||||
|
|
||||||
|
if key == 'rekeylimit':
|
||||||
|
rekey_split = val.split(maxsplit=1) # type: ignore
|
||||||
|
proc_data[key] = rekey_split[0]
|
||||||
|
if len(rekey_split) > 1:
|
||||||
|
proc_data[key + '_time'] = rekey_split[1]
|
||||||
|
continue
|
||||||
|
|
||||||
|
if key == 'subsystem':
|
||||||
|
sub_split = val.split(maxsplit=1) # type: ignore
|
||||||
|
proc_data[key] = sub_split[0]
|
||||||
|
if len(sub_split) > 1:
|
||||||
|
proc_data[key + '_command'] = sub_split[1]
|
||||||
|
continue
|
||||||
|
|
||||||
|
if key in split_fields_space:
|
||||||
|
proc_data[key] = val.split() # type: ignore
|
||||||
|
continue
|
||||||
|
|
||||||
|
if key in split_fields_comma:
|
||||||
|
proc_data[key] = val.split(',') # type: ignore
|
||||||
|
continue
|
||||||
|
|
||||||
|
for key, val in proc_data.items():
|
||||||
|
if key in int_list:
|
||||||
|
proc_data[key] = jc.utils.convert_to_int(val)
|
||||||
|
|
||||||
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
|
def parse(
|
||||||
|
data: str,
|
||||||
|
raw: bool = False,
|
||||||
|
quiet: bool = False
|
||||||
|
) -> JSONDictType:
|
||||||
|
"""
|
||||||
|
Main text parsing function
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
data: (string) text data to parse
|
||||||
|
raw: (boolean) unprocessed output if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
"""
|
||||||
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
|
raw_output: Dict = {}
|
||||||
|
|
||||||
|
multi_fields: Set[str] = {'acceptenv', 'hostkey', 'include', 'listenaddress', 'port'}
|
||||||
|
|
||||||
|
modified_fields: Set[str] = {
|
||||||
|
'casignaturealgorithms', 'ciphers', 'hostbasedacceptedalgorithms',
|
||||||
|
'kexalgorithms', 'macs', 'pubkeyacceptedalgorithms'
|
||||||
|
}
|
||||||
|
|
||||||
|
modifiers: Set[str] = {'+', '-', '^'}
|
||||||
|
|
||||||
|
match_block_found = False
|
||||||
|
|
||||||
|
if jc.utils.has_data(data):
|
||||||
|
|
||||||
|
for line in filter(None, data.splitlines()):
|
||||||
|
# support configuration file by skipping commented lines
|
||||||
|
if line.strip().startswith('#'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
# support configuration file by ignoring all lines between
|
||||||
|
# Match xxx and Match any
|
||||||
|
if line.strip().startswith('Match all'):
|
||||||
|
match_block_found = False
|
||||||
|
continue
|
||||||
|
|
||||||
|
if line.strip().startswith('Match'):
|
||||||
|
match_block_found = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
if match_block_found:
|
||||||
|
continue
|
||||||
|
|
||||||
|
key, val = line.split(maxsplit=1)
|
||||||
|
|
||||||
|
# support configuration file by converting to lower case
|
||||||
|
key = key.lower()
|
||||||
|
|
||||||
|
if key in multi_fields:
|
||||||
|
if key not in raw_output:
|
||||||
|
raw_output[key] = []
|
||||||
|
raw_output[key].append(val)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if key in modified_fields and val[0] in modifiers:
|
||||||
|
raw_output[key] = val[1:]
|
||||||
|
raw_output[key + '_strategy'] = val[0]
|
||||||
|
continue
|
||||||
|
|
||||||
|
raw_output[key] = val
|
||||||
|
continue
|
||||||
|
|
||||||
|
return raw_output if raw else _process(raw_output)
|
@ -1,5 +1,10 @@
|
|||||||
"""jc - JSON Convert `XML` file parser
|
"""jc - JSON Convert `XML` file parser
|
||||||
|
|
||||||
|
This parser adds a `@` prefix to attributes by default. This can be changed
|
||||||
|
to a `_` prefix by using the `-r` (cli) or `raw=True` (module) option.
|
||||||
|
|
||||||
|
Text values for nodes will have the key-name of `#text`.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat foo.xml | jc --xml
|
$ cat foo.xml | jc --xml
|
||||||
@ -68,10 +73,15 @@ Examples:
|
|||||||
import jc.utils
|
import jc.utils
|
||||||
from jc.exceptions import LibraryNotInstalled
|
from jc.exceptions import LibraryNotInstalled
|
||||||
|
|
||||||
|
try:
|
||||||
|
import xmltodict
|
||||||
|
except Exception:
|
||||||
|
raise LibraryNotInstalled('The xmltodict library is not installed.')
|
||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.6'
|
version = '1.7'
|
||||||
description = 'XML file parser'
|
description = 'XML file parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -82,7 +92,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def _process(proc_data):
|
def _process(proc_data, has_data=False):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -94,9 +104,13 @@ def _process(proc_data):
|
|||||||
|
|
||||||
Dictionary representing an XML document.
|
Dictionary representing an XML document.
|
||||||
"""
|
"""
|
||||||
|
raw_output = []
|
||||||
|
|
||||||
# No further processing
|
if has_data:
|
||||||
return proc_data
|
# standard output with @ prefix for attributes
|
||||||
|
raw_output = xmltodict.parse(proc_data, dict_constructor=dict)
|
||||||
|
|
||||||
|
return raw_output
|
||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
@ -113,22 +127,20 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
# check if xml library is installed and fail gracefully if it is not
|
|
||||||
try:
|
|
||||||
import xmltodict
|
|
||||||
except Exception:
|
|
||||||
raise LibraryNotInstalled('The xmltodict library is not installed.')
|
|
||||||
|
|
||||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
jc.utils.input_type_check(data)
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
has_data = False
|
||||||
|
|
||||||
if jc.utils.has_data(data):
|
if jc.utils.has_data(data):
|
||||||
|
has_data = True
|
||||||
raw_output = xmltodict.parse(data)
|
|
||||||
|
|
||||||
if raw:
|
if raw:
|
||||||
|
if has_data:
|
||||||
|
# modified output with _ prefix for attributes
|
||||||
|
raw_output = xmltodict.parse(data, dict_constructor=dict, attr_prefix='_')
|
||||||
|
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
|
||||||
return _process(raw_output)
|
return _process(data, has_data)
|
||||||
|
@ -273,7 +273,7 @@ def convert_to_bool(value: object) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def input_type_check(data: str) -> None:
|
def input_type_check(data: object) -> None:
|
||||||
"""Ensure input data is a string. Raises `TypeError` if not."""
|
"""Ensure input data is a string. Raises `TypeError` if not."""
|
||||||
if not isinstance(data, str):
|
if not isinstance(data, str):
|
||||||
raise TypeError("Input data must be a 'str' object.")
|
raise TypeError("Input data must be a 'str' object.")
|
||||||
|
27
man/jc.1
27
man/jc.1
@ -1,4 +1,4 @@
|
|||||||
.TH jc 1 2022-10-24 1.22.1 "JSON Convert"
|
.TH jc 1 2022-11-08 1.22.2 "JSON Convert"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types, and strings
|
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types, and strings
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -160,6 +160,11 @@ Email Address string parser
|
|||||||
\fB--file\fP
|
\fB--file\fP
|
||||||
`file` command parser
|
`file` command parser
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
\fB--findmnt\fP
|
||||||
|
`findmnt` command parser
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
\fB--finger\fP
|
\fB--finger\fP
|
||||||
@ -185,6 +190,11 @@ Email Address string parser
|
|||||||
\fB--git-log-s\fP
|
\fB--git-log-s\fP
|
||||||
`git log` command streaming parser
|
`git log` command streaming parser
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
\fB--git-ls-remote\fP
|
||||||
|
`git ls-remote` command parser
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
\fB--gpg\fP
|
\fB--gpg\fP
|
||||||
@ -370,6 +380,11 @@ M3U and M3U8 file parser
|
|||||||
\fB--ntpq\fP
|
\fB--ntpq\fP
|
||||||
`ntpq -p` command parser
|
`ntpq -p` command parser
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
\fB--os-prober\fP
|
||||||
|
`os-prober` command parser
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
\fB--passwd\fP
|
\fB--passwd\fP
|
||||||
@ -695,6 +710,11 @@ PLIST file parser
|
|||||||
\fB--rsync-s\fP
|
\fB--rsync-s\fP
|
||||||
`rsync` command streaming parser
|
`rsync` command streaming parser
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
\fB--semver\fP
|
||||||
|
Semantic Version string parser
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
\fB--sfdisk\fP
|
\fB--sfdisk\fP
|
||||||
@ -710,6 +730,11 @@ PLIST file parser
|
|||||||
\fB--ss\fP
|
\fB--ss\fP
|
||||||
`ss` command parser
|
`ss` command parser
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
\fB--sshd-conf\fP
|
||||||
|
sshd config file and `sshd -T` command parser
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
\fB--stat\fP
|
\fB--stat\fP
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='jc',
|
name='jc',
|
||||||
version='1.22.1',
|
version='1.22.2',
|
||||||
author='Kelly Brazil',
|
author='Kelly Brazil',
|
||||||
author_email='kellyjonbrazil@gmail.com',
|
author_email='kellyjonbrazil@gmail.com',
|
||||||
description='Converts the output of popular command-line tools and file-types to JSON.',
|
description='Converts the output of popular command-line tools and file-types to JSON.',
|
||||||
|
1
tests/fixtures/centos-7.7/findmnt-a.json
vendored
Normal file
1
tests/fixtures/centos-7.7/findmnt-a.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"target":"/","source":"/dev/mapper/centos-root","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]},{"target":"/sys","source":"sysfs","fstype":"sysfs","options":["rw","nosuid","nodev","noexec","relatime","seclabel"]},{"target":"/sys/kernel/security","source":"securityfs","fstype":"securityfs","options":["rw","nosuid","nodev","noexec","relatime"]},{"target":"/sys/fs/cgroup","source":"tmpfs","fstype":"tmpfs","options":["ro","nosuid","nodev","noexec","seclabel"],"kv_options":{"mode":"755"}},{"target":"/sys/fs/cgroup/systemd","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","xattr"],"kv_options":{"release_agent":"/usr/lib/systemd/systemd-cgroups-agent","name":"systemd"}},{"target":"/sys/fs/cgroup/net_cls,net_prio","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","net_prio","net_cls"]},{"target":"/sys/fs/cgroup/freezer","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","freezer"]},{"target":"/sys/fs/cgroup/devices","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","devices"]},{"target":"/sys/fs/cgroup/cpuset","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","cpuset"]},{"target":"/sys/fs/cgroup/cpu,cpuacct","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","cpuacct","cpu"]},{"target":"/sys/fs/cgroup/pids","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","pids"]},{"target":"/sys/fs/cgroup/memory","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","memory"]},{"target":"/sys/fs/cgroup/perf_event","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","perf_event"]},{"target":"/sys/fs/cgroup/hugetlb","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","hugetlb"]},{"target":"/sys/fs/cgroup/blkio","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","blkio"]},{"target":"/sys/fs/pstore","source":"pstore","fstype":"pstore","options":["rw","nosuid","nodev","noexec","relatime"]},{"target":"/sys/kernel/config","source":"configfs","fstype":"configfs","options":["rw","relatime"]},{"target":"/sys/fs/selinux","source":"selinuxfs","fstype":"selinuxfs","options":["rw","relatime"]},{"target":"/sys/kernel/debug","source":"debugfs","fstype":"debugfs","options":["rw","relatime"]},{"target":"/proc","source":"proc","fstype":"proc","options":["rw","nosuid","nodev","noexec","relatime"]},{"target":"/proc/sys/fs/binfmt_misc","source":"systemd-1","fstype":"autofs","options":["rw","relatime","direct"],"kv_options":{"fd":"22","pgrp":"1","timeout":"0","minproto":"5","maxproto":"5","pipe_ino":"13827"}},{"target":"/dev","source":"devtmpfs","fstype":"devtmpfs","options":["rw","nosuid","seclabel"],"kv_options":{"size":"1918816k","nr_inodes":"479704","mode":"755"}},{"target":"/dev/shm","source":"tmpfs","fstype":"tmpfs","options":["rw","nosuid","nodev","seclabel"]},{"target":"/dev/pts","source":"devpts","fstype":"devpts","options":["rw","nosuid","noexec","relatime","seclabel"],"kv_options":{"gid":"5","mode":"620","ptmxmode":"000"}},{"target":"/dev/hugepages","source":"hugetlbfs","fstype":"hugetlbfs","options":["rw","relatime","seclabel"]},{"target":"/dev/mqueue","source":"mqueue","fstype":"mqueue","options":["rw","relatime","seclabel"]},{"target":"/run","source":"tmpfs","fstype":"tmpfs","options":["rw","nosuid","nodev","seclabel"],"kv_options":{"mode":"755"}},{"target":"/run/user/1000","source":"tmpfs","fstype":"tmpfs","options":["rw","nosuid","nodev","relatime","seclabel"],"kv_options":{"size":"386136k","mode":"700","uid":"1000","gid":"1000"}},{"target":"/boot","source":"/dev/sda1","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]},{"target":"/var/lib/docker/containers","source":"/dev/mapper/centos-root[/var/lib/docker/containers]","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]},{"target":"/var/lib/docker/overlay2","source":"/dev/mapper/centos-root[/var/lib/docker/overlay2]","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]}]
|
32
tests/fixtures/centos-7.7/findmnt-a.out
vendored
Normal file
32
tests/fixtures/centos-7.7/findmnt-a.out
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
TARGET SOURCE FSTYPE OPTIONS
|
||||||
|
/ /dev/mapper/centos-root xfs rw,relatime,seclabel,attr2,inode64,noquota
|
||||||
|
|-/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime,seclabel
|
||||||
|
| |-/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
|
||||||
|
| |-/sys/fs/cgroup tmpfs tmpfs ro,nosuid,nodev,noexec,seclabel,mode=755
|
||||||
|
| | |-/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd
|
||||||
|
| | |-/sys/fs/cgroup/net_cls,net_prio cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,net_prio,net_cls
|
||||||
|
| | |-/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,freezer
|
||||||
|
| | |-/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,devices
|
||||||
|
| | |-/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,cpuset
|
||||||
|
| | |-/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,cpuacct,cpu
|
||||||
|
| | |-/sys/fs/cgroup/pids cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,pids
|
||||||
|
| | |-/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,memory
|
||||||
|
| | |-/sys/fs/cgroup/perf_event cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,perf_event
|
||||||
|
| | |-/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,hugetlb
|
||||||
|
| | `-/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,blkio
|
||||||
|
| |-/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec,relatime
|
||||||
|
| |-/sys/kernel/config configfs configfs rw,relatime
|
||||||
|
| |-/sys/fs/selinux selinuxfs selinuxfs rw,relatime
|
||||||
|
| `-/sys/kernel/debug debugfs debugfs rw,relatime
|
||||||
|
|-/proc proc proc rw,nosuid,nodev,noexec,relatime
|
||||||
|
| `-/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=22,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13827
|
||||||
|
|-/dev devtmpfs devtmpfs rw,nosuid,seclabel,size=1918816k,nr_inodes=479704,mode=755
|
||||||
|
| |-/dev/shm tmpfs tmpfs rw,nosuid,nodev,seclabel
|
||||||
|
| |-/dev/pts devpts devpts rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000
|
||||||
|
| |-/dev/hugepages hugetlbfs hugetlbfs rw,relatime,seclabel
|
||||||
|
| `-/dev/mqueue mqueue mqueue rw,relatime,seclabel
|
||||||
|
|-/run tmpfs tmpfs rw,nosuid,nodev,seclabel,mode=755
|
||||||
|
| `-/run/user/1000 tmpfs tmpfs rw,nosuid,nodev,relatime,seclabel,size=386136k,mode=700,uid=1000,gid=1000
|
||||||
|
|-/boot /dev/sda1 xfs rw,relatime,seclabel,attr2,inode64,noquota
|
||||||
|
|-/var/lib/docker/containers /dev/mapper/centos-root[/var/lib/docker/containers] xfs rw,relatime,seclabel,attr2,inode64,noquota
|
||||||
|
`-/var/lib/docker/overlay2 /dev/mapper/centos-root[/var/lib/docker/overlay2] xfs rw,relatime,seclabel,attr2,inode64,noquota
|
1
tests/fixtures/centos-7.7/findmnt-l.json
vendored
Normal file
1
tests/fixtures/centos-7.7/findmnt-l.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"target":"/sys","source":"sysfs","fstype":"sysfs","options":["rw","nosuid","nodev","noexec","relatime","seclabel"]},{"target":"/proc","source":"proc","fstype":"proc","options":["rw","nosuid","nodev","noexec","relatime"]},{"target":"/dev","source":"devtmpfs","fstype":"devtmpfs","options":["rw","nosuid","seclabel"],"kv_options":{"size":"1918816k","nr_inodes":"479704","mode":"755"}},{"target":"/sys/kernel/security","source":"securityfs","fstype":"securityfs","options":["rw","nosuid","nodev","noexec","relatime"]},{"target":"/dev/shm","source":"tmpfs","fstype":"tmpfs","options":["rw","nosuid","nodev","seclabel"]},{"target":"/dev/pts","source":"devpts","fstype":"devpts","options":["rw","nosuid","noexec","relatime","seclabel"],"kv_options":{"gid":"5","mode":"620","ptmxmode":"000"}},{"target":"/run","source":"tmpfs","fstype":"tmpfs","options":["rw","nosuid","nodev","seclabel"],"kv_options":{"mode":"755"}},{"target":"/sys/fs/cgroup","source":"tmpfs","fstype":"tmpfs","options":["ro","nosuid","nodev","noexec","seclabel"],"kv_options":{"mode":"755"}},{"target":"/sys/fs/cgroup/systemd","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","xattr"],"kv_options":{"release_agent":"/usr/lib/systemd/systemd-cgroups-agent","name":"systemd"}},{"target":"/sys/fs/pstore","source":"pstore","fstype":"pstore","options":["rw","nosuid","nodev","noexec","relatime"]},{"target":"/sys/fs/cgroup/net_cls,net_prio","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","net_prio","net_cls"]},{"target":"/sys/fs/cgroup/freezer","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","freezer"]},{"target":"/sys/fs/cgroup/devices","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","devices"]},{"target":"/sys/fs/cgroup/cpuset","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","cpuset"]},{"target":"/sys/fs/cgroup/cpu,cpuacct","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","cpuacct","cpu"]},{"target":"/sys/fs/cgroup/pids","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","pids"]},{"target":"/sys/fs/cgroup/memory","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","memory"]},{"target":"/sys/fs/cgroup/perf_event","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","perf_event"]},{"target":"/sys/fs/cgroup/hugetlb","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","hugetlb"]},{"target":"/sys/fs/cgroup/blkio","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","blkio"]},{"target":"/sys/kernel/config","source":"configfs","fstype":"configfs","options":["rw","relatime"]},{"target":"/","source":"/dev/mapper/centos-root","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]},{"target":"/sys/fs/selinux","source":"selinuxfs","fstype":"selinuxfs","options":["rw","relatime"]},{"target":"/proc/sys/fs/binfmt_misc","source":"systemd-1","fstype":"autofs","options":["rw","relatime","direct"],"kv_options":{"fd":"22","pgrp":"1","timeout":"0","minproto":"5","maxproto":"5","pipe_ino":"13827"}},{"target":"/dev/hugepages","source":"hugetlbfs","fstype":"hugetlbfs","options":["rw","relatime","seclabel"]},{"target":"/dev/mqueue","source":"mqueue","fstype":"mqueue","options":["rw","relatime","seclabel"]},{"target":"/sys/kernel/debug","source":"debugfs","fstype":"debugfs","options":["rw","relatime"]},{"target":"/boot","source":"/dev/sda1","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]},{"target":"/var/lib/docker/containers","source":"/dev/mapper/centos-root[/var/lib/docker/containers]","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]},{"target":"/var/lib/docker/overlay2","source":"/dev/mapper/centos-root[/var/lib/docker/overlay2]","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]},{"target":"/run/user/1000","source":"tmpfs","fstype":"tmpfs","options":["rw","nosuid","nodev","relatime","seclabel"],"kv_options":{"size":"386136k","mode":"700","uid":"1000","gid":"1000"}}]
|
32
tests/fixtures/centos-7.7/findmnt-l.out
vendored
Normal file
32
tests/fixtures/centos-7.7/findmnt-l.out
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
TARGET SOURCE FSTYPE OPTIONS
|
||||||
|
/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime,seclabel
|
||||||
|
/proc proc proc rw,nosuid,nodev,noexec,relatime
|
||||||
|
/dev devtmpfs devtmpfs rw,nosuid,seclabel,size=1918816k,nr_inodes=479704,mode=755
|
||||||
|
/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
|
||||||
|
/dev/shm tmpfs tmpfs rw,nosuid,nodev,seclabel
|
||||||
|
/dev/pts devpts devpts rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000
|
||||||
|
/run tmpfs tmpfs rw,nosuid,nodev,seclabel,mode=755
|
||||||
|
/sys/fs/cgroup tmpfs tmpfs ro,nosuid,nodev,noexec,seclabel,mode=755
|
||||||
|
/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd
|
||||||
|
/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec,relatime
|
||||||
|
/sys/fs/cgroup/net_cls,net_prio cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,net_prio,net_cls
|
||||||
|
/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,freezer
|
||||||
|
/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,devices
|
||||||
|
/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,cpuset
|
||||||
|
/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,cpuacct,cpu
|
||||||
|
/sys/fs/cgroup/pids cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,pids
|
||||||
|
/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,memory
|
||||||
|
/sys/fs/cgroup/perf_event cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,perf_event
|
||||||
|
/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,hugetlb
|
||||||
|
/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,blkio
|
||||||
|
/sys/kernel/config configfs configfs rw,relatime
|
||||||
|
/ /dev/mapper/centos-root xfs rw,relatime,seclabel,attr2,inode64,noquota
|
||||||
|
/sys/fs/selinux selinuxfs selinuxfs rw,relatime
|
||||||
|
/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=22,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13827
|
||||||
|
/dev/hugepages hugetlbfs hugetlbfs rw,relatime,seclabel
|
||||||
|
/dev/mqueue mqueue mqueue rw,relatime,seclabel
|
||||||
|
/sys/kernel/debug debugfs debugfs rw,relatime
|
||||||
|
/boot /dev/sda1 xfs rw,relatime,seclabel,attr2,inode64,noquota
|
||||||
|
/var/lib/docker/containers /dev/mapper/centos-root[/var/lib/docker/containers] xfs rw,relatime,seclabel,attr2,inode64,noquota
|
||||||
|
/var/lib/docker/overlay2 /dev/mapper/centos-root[/var/lib/docker/overlay2] xfs rw,relatime,seclabel,attr2,inode64,noquota
|
||||||
|
/run/user/1000 tmpfs tmpfs rw,nosuid,nodev,relatime,seclabel,size=386136k,mode=700,uid=1000,gid=1000
|
1
tests/fixtures/centos-7.7/findmnt.json
vendored
Normal file
1
tests/fixtures/centos-7.7/findmnt.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"target":"/","source":"/dev/mapper/centos-root","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]},{"target":"/sys","source":"sysfs","fstype":"sysfs","options":["rw","nosuid","nodev","noexec","relatime","seclabel"]},{"target":"/sys/kernel/security","source":"securityfs","fstype":"securityfs","options":["rw","nosuid","nodev","noexec","relatime"]},{"target":"/sys/fs/cgroup","source":"tmpfs","fstype":"tmpfs","options":["ro","nosuid","nodev","noexec","seclabel"],"kv_options":{"mode":"755"}},{"target":"/sys/fs/cgroup/systemd","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","xattr"],"kv_options":{"release_agent":"/usr/lib/systemd/systemd-cgroups-agent","name":"systemd"}},{"target":"/sys/fs/cgroup/net_cls,net_prio","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","net_prio","net_cls"]},{"target":"/sys/fs/cgroup/blkio","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","blkio"]},{"target":"/sys/fs/cgroup/devices","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","devices"]},{"target":"/sys/fs/cgroup/hugetlb","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","hugetlb"]},{"target":"/sys/fs/cgroup/cpuset","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","cpuset"]},{"target":"/sys/fs/cgroup/cpu,cpuacct","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","cpuacct","cpu"]},{"target":"/sys/fs/cgroup/memory","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","memory"]},{"target":"/sys/fs/cgroup/perf_event","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","perf_event"]},{"target":"/sys/fs/cgroup/freezer","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","freezer"]},{"target":"/sys/fs/cgroup/pids","source":"cgroup","fstype":"cgroup","options":["rw","nosuid","nodev","noexec","relatime","seclabel","pids"]},{"target":"/sys/fs/pstore","source":"pstore","fstype":"pstore","options":["rw","nosuid","nodev","noexec","relatime"]},{"target":"/sys/kernel/config","source":"configfs","fstype":"configfs","options":["rw","relatime"]},{"target":"/sys/fs/selinux","source":"selinuxfs","fstype":"selinuxfs","options":["rw","relatime"]},{"target":"/sys/kernel/debug","source":"debugfs","fstype":"debugfs","options":["rw","relatime"]},{"target":"/proc","source":"proc","fstype":"proc","options":["rw","nosuid","nodev","noexec","relatime"]},{"target":"/proc/sys/fs/binfmt_misc","source":"systemd-1","fstype":"autofs","options":["rw","relatime","direct"],"kv_options":{"fd":"36","pgrp":"1","timeout":"0","minproto":"5","maxproto":"5","pipe_ino":"13995"}},{"target":"/dev","source":"devtmpfs","fstype":"devtmpfs","options":["rw","nosuid","seclabel"],"kv_options":{"size":"1918816k","nr_inodes":"479704","mode":"755"}},{"target":"/dev/shm","source":"tmpfs","fstype":"tmpfs","options":["rw","nosuid","nodev","seclabel"]},{"target":"/dev/pts","source":"devpts","fstype":"devpts","options":["rw","nosuid","noexec","relatime","seclabel"],"kv_options":{"gid":"5","mode":"620","ptmxmode":"000"}},{"target":"/dev/mqueue","source":"mqueue","fstype":"mqueue","options":["rw","relatime","seclabel"]},{"target":"/dev/hugepages","source":"hugetlbfs","fstype":"hugetlbfs","options":["rw","relatime","seclabel"]},{"target":"/run","source":"tmpfs","fstype":"tmpfs","options":["rw","nosuid","nodev","seclabel"],"kv_options":{"mode":"755"}},{"target":"/run/user/0","source":"tmpfs","fstype":"tmpfs","options":["rw","nosuid","nodev","relatime","seclabel"],"kv_options":{"size":"386136k","mode":"700"}},{"target":"/run/user/1000","source":"tmpfs","fstype":"tmpfs","options":["rw","nosuid","nodev","relatime","seclabel"],"kv_options":{"size":"386136k","mode":"700","uid":"1000","gid":"1000"}},{"target":"/boot","source":"/dev/sda1","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]},{"target":"/var/lib/docker/containers","source":"/dev/mapper/centos-root[/var/lib/docker/containers]","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]},{"target":"/var/lib/docker/overlay2","source":"/dev/mapper/centos-root[/var/lib/docker/overlay2]","fstype":"xfs","options":["rw","relatime","seclabel","attr2","inode64","noquota"]}]
|
33
tests/fixtures/centos-7.7/findmnt.out
vendored
Normal file
33
tests/fixtures/centos-7.7/findmnt.out
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
TARGET SOURCE FSTYPE OPTIONS
|
||||||
|
/ /dev/mapper/centos-root xfs rw,relatime,seclabel,attr2,inode64,noquota
|
||||||
|
├─/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime,seclabel
|
||||||
|
│ ├─/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
|
||||||
|
│ ├─/sys/fs/cgroup tmpfs tmpfs ro,nosuid,nodev,noexec,seclabel,mode=755
|
||||||
|
│ │ ├─/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd
|
||||||
|
│ │ ├─/sys/fs/cgroup/net_cls,net_prio cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,net_prio,net_cls
|
||||||
|
│ │ ├─/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,blkio
|
||||||
|
│ │ ├─/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,devices
|
||||||
|
│ │ ├─/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,hugetlb
|
||||||
|
│ │ ├─/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,cpuset
|
||||||
|
│ │ ├─/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,cpuacct,cpu
|
||||||
|
│ │ ├─/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,memory
|
||||||
|
│ │ ├─/sys/fs/cgroup/perf_event cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,perf_event
|
||||||
|
│ │ ├─/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,freezer
|
||||||
|
│ │ └─/sys/fs/cgroup/pids cgroup cgroup rw,nosuid,nodev,noexec,relatime,seclabel,pids
|
||||||
|
│ ├─/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec,relatime
|
||||||
|
│ ├─/sys/kernel/config configfs configfs rw,relatime
|
||||||
|
│ ├─/sys/fs/selinux selinuxfs selinuxfs rw,relatime
|
||||||
|
│ └─/sys/kernel/debug debugfs debugfs rw,relatime
|
||||||
|
├─/proc proc proc rw,nosuid,nodev,noexec,relatime
|
||||||
|
│ └─/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=36,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13995
|
||||||
|
├─/dev devtmpfs devtmpfs rw,nosuid,seclabel,size=1918816k,nr_inodes=479704,mode=755
|
||||||
|
│ ├─/dev/shm tmpfs tmpfs rw,nosuid,nodev,seclabel
|
||||||
|
│ ├─/dev/pts devpts devpts rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000
|
||||||
|
│ ├─/dev/mqueue mqueue mqueue rw,relatime,seclabel
|
||||||
|
│ └─/dev/hugepages hugetlbfs hugetlbfs rw,relatime,seclabel
|
||||||
|
├─/run tmpfs tmpfs rw,nosuid,nodev,seclabel,mode=755
|
||||||
|
│ ├─/run/user/0 tmpfs tmpfs rw,nosuid,nodev,relatime,seclabel,size=386136k,mode=700
|
||||||
|
│ └─/run/user/1000 tmpfs tmpfs rw,nosuid,nodev,relatime,seclabel,size=386136k,mode=700,uid=1000,gid=1000
|
||||||
|
├─/boot /dev/sda1 xfs rw,relatime,seclabel,attr2,inode64,noquota
|
||||||
|
├─/var/lib/docker/containers /dev/mapper/centos-root[/var/lib/docker/containers] xfs rw,relatime,seclabel,attr2,inode64,noquota
|
||||||
|
└─/var/lib/docker/overlay2 /dev/mapper/centos-root[/var/lib/docker/overlay2] xfs rw,relatime,seclabel,attr2,inode64,noquota
|
2
tests/fixtures/centos-7.7/ifconfig.json
vendored
2
tests/fixtures/centos-7.7/ifconfig.json
vendored
@ -1 +1 @@
|
|||||||
[{"name": "docker0", "flags": 4099, "state": ["UP", "BROADCAST", "MULTICAST"], "mtu": 1500, "ipv4_addr": "172.17.0.1", "ipv4_mask": "255.255.0.0", "ipv4_bcast": "0.0.0.0", "mac_addr": "02:42:b1:9a:ea:02", "type": "Ethernet", "rx_packets": 0, "rx_bytes": 0, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 0, "tx_bytes": 0, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null}, {"name": "ens33", "flags": 4163, "state": ["UP", "BROADCAST", "RUNNING", "MULTICAST"], "mtu": 1500, "ipv4_addr": "192.168.71.137", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.71.255", "ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0", "ipv6_mask": 64, "ipv6_scope": "0x20", "mac_addr": "00:0c:29:3b:58:0e", "type": "Ethernet", "rx_packets": 8061, "rx_bytes": 1514413, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 4502, "tx_bytes": 866622, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}, {"name": "lo", "flags": 73, "state": ["UP", "LOOPBACK", "RUNNING"], "mtu": 65536, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "::1", "ipv6_mask": 128, "ipv6_scope": "0x10", "mac_addr": null, "type": "Local Loopback", "rx_packets": 73, "rx_bytes": 6009, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 73, "tx_bytes": 6009, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}]
|
[{"name":"docker0","flags":4099,"state":["UP","BROADCAST","MULTICAST"],"mtu":1500,"type":"Ethernet","mac_addr":"02:42:b1:9a:ea:02","ipv4_addr":"172.17.0.1","ipv4_mask":"255.255.0.0","ipv4_bcast":"0.0.0.0","ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":null,"rx_packets":0,"rx_errors":0,"rx_dropped":0,"rx_overruns":0,"rx_frame":0,"tx_packets":0,"tx_errors":0,"tx_dropped":0,"tx_overruns":0,"tx_carrier":0,"tx_collisions":0,"rx_bytes":0,"tx_bytes":0,"ipv4":[{"address":"172.17.0.1","mask":"255.255.0.0","broadcast":"0.0.0.0"}]},{"name":"ens33","flags":4163,"state":["UP","BROADCAST","RUNNING","MULTICAST"],"mtu":1500,"type":"Ethernet","mac_addr":"00:0c:29:3b:58:0e","ipv4_addr":"192.168.71.137","ipv4_mask":"255.255.255.0","ipv4_bcast":"192.168.71.255","ipv6_addr":"fe80::c1cb:715d:bc3e:b8a0","ipv6_mask":64,"ipv6_scope":"0x20","ipv6_type":"link","metric":null,"rx_packets":8061,"rx_errors":0,"rx_dropped":0,"rx_overruns":0,"rx_frame":0,"tx_packets":4502,"tx_errors":0,"tx_dropped":0,"tx_overruns":0,"tx_carrier":0,"tx_collisions":0,"rx_bytes":1514413,"tx_bytes":866622,"ipv4":[{"address":"192.168.71.137","mask":"255.255.255.0","broadcast":"192.168.71.255"}],"ipv6":[{"address":"fe80::c1cb:715d:bc3e:b8a0","mask":64,"scope":"0x20","type":"link"}]},{"name":"lo","flags":73,"state":["UP","LOOPBACK","RUNNING"],"mtu":65536,"type":"Local Loopback","mac_addr":null,"ipv4_addr":"127.0.0.1","ipv4_mask":"255.0.0.0","ipv4_bcast":null,"ipv6_addr":"::1","ipv6_mask":128,"ipv6_scope":"0x10","ipv6_type":"host","metric":null,"rx_packets":73,"rx_errors":0,"rx_dropped":0,"rx_overruns":0,"rx_frame":0,"tx_packets":73,"tx_errors":0,"tx_dropped":0,"tx_overruns":0,"tx_carrier":0,"tx_collisions":0,"rx_bytes":6009,"tx_bytes":6009,"ipv4":[{"address":"127.0.0.1","mask":"255.0.0.0","broadcast":null}],"ipv6":[{"address":"::1","mask":128,"scope":"0x10","type":"host"}]}]
|
||||||
|
1
tests/fixtures/freebsd12/ifconfig-extra-fields.json
vendored
Normal file
1
tests/fixtures/freebsd12/ifconfig-extra-fields.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"name":"cxl3","flags":8843,"state":["UP","BROADCAST","RUNNING","SIMPLEX","MULTICAST"],"mtu":1500,"type":null,"mac_addr":"00:07:43:3d:b7:70","ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":0,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"options":"6ec07bb","options_flags":["RXCSUM","TXCSUM","VLAN_MTU","VLAN_HWTAGGING","JUMBO_MTU","VLAN_HWCSUM","TSO4","TSO6","LRO","VLAN_HWTSO","LINKSTATE","RXCSUM_IPV6","TXCSUM_IPV6","HWRXTSTMP","NOMAP"],"hw_address":"00:07:43:3d:b7:88","media":"Ethernet 10Gbase-LR","media_flags":["full-duplex","rxpause","txpause"],"status":"active","nd6_options":29,"nd6_flags":["PERFORMNUD","IFDISABLED","AUTO_LINKLOCAL"],"plugged":"SFP/SFP+/SFP28 10G Base-LR (LC)","vendor":"INNOLIGHT","vendor_pn":"TR-PX13L-N00","vendor_sn":"INJBL0431986","vendor_date":"2020-01-04","module_temperature":"21.20 C","module_voltage":"3.16 Volts"}]
|
10
tests/fixtures/freebsd12/ifconfig-extra-fields.out
vendored
Normal file
10
tests/fixtures/freebsd12/ifconfig-extra-fields.out
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
cxl3: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
|
||||||
|
options=6ec07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWTSO,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6,HWRXTSTMP,NOMAP>
|
||||||
|
ether 00:07:43:3d:b7:70
|
||||||
|
hwaddr 00:07:43:3d:b7:88 media: Ethernet 10Gbase-LR <full-duplex,rxpause,txpause>
|
||||||
|
status: active
|
||||||
|
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
|
||||||
|
plugged: SFP/SFP+/SFP28 10G Base-LR (LC)
|
||||||
|
vendor: INNOLIGHT PN: TR-PX13L-N00 SN: INJBL0431986 DATE: 2020-01-04
|
||||||
|
module temperature: 21.20 C voltage: 3.16 Volts
|
||||||
|
lane 1: RX power: 0.49 mW (-3.10 dBm) TX bias: 23.85 mA
|
1
tests/fixtures/freebsd12/ifconfig-extra-fields2.json
vendored
Normal file
1
tests/fixtures/freebsd12/ifconfig-extra-fields2.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"name":"ix0","flags":8843,"state":["UP","BROADCAST","RUNNING","SIMPLEX","MULTICAST"],"mtu":9000,"type":null,"mac_addr":"00:1b:21:8b:f8:2c","ipv4_addr":"10.10.2.101","ipv4_mask":"255.255.255.0","ipv4_bcast":"10.10.2.255","ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":0,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"options":"e53fbb","options_flags":["RXCSUM","TXCSUM","VLAN_MTU","VLAN_HWTAGGING","JUMBO_MTU","VLAN_HWCSUM","TSO4","TSO6","LRO","WOL_UCAST","WOL_MCAST","WOL_MAGIC","VLAN_HWFILTER","VLAN_HWTSO","RXCSUM_IPV6","TXCSUM_IPV6"],"media":"Ethernet autoselect (10Gbase-SR","media_flags":["full-duplex","rxpause","txpause"],"status":"active","nd6_options":29,"nd6_flags":["PERFORMNUD","IFDISABLED","AUTO_LINKLOCAL"],"plugged":"SFP/SFP+/SFP28 10G Base-SR (LC)","vendor":"Intel Corp","vendor_pn":"FTLX8571D3BCV-IT","vendor_sn":"ALH1AV9","vendor_date":"2011-10-27","module_temperature":"51.27 C","module_voltage":"3.31 Volts","rx_power":"0.49 mW (-3.02 dBm)","tx_pwer":"0.66 mW (-1.74 dBm)","ipv4":[{"address":"10.10.2.101","mask":"255.255.255.0","broadcast":"10.10.2.255"}]}]
|
11
tests/fixtures/freebsd12/ifconfig-extra-fields2.out
vendored
Normal file
11
tests/fixtures/freebsd12/ifconfig-extra-fields2.out
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
ix0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 9000
|
||||||
|
options=e53fbb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,WOL_UCAST,WOL_MCAST,WOL_MAGIC,VLAN_HWFILTER,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6>
|
||||||
|
ether 00:1b:21:8b:f8:2c
|
||||||
|
inet 10.10.2.101/24 broadcast 10.10.2.255
|
||||||
|
media: Ethernet autoselect (10Gbase-SR <full-duplex,rxpause,txpause>)
|
||||||
|
status: active
|
||||||
|
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
|
||||||
|
plugged: SFP/SFP+/SFP28 10G Base-SR (LC)
|
||||||
|
vendor: Intel Corp PN: FTLX8571D3BCV-IT SN: ALH1AV9 DATE: 2011-10-27
|
||||||
|
module temperature: 51.27 C Voltage: 3.31 Volts
|
||||||
|
RX: 0.49 mW (-3.02 dBm) TX: 0.66 mW (-1.74 dBm)
|
1
tests/fixtures/freebsd12/ifconfig-extra-fields3.json
vendored
Normal file
1
tests/fixtures/freebsd12/ifconfig-extra-fields3.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"name":"cxl3","flags":8843,"state":["UP","BROADCAST","RUNNING","SIMPLEX","MULTICAST"],"mtu":1500,"type":null,"mac_addr":"00:07:43:3d:b7:70","ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":0,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"options":"6ec07bb","options_flags":["RXCSUM","TXCSUM","VLAN_MTU","VLAN_HWTAGGING","JUMBO_MTU","VLAN_HWCSUM","TSO4","TSO6","LRO","VLAN_HWTSO","LINKSTATE","RXCSUM_IPV6","TXCSUM_IPV6","HWRXTSTMP","NOMAP"],"hw_address":"00:07:43:3d:b7:88","media":null,"media_flags":null,"status":"active","nd6_options":29,"nd6_flags":["PERFORMNUD","IFDISABLED","AUTO_LINKLOCAL"],"plugged":"SFP/SFP+/SFP28 10G Base-LR (LC)","vendor":"INNOLIGHT","vendor_pn":"TR-PX13L-N00","vendor_sn":"INJBL0431986","vendor_date":"2020-01-04","module_temperature":"21.20 C","module_voltage":"3.16 Volts"}]
|
10
tests/fixtures/freebsd12/ifconfig-extra-fields3.out
vendored
Normal file
10
tests/fixtures/freebsd12/ifconfig-extra-fields3.out
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
cxl3: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
|
||||||
|
options=6ec07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWTSO,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6,HWRXTSTMP,NOMAP>
|
||||||
|
ether 00:07:43:3d:b7:70
|
||||||
|
hwaddr 00:07:43:3d:b7:88
|
||||||
|
status: active
|
||||||
|
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
|
||||||
|
plugged: SFP/SFP+/SFP28 10G Base-LR (LC)
|
||||||
|
vendor: INNOLIGHT PN: TR-PX13L-N00 SN: INJBL0431986 DATE: 2020-01-04
|
||||||
|
module temperature: 21.20 C voltage: 3.16 Volts
|
||||||
|
lane 1: RX power: 0.49 mW (-3.10 dBm) TX bias: 23.85 mA
|
1
tests/fixtures/generic/csv-utf-8-bom-streaming.json
vendored
Normal file
1
tests/fixtures/generic/csv-utf-8-bom-streaming.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"col1":"a","col2":"b","col3":"c"},{"col1":"x","col2":"y","col3":"z"},{"col1":"abc","col2":"def","col3":"ghi"},{"col1":"1","col2":"2","col3":"3"},{"col1":"foo","col2":"bar","col3":"baz"}]
|
6
tests/fixtures/generic/csv-utf-8-bom.csv
vendored
Normal file
6
tests/fixtures/generic/csv-utf-8-bom.csv
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
col1,col2,col3
|
||||||
|
a,b,c
|
||||||
|
x,y,z
|
||||||
|
abc,def,ghi
|
||||||
|
1,2,3
|
||||||
|
foo,bar,baz
|
|
1
tests/fixtures/generic/csv-utf-8-bom.json
vendored
Normal file
1
tests/fixtures/generic/csv-utf-8-bom.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"col1":"a","col2":"b","col3":"c"},{"col1":"x","col2":"y","col3":"z"},{"col1":"abc","col2":"def","col3":"ghi"},{"col1":"1","col2":"2","col3":"3"},{"col1":"foo","col2":"bar","col3":"baz"}]
|
1
tests/fixtures/generic/git-ls-remote-raw.json
vendored
Normal file
1
tests/fixtures/generic/git-ls-remote-raw.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
tests/fixtures/generic/git-ls-remote.json
vendored
Normal file
1
tests/fixtures/generic/git-ls-remote.json
vendored
Normal file
File diff suppressed because one or more lines are too long
305
tests/fixtures/generic/git-ls-remote.out
vendored
Normal file
305
tests/fixtures/generic/git-ls-remote.out
vendored
Normal file
@ -0,0 +1,305 @@
|
|||||||
|
214cd6b9e09603b3c4fa02203b24fb2bc3d4e338 HEAD
|
||||||
|
b884f6aacca39e05994596d8fdfa7e7c4f1e0389 refs/heads/dev
|
||||||
|
214cd6b9e09603b3c4fa02203b24fb2bc3d4e338 refs/heads/master
|
||||||
|
e416c77bed1267254da972b0f95b7ff1d43fccef refs/pull/1/head
|
||||||
|
283b89e37c38a3082203e43e38569c8b0bb11e12 refs/pull/101/head
|
||||||
|
cc6a19adccea3e10243a166b87d852b6f95414b5 refs/pull/102/head
|
||||||
|
325fab2de7b8a4bfc452ab8d3cf333d47fdf4989 refs/pull/106/head
|
||||||
|
5b60c7445a3f8bd2ae1587aa0ffaeaf093966f9a refs/pull/107/head
|
||||||
|
a73fdb7478965f0f2c841ac01b2762db80ad0786 refs/pull/114/head
|
||||||
|
5285e699c30fdeaf56068f5a03ef1d1d33fa673c refs/pull/115/head
|
||||||
|
5d8f8365e24a7c3a587d4e71ebba4876de08203b refs/pull/116/head
|
||||||
|
605353fdce3b8b5986d20a35d05f7210a6df0730 refs/pull/117/head
|
||||||
|
13deb8bfb6e77aaf86942f0be87b59d06ee2a97c refs/pull/118/head
|
||||||
|
aef54705f5267c633e0778e8dce0065978083139 refs/pull/119/head
|
||||||
|
e0681eebb9881dc0ffddb478224455f434919104 refs/pull/120/head
|
||||||
|
6c838460752c7131f75cdab2da07266fee492060 refs/pull/121/head
|
||||||
|
3ab9d480149a692510ab9e0ac8e745b674683e3d refs/pull/123/head
|
||||||
|
35464bbbfb6b424ef3ee1c855557ada1bf3769fa refs/pull/127/head
|
||||||
|
92e2252bee00482bb0eeae3074b107d4c8553e4c refs/pull/128/head
|
||||||
|
56e041aa260b2daf2f5662fae98645a93137adb5 refs/pull/129/head
|
||||||
|
bd428a9fd75327710dce96f3c95f74ab9d1beaad refs/pull/130/head
|
||||||
|
d24f9a885d3954035a98a488671486408f509dca refs/pull/131/head
|
||||||
|
6150aae0aeabafba26d9f119406b0660d9221cb6 refs/pull/135/head
|
||||||
|
efb1d3e6b2db920423511a9dcf4c5e5fd9d6af43 refs/pull/136/head
|
||||||
|
9c57c09c00e64a9031391b9b70083ad6ecf0bc0b refs/pull/138/head
|
||||||
|
95aec9c6f9aa8fb4d0dae227410a1346d550f47f refs/pull/139/head
|
||||||
|
ff7ab0a1ed7f468d0e84eb3bf0636f53913c490d refs/pull/141/head
|
||||||
|
3b22ce41105387e7f46a410460cf04759feef197 refs/pull/147/head
|
||||||
|
7a1be905bb8654558afb5979b0bd78d4a8488874 refs/pull/149/head
|
||||||
|
0dbd2702f6ab2640b2ccdea92411ac0789673e66 refs/pull/154/head
|
||||||
|
2689697b4c21758903e5f74ec069e89be585aba2 refs/pull/155/head
|
||||||
|
473f70668f04a38765559c5dbf0468af24d625c9 refs/pull/156/head
|
||||||
|
834e52369ceb479776ddc8fc2931790af53b9c18 refs/pull/159/head
|
||||||
|
4867655eb297b1da7a55e0d3a24c7ed7c8af55c7 refs/pull/16/head
|
||||||
|
e08b61fa81b1bd2304d04db5cdc8b809fe9c6032 refs/pull/163/head
|
||||||
|
aac553950d3bdd8fbd60f3df81cc67686622ed9a refs/pull/167/head
|
||||||
|
528aac7ad87feae2093aba563c83a29ebf75e5f9 refs/pull/168/head
|
||||||
|
a6f859a55edae50fcc185948736218404cfaa929 refs/pull/169/head
|
||||||
|
4f118559356edc1da866e1bec80830e7a75a0b26 refs/pull/17/head
|
||||||
|
77dcbc544da271edab5de5ad209117e98c846f9c refs/pull/170/head
|
||||||
|
9b160f6279bbbf0c15413c98922eef137ba2f3f4 refs/pull/172/head
|
||||||
|
5ba22dae597b9d154ca0a82f71cfbd8d8a6325db refs/pull/176/head
|
||||||
|
7fa5391b6613e62689c624041e03f9750c9c7972 refs/pull/179/head
|
||||||
|
eb888dcbbcf83c9197bd59aab72f65ea6eb622ba refs/pull/180/head
|
||||||
|
7933dfdbe7bf400833d6f6b771362dfc518b9a8d refs/pull/183/head
|
||||||
|
b4506976e3c865397bc657183d49c484d8bcfd7a refs/pull/184/head
|
||||||
|
9c1eaa938934269fe4179da798acf5f119cde0cf refs/pull/185/head
|
||||||
|
2e4f5a508b6c90f9e03dcbcf64efc0e2fc446666 refs/pull/186/head
|
||||||
|
433c7cc0f05e321ffe024845a908f3e856d4cd2b refs/pull/187/head
|
||||||
|
b7d439cb870e443e4f4e4a2137ab170835e77eff refs/pull/188/head
|
||||||
|
f7331001d4ab976e311458a16b6e5337da2e3aab refs/pull/189/head
|
||||||
|
53cdf863acc72dbdb671773e30277f42e9eadc0e refs/pull/19/head
|
||||||
|
65d96e26b59e231c77c1dbba1dc91708c33de30c refs/pull/190/head
|
||||||
|
bc7973af36e13006230b5faa9e201e300d468912 refs/pull/192/head
|
||||||
|
78672bd7ad66c418e0ecf31add73f887b0946d29 refs/pull/193/head
|
||||||
|
e6900e2000bf265dfcfc09ffbfda39e9238661af refs/pull/194/head
|
||||||
|
830674cc6f19e107347a743baff7bbaab7f80b75 refs/pull/195/head
|
||||||
|
027c231097a002526350a93322407582a85db0cb refs/pull/198/head
|
||||||
|
b3896650c230b4acc73704a50c93ee74e4034eef refs/pull/199/head
|
||||||
|
30080c01659cf611666876b7b063b7b329822352 refs/pull/2/head
|
||||||
|
8bb266352207f95040b72750e5b3ae3b8ceb2b98 refs/pull/203/head
|
||||||
|
cbdc66623671da335eafe132b7af79f884856f1d refs/pull/204/head
|
||||||
|
3afaa48eee081e28262d1762c5ec23d318012822 refs/pull/207/head
|
||||||
|
961968a0fcaf37b64bc850c4945ba4b805a1fe54 refs/pull/208/head
|
||||||
|
98619834818c181cb50a9605fe166b6153c46095 refs/pull/209/head
|
||||||
|
ac61e9ad2c9c4e864db02db04cbf907fb0efd99b refs/pull/211/head
|
||||||
|
789f0735dfd63e728b8716d97cf0c6045ede5011 refs/pull/213/head
|
||||||
|
4140939bbf74bada6e062143ceba777c129f1955 refs/pull/215/head
|
||||||
|
14d6d8b84f0ddeff984aff486e2e697a91ac6fb6 refs/pull/22/head
|
||||||
|
7138eef3d137bc64286d4af453d8d4e7b3f4408d refs/pull/220/head
|
||||||
|
a1afed8d95e33fbbc618c7b5778a9faeea2f628f refs/pull/223/head
|
||||||
|
4ee8a69337b24e199983fe657643abcb0a56a8e6 refs/pull/225/head
|
||||||
|
dcca7a57d558721a61fbba44f07b1d53116827e1 refs/pull/226/head
|
||||||
|
8bc2ea14a3c83df0c46a16384cffd10f4fa5880b refs/pull/233/head
|
||||||
|
46af3bd0c0f699a45e2e12bab43fffca8fe44b77 refs/pull/234/head
|
||||||
|
148f2fb6dba660bd5211f946ca9321e0e3ac874a refs/pull/235/head
|
||||||
|
49ca0cecf42212e1036cd2234bdbf48701d25041 refs/pull/236/head
|
||||||
|
7608823ea7bf1a444b6e6d85c58bc733d969bb9d refs/pull/238/head
|
||||||
|
1f236dc02aff63e7575df7b67ed0824d6d7f5eb3 refs/pull/240/head
|
||||||
|
0bf69713abd312998cd28b7ec721aa7b79564984 refs/pull/242/head
|
||||||
|
c12b48537a7a0f7d47cd655940ab7ba091a78243 refs/pull/244/head
|
||||||
|
176ca2f75d5bfa8353cc22b233653dbe34d11922 refs/pull/247/head
|
||||||
|
9bf2cd06915ae232c3db133d0a50640dc99f4b3e refs/pull/249/head
|
||||||
|
f857523ca756864211b6b18af5a8886e5db200bb refs/pull/25/head
|
||||||
|
57142d899c2261ae02b7f5797f412113cd79f510 refs/pull/250/head
|
||||||
|
776ee66baef425517b8c9e4ba39a25539bf6673c refs/pull/251/head
|
||||||
|
7583f315cee2930c5e6e5faec697d59c8b2063cd refs/pull/256/head
|
||||||
|
f1ed8035252d30e2637b6d38de740b1351b89f97 refs/pull/258/head
|
||||||
|
b0e9d9fa9d13f3db7118a22fe0774ef84cd0f2e4 refs/pull/260/head
|
||||||
|
eaa36a6a319f85eed9f80fb04eb0287306b4774a refs/pull/262/head
|
||||||
|
8b3228797ef357678be900d9a4b13c3f875f8738 refs/pull/266/head
|
||||||
|
73d0bb8bbdd37aa9691df7e2d6290e17fbea04a1 refs/pull/267/head
|
||||||
|
cd2f139409d1901d13f3a91e2a0f6240aa1782f4 refs/pull/273/head
|
||||||
|
4746cb381424864bfdecbed86237c6018ab053fe refs/pull/274/head
|
||||||
|
0b726f7accf819c69c18d582682f11494c321cb1 refs/pull/275/head
|
||||||
|
00e497828e251de1188e012cb2534e39e911bf1b refs/pull/277/head
|
||||||
|
4ebde3af5f8d6019db51c7c3e9d53dcecebb667a refs/pull/284/head
|
||||||
|
f1383b5c66538db858b0de0bf1197d47353c0f29 refs/pull/286/head
|
||||||
|
c348fa89a938099662c4fe8f89bdfd9422230ab5 refs/pull/287/head
|
||||||
|
aeb494703e19b4041e16c86db926d4db53e26d4f refs/pull/289/head
|
||||||
|
8bfa0bddec9ff1c21972019467dcf5738ab3afd2 refs/pull/29/head
|
||||||
|
9c290b5e115c59db14f6629f8221767756c41651 refs/pull/290/head
|
||||||
|
32fddce8fbb42eb1040fe123c66523122fe9aa72 refs/pull/292/head
|
||||||
|
6f1ef09d2a24de2a0a33e174cf36830952c98c52 refs/pull/299/head
|
||||||
|
976fd7d9bd49190a8b28ea5acf5af8979cdec537 refs/pull/3/head
|
||||||
|
6770892acd49aced225dbccf39290f33522c9001 refs/pull/30/head
|
||||||
|
2caa10e0af48c4fc1d75ccca27ff45b9ff5e8452 refs/pull/304/head
|
||||||
|
45859b01e50164123ff689730d77cc416a14a4d3 refs/pull/306/head
|
||||||
|
73c280de3a1aaa04caefedc7f4dcb1ab807326a6 refs/pull/310/head
|
||||||
|
22ff2964e9889587711e779ac24f8f8034212f5e refs/pull/32/head
|
||||||
|
a63408c8cf3f99646be2b375f651d6cf417f7ae0 refs/pull/33/head
|
||||||
|
065276805f0f2dd23a6382f0120ca07e9eae116f refs/pull/34/head
|
||||||
|
c01bcd3734382a0c388d9f4041fc888171ca7675 refs/pull/35/head
|
||||||
|
065276805f0f2dd23a6382f0120ca07e9eae116f refs/pull/36/head
|
||||||
|
51d5c3892d6ff1e2e6ac7c4f3e496e7d9ed4b6a7 refs/pull/37/head
|
||||||
|
2cc1b1bd5451f31d71b0e2236bdee0ce2b25b5d7 refs/pull/4/head
|
||||||
|
ddc8ae70c5b3345053810144ce9a2d8e482ba333 refs/pull/43/head
|
||||||
|
65bd7e2904016141c1ed53cdd437865c66d7628e refs/pull/44/head
|
||||||
|
5bc5596f604fb87dffbfdf44ce2395b16bf01297 refs/pull/45/head
|
||||||
|
a2ab5bab91ea980399df1afb9d8071fa3282d04e refs/pull/48/head
|
||||||
|
c29e7cfe5cc4b2151912c6f618137d1b6c39c7be refs/pull/49/head
|
||||||
|
c9849ce0db1f864d33739f8f6f942bf5672bc3b7 refs/pull/5/head
|
||||||
|
c02811356153c2b4f8b2d7efb7f48bf8f7748068 refs/pull/50/head
|
||||||
|
5b697dc38141cdd47fcdd63bf295a80a7da86697 refs/pull/52/head
|
||||||
|
3f5279b97c386c736e0e2faa5c39d68ef89c46aa refs/pull/53/head
|
||||||
|
07b8d9e0c0d723d93e6c652f5b6156c467c451c7 refs/pull/56/head
|
||||||
|
4a77ec63a46554c84e646d31564230774ed87431 refs/pull/57/head
|
||||||
|
a3d9213a1e2fd52ba2cbc863d4d01d3ffeebe230 refs/pull/6/head
|
||||||
|
d98e43dc78205d3224bfc1e67de2da3c5fb7ea9a refs/pull/61/head
|
||||||
|
84f48aa369a458f534523ecc1e3aaaf403d06f1c refs/pull/62/head
|
||||||
|
fa44d48c094a55e499c2c780d109bf277736b42e refs/pull/64/head
|
||||||
|
9f2279d5867eb89d4b4b7b4ffca290166ec97c48 refs/pull/65/head
|
||||||
|
f6478fb636ead8d1e53e4a88d59e55222df37a8f refs/pull/66/head
|
||||||
|
054422d8373e7b8def18ddabd447062cb9cc3137 refs/pull/67/head
|
||||||
|
83f41b83dc01c462c6a2295e9fc56ad42a3b62f4 refs/pull/68/head
|
||||||
|
8a134065dff429551449c1ea16a36d745fdab580 refs/pull/70/head
|
||||||
|
847e346602789bf58e3515319e9d080dfb897fc9 refs/pull/71/head
|
||||||
|
ce0b43d919f07d96d1b94e9d14d03e935e80011d refs/pull/72/head
|
||||||
|
94b12b57aaa56170d1f31f4910fd1239f88de137 refs/pull/73/head
|
||||||
|
6badd3fb1e1cf6d1ee99614fadc20d54be8039aa refs/pull/74/head
|
||||||
|
85ad5cfd0bfb903ce35e37b343244fed88dbd979 refs/pull/76/head
|
||||||
|
b12217466e906829d19be4cfd80dfe7cf4008e57 refs/pull/91/head
|
||||||
|
996d394e89c732f327323ca340fce405bd5fb2e4 refs/pull/97/head
|
||||||
|
58246e33b71bae0ca4a42ad5bdf31134948b1014 refs/pull/98/head
|
||||||
|
92fdd51788536ca3b163af87698b362c42d01ef2 refs/tags/v.1.7.2
|
||||||
|
028e136161ac15f588845f87907b4565a6ee7be2 refs/tags/v.1.7.2^{}
|
||||||
|
ef906f46da0b92af7b2bbfaa47d18341cb9a4b05 refs/tags/v0.2.0
|
||||||
|
3b74afc39e58f801e75b7105e521c1469d30f991 refs/tags/v0.2.0^{}
|
||||||
|
0d89e870ccce11f0dca4ce85c14c9f17b8aac4aa refs/tags/v0.5.5
|
||||||
|
0040febbf099ed8ab35f6ee343750fcf89f2e739 refs/tags/v0.5.5^{}
|
||||||
|
b9f8dd20bb1d461cb8c0114fd9ac57dbf5aad733 refs/tags/v0.6.2
|
||||||
|
59238c85408117748e78c5e87157381a828f3782 refs/tags/v0.6.2^{}
|
||||||
|
a30131ed88a94183bd0ac01aac1fa030dff009b4 refs/tags/v0.6.3
|
||||||
|
4c8610c54ff4b643237d8f0e4c5781c277fc39f5 refs/tags/v0.6.3^{}
|
||||||
|
150a3c7819fdca2b0571326b88b7941b0cecfbcc refs/tags/v0.6.4
|
||||||
|
b5ea08e55bfd22c9da5ba73c124791012df119a0 refs/tags/v0.6.4^{}
|
||||||
|
5a7e77f7fa50a1b79561dfe3ac0c6bba1daf3213 refs/tags/v0.8.1
|
||||||
|
976fd7d9bd49190a8b28ea5acf5af8979cdec537 refs/tags/v0.8.1^{}
|
||||||
|
2d6a1ed2a0e423e9c4fd770c644331e86a7fa613 refs/tags/v0.9.1
|
||||||
|
e7921b65f5a250c10b08f78939f74968047af430 refs/tags/v0.9.1^{}
|
||||||
|
3d653caf11f65a72de974e7f6baccc5af79198af refs/tags/v1.0.1
|
||||||
|
c3eaf59836538f4ab4c745e87b70115b4a4c5421 refs/tags/v1.0.1^{}
|
||||||
|
0f85dd49a165885592fbbf84023cb99127fe87c0 refs/tags/v1.1.1
|
||||||
|
d1927456b02e6c2a6e6395cd6ce873b6565ec37d refs/tags/v1.1.1^{}
|
||||||
|
dc709cbaf59a51fa92431ed005c4f5d1fc16b36e refs/tags/v1.10.0
|
||||||
|
a43e2e19916662d509883457c160d7f95f97ae12 refs/tags/v1.10.0^{}
|
||||||
|
015af5415cf4d20a946a1c835a01ff483aec5ffa refs/tags/v1.10.1
|
||||||
|
606904d48b1c7e0c19a940b5be0b564d1b5be6c8 refs/tags/v1.10.1^{}
|
||||||
|
186dcced5716351159cac4f8638282b4513fdfea refs/tags/v1.10.10
|
||||||
|
2c1935115de03a28fe92674b04b2542b0eccb8fe refs/tags/v1.10.10^{}
|
||||||
|
f10f2af68d562763c42d8269f5c9551a0657b6e9 refs/tags/v1.10.12
|
||||||
|
f5627a45947e5e76e5f3e64d9b30099fe0b962a2 refs/tags/v1.10.12^{}
|
||||||
|
9c270d623a393a36c954dc717bd008dfc90d3bf7 refs/tags/v1.10.2
|
||||||
|
7f869b4b187d70752207a7e74c13b858446f898f refs/tags/v1.10.2^{}
|
||||||
|
5e0a2be9cd470cc7a505eb974d3c2b475e978159 refs/tags/v1.10.3
|
||||||
|
99f7842dee0f79cf933fae185cf8b0ed7c8b210f refs/tags/v1.10.3^{}
|
||||||
|
8b995d8f4dbe8b75a463836f5fbcb7ea19a22b2b refs/tags/v1.10.4
|
||||||
|
c87b722aec6e6964c516bbb8e80667ad7d9c6bc7 refs/tags/v1.10.4^{}
|
||||||
|
a61503737869559aa6e848d42b88a1a488b45905 refs/tags/v1.10.5
|
||||||
|
a06a89cbd11026aa3910fadd1eff7fe388d02507 refs/tags/v1.10.5^{}
|
||||||
|
44ae0f54fc9230dfa849726139317733c969c365 refs/tags/v1.10.6
|
||||||
|
b7756d92501a7b8ba8e77d77d9d3718a58425beb refs/tags/v1.10.6^{}
|
||||||
|
b73ca6db2654551a8055003aead61ad45d4c9c5f refs/tags/v1.10.7
|
||||||
|
5b08469b874553744bd5c5b1fa6581f4dcffacd0 refs/tags/v1.10.7^{}
|
||||||
|
34f81a6985533ade66f222b81537b5427d614ca1 refs/tags/v1.10.8
|
||||||
|
c72562524b2b9aaca0be372bb24343158829ba5a refs/tags/v1.10.8^{}
|
||||||
|
c50c31c006b9c7b4ebab69964182c30e7a020545 refs/tags/v1.10.9
|
||||||
|
99070fa6073c4415a6faf8ca69dd6aa089af4062 refs/tags/v1.10.9^{}
|
||||||
|
57a6a7527c81fdbdaa9cabc0de32ea239fc77642 refs/tags/v1.11.0
|
||||||
|
c7fdce5d3b7566a7d290627767c47d9c196e02ad refs/tags/v1.11.0^{}
|
||||||
|
5a5c0374e77bfe05867d24e47d032c98e5cf3fde refs/tags/v1.11.1
|
||||||
|
3f9164ea77ec41e1b0671d0a642900d8e36faf9b refs/tags/v1.11.1^{}
|
||||||
|
978241b9d367e9d2b5e4a01a76babb3854eaa9c8 refs/tags/v1.11.2
|
||||||
|
bed694fcf5c8c31bbd4f3e88759fe7ab82382d24 refs/tags/v1.11.2^{}
|
||||||
|
c79fe15ca31741f8ba40308152557279b1a4a9c9 refs/tags/v1.11.3
|
||||||
|
ee7ff9a09d3373f60ae1645376ccc0057803147e refs/tags/v1.11.3^{}
|
||||||
|
279b0cb778381bc8e8ca0d842116f0694793101c refs/tags/v1.11.4
|
||||||
|
07b179cd7f8853ff6aca0b27a703e198c158ca72 refs/tags/v1.11.4^{}
|
||||||
|
22aed2d43f3a0196a8588a9b2e0a20fe9162fb2b refs/tags/v1.11.5
|
||||||
|
2af61730f0f5b9bc6f1f4c5d9d808ff6ccb0faeb refs/tags/v1.11.5^{}
|
||||||
|
5dea7ffda62fc9bc605444bb58361fba523fd26b refs/tags/v1.11.6
|
||||||
|
d0d7254c6acc7be4341618d231a5b166f640b287 refs/tags/v1.11.6^{}
|
||||||
|
0a2221b6fb4f2a83f99d0364eb46d268dc6d0576 refs/tags/v1.11.7
|
||||||
|
d20b795137036f8b889eb231cb4f14b756ec6479 refs/tags/v1.11.7^{}
|
||||||
|
2af89405635505d3ad8c3313f1f037018d4e6840 refs/tags/v1.11.8
|
||||||
|
de3b91a36cfcaf565b26b1da42f1e87835da4dc3 refs/tags/v1.11.8^{}
|
||||||
|
4b784c04f4ecf71b484a7e8c66fbefd82c219aee refs/tags/v1.12.0
|
||||||
|
ffb3a0ee5fb30a3f61d6cbedf877ab04acdbf624 refs/tags/v1.12.0^{}
|
||||||
|
4d9cebff16bb9bfca9477dbac20d0c8b48afdda3 refs/tags/v1.12.1
|
||||||
|
34ed772775f1f02ed148f24a3bfff532bc811607 refs/tags/v1.12.1^{}
|
||||||
|
a97c8eefd0fc830d0cb7a2b36a41fb61df9452be refs/tags/v1.13.0
|
||||||
|
032cda8b3db096b690d2557e3b918c50c716c543 refs/tags/v1.13.0^{}
|
||||||
|
1d2feb42517aa4efc1337a9837bacc19ec7d8dec refs/tags/v1.13.1
|
||||||
|
339238ab364d8735892a11cb16a62a651edae169 refs/tags/v1.13.1^{}
|
||||||
|
9b4880c39522965de02daabfd647c1f22433be58 refs/tags/v1.13.2
|
||||||
|
e30a75e25c4b43969bf9f874f89e18512a5e3a34 refs/tags/v1.13.2^{}
|
||||||
|
5075a9b7752e82d706868320346ea7ba75aecd0d refs/tags/v1.13.3
|
||||||
|
5c538816cf76686bac1a86a7c06e24664d25a2dc refs/tags/v1.13.3^{}
|
||||||
|
cae0e57b32f6324fdd6f92d3c0d9b14d378013da refs/tags/v1.13.4
|
||||||
|
5344883394a0662ee16bb5edd68df8e4410025f6 refs/tags/v1.13.4^{}
|
||||||
|
37c3d8d2ea57a7f21efac7a72942310c570d959f refs/tags/v1.14.0
|
||||||
|
9e3b88727cd439e15f235dddb9dd5796e010797a refs/tags/v1.14.0^{}
|
||||||
|
999b4c4468048a07198a44b0eb56ca3397fa113a refs/tags/v1.14.1
|
||||||
|
3c25839350800c7e7d2c48fc032bb21efa0ac213 refs/tags/v1.14.1^{}
|
||||||
|
97a3bc99175cffe62b710f640e8de4d9087fd269 refs/tags/v1.14.2
|
||||||
|
87b506dc9b4831d11b4fd04fd6849532db074f90 refs/tags/v1.14.2^{}
|
||||||
|
7746edaa7175f4b9da2333ab0a5c49cab71e959e refs/tags/v1.14.3
|
||||||
|
fb723ae8bd7bb51f9a4bab380ec1bc54cda0445b refs/tags/v1.14.3^{}
|
||||||
|
15196cb46637418943d66ef39e45289906db4f98 refs/tags/v1.14.4
|
||||||
|
1e18dd30a824b0463f0cad86e0da7094c47d34f9 refs/tags/v1.14.4^{}
|
||||||
|
49ec8ce6acc6993f1f755320f7ff5528e373d9ed refs/tags/v1.15.0
|
||||||
|
5285e699c30fdeaf56068f5a03ef1d1d33fa673c refs/tags/v1.15.0^{}
|
||||||
|
e043a1e1496ef0a1129e14fd2b453fd070ae4c52 refs/tags/v1.15.1
|
||||||
|
6c838460752c7131f75cdab2da07266fee492060 refs/tags/v1.15.1^{}
|
||||||
|
0152c26cb8c0da1526b287fe949fa299d6ba59bc refs/tags/v1.15.2
|
||||||
|
fcc7e5294973d1a18943fa2ce2e836b0fe757d95 refs/tags/v1.15.2^{}
|
||||||
|
c3d5d92f87d7c0a2d67aef926caf0072a0caab2d refs/tags/v1.15.3
|
||||||
|
fd7861db11e5aaa17c4e7bbce942c0c096116e30 refs/tags/v1.15.3^{}
|
||||||
|
260661d53da9f08b731a87e2d302266b4c3fdef5 refs/tags/v1.15.4
|
||||||
|
773b7f4b1f23e04c90e602aab05bc1a7e5aae37b refs/tags/v1.15.4^{}
|
||||||
|
48de1293a0167366a14b5fde21436314e7c4574b refs/tags/v1.15.5
|
||||||
|
572548b42fb6ed9d32a392503d44fac1a8f146d3 refs/tags/v1.15.5^{}
|
||||||
|
3c19f4c6e26e5954f57dcbc81fcfab52e5ee486d refs/tags/v1.15.6
|
||||||
|
3b22ce41105387e7f46a410460cf04759feef197 refs/tags/v1.15.6^{}
|
||||||
|
5df24c1861d76c5d9ca05d405a9d322ae0a2b474 refs/tags/v1.16.0
|
||||||
|
c5b7aaca25d6b66d3e44256c2c6760a4cf2956ec refs/tags/v1.16.0^{}
|
||||||
|
948302dcd3349d76e8fc11682e0aa920c11872e6 refs/tags/v1.16.1
|
||||||
|
834e52369ceb479776ddc8fc2931790af53b9c18 refs/tags/v1.16.1^{}
|
||||||
|
53847835a919262ca497906613c7bca5d0957753 refs/tags/v1.16.2
|
||||||
|
ab482e521d4cecfffa5393805b1d7de4389db49a refs/tags/v1.16.2^{}
|
||||||
|
aca99f9944c0f759505fb9eb65d8fe3cf81cbda2 refs/tags/v1.17.0
|
||||||
|
73e5ea98c1ca2b9299085e3832791162eca3b9ff refs/tags/v1.17.0^{}
|
||||||
|
d443374208e241b52b8cb5875454cb690e289c1d refs/tags/v1.17.1
|
||||||
|
b59e38cfd2c8a7f5868e05d5562557b1c27e5e56 refs/tags/v1.17.1^{}
|
||||||
|
0f230bf425ca9547f2e4231e0eb4afa22371f451 refs/tags/v1.17.2
|
||||||
|
597d39c28ea0c0fe3b072413e9d91ab5e27b62bd refs/tags/v1.17.2^{}
|
||||||
|
a7de9111d97e687cafbc0709ec3ff7453d658a80 refs/tags/v1.17.3
|
||||||
|
a73d0d26cbe2860b8374661068e09e0717a3bab2 refs/tags/v1.17.4
|
||||||
|
d753e71a7452310d45fa605a2e4c70320ed60dbb refs/tags/v1.17.5
|
||||||
|
0ee244756bf39123e4873eb231156edbe7f0e0ec refs/tags/v1.17.6
|
||||||
|
70cb4453bebb235130e2c287633ecb1de6c2b0aa refs/tags/v1.17.7
|
||||||
|
6e7b6afe87355e96422bb2560ffcbd5e79d28f04 refs/tags/v1.18.0
|
||||||
|
8e6a31d3da19926ac46744e02b27a899ca5fbd7c refs/tags/v1.18.1
|
||||||
|
681176e4c958157ef1f2151b3e57963a6ba48e09 refs/tags/v1.18.2
|
||||||
|
2f7c03eb35520be916c28a687031f8c6425839ba refs/tags/v1.18.3
|
||||||
|
6afb1d389ca9dfd7880386d380fee032b7eb92e2 refs/tags/v1.18.4
|
||||||
|
727fc9a701e9aae75d3d2b708010da1d0dc8781a refs/tags/v1.18.5
|
||||||
|
e05be3f08beae1b600fc55a3a7b4e28163e15bc0 refs/tags/v1.18.6
|
||||||
|
fecb2193ae6a939e70294841782cff106c675adb refs/tags/v1.18.7
|
||||||
|
4f8c1a2ca2cb4c81938973f54c08bb4fa5f146c1 refs/tags/v1.18.8
|
||||||
|
c12b48537a7a0f7d47cd655940ab7ba091a78243 refs/tags/v1.19.0
|
||||||
|
776ee66baef425517b8c9e4ba39a25539bf6673c refs/tags/v1.20.0
|
||||||
|
7fd67fda136b99e68dba4cf56c31b042e7217870 refs/tags/v1.20.1
|
||||||
|
9b33a50bb0a034a792d1dfdbb7d2e0cdeae72c96 refs/tags/v1.20.2
|
||||||
|
2683dbb20a2f30afbd9c007b4af600a1eae59a2e refs/tags/v1.20.3
|
||||||
|
e2f1b16cb9e920968c093bd1f371b191aa7107bf refs/tags/v1.20.4
|
||||||
|
37835c197268d98736e5f253a763cd4fe4e95274 refs/tags/v1.21.0
|
||||||
|
ea78b389c950c6f54a9f2ccd446d3314cbf77804 refs/tags/v1.21.1
|
||||||
|
f1383b5c66538db858b0de0bf1197d47353c0f29 refs/tags/v1.21.2
|
||||||
|
b877cc9509b9828a13e4513c8241164e2fc9b37c refs/tags/v1.22.0
|
||||||
|
81ea83064ce380515b804e40f403c599a376f00a refs/tags/v1.22.1
|
||||||
|
3c3fb6dc6dd64d268e23c72a08b177ceb97dd78f refs/tags/v1.5.1
|
||||||
|
9c1b8bacf9a59a86feb2a91eb44919e800491d1e refs/tags/v1.5.1^{}
|
||||||
|
33a55c4230623266dd0ca0020191c7602ce4d435 refs/tags/v1.6.1
|
||||||
|
4de8f42664379570392552796e34324abb39fdc2 refs/tags/v1.6.1^{}
|
||||||
|
21cbe50c30bd4d2322f6653419e06e1bd1c90416 refs/tags/v1.7.1
|
||||||
|
77d334f7f386f79ec0571325500054fdab207f31 refs/tags/v1.7.1^{}
|
||||||
|
5701feb36c13cda4db303435bbb3cf397816c559 refs/tags/v1.7.3
|
||||||
|
c2450b27b079b02ed3f4ece9e36547f01cd4b139 refs/tags/v1.7.3^{}
|
||||||
|
5c9ab693385d307876f95e7a9adbb27086418b31 refs/tags/v1.7.4
|
||||||
|
ddabfaa05c63f886b17e5b4d37cd83fcfdb9b221 refs/tags/v1.7.4^{}
|
||||||
|
b13e31474fa4f981091a4ffed4be66f753fb9af9 refs/tags/v1.7.5
|
||||||
|
53ee2c36310cb84390ef96644aee6871769151c9 refs/tags/v1.7.5^{}
|
||||||
|
a4723556f1e589cc1a8cc10a2964b8b78bcbf562 refs/tags/v1.8.0
|
||||||
|
4989445ef4bb8919d9b3b95e2fcee77ca7692aec refs/tags/v1.8.0^{}
|
||||||
|
94a757689a05cfe6fb3473494ec21e27a37080e4 refs/tags/v1.8.1
|
||||||
|
f0528ea83112e71ff51c89be27fc9bbdfbbf1951 refs/tags/v1.8.1^{}
|
||||||
|
a6bba1dcb183a487c9d99bd7c6d0c991eadcbea5 refs/tags/v1.9.0
|
||||||
|
400f5a44ece280cb0097d806b78a9490d2905600 refs/tags/v1.9.0^{}
|
||||||
|
e2b1099e4288597f2e2f0140433e77c5478831ce refs/tags/v1.9.1
|
||||||
|
e5bea9ae3b0a70b38f7da7dd9184343dbbd18887 refs/tags/v1.9.1^{}
|
||||||
|
8299d4c9dac5943d4f393241e60ead586a5f162d refs/tags/v1.9.2
|
||||||
|
8ec8cd62944c59c462ab9f520c1dcfd14218b1ed refs/tags/v1.9.2^{}
|
||||||
|
1848db2562c1a22f439538daff3a167ccb8603e2 refs/tags/v1.9.3
|
||||||
|
6b4ba662317629839aa62fbcfefb8ed3337c37ef refs/tags/v1.9.3^{}
|
1
tests/fixtures/generic/sshd-T-2.json
vendored
Normal file
1
tests/fixtures/generic/sshd-T-2.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"port":[22],"addressfamily":"any","listenaddress":["[::]:22","0.0.0.0:22"],"usepam":"yes","logingracetime":120,"x11displayoffset":10,"x11maxdisplays":1000,"maxauthtries":6,"maxsessions":10,"clientaliveinterval":0,"clientalivecountmax":3,"streamlocalbindmask":"0177","permitrootlogin":"yes","ignorerhosts":"yes","ignoreuserknownhosts":"no","hostbasedauthentication":"no","hostbasedusesnamefrompacketonly":"no","pubkeyauthentication":"yes","kerberosauthentication":"no","kerberosorlocalpasswd":"yes","kerberosticketcleanup":"yes","gssapiauthentication":"yes","gssapicleanupcredentials":"no","gssapikeyexchange":"no","gssapistrictacceptorcheck":"yes","gssapistorecredentialsonrekey":"no","gssapikexalgorithms":["gss-gex-sha1-","gss-group1-sha1-","gss-group14-sha1-"],"passwordauthentication":"yes","kbdinteractiveauthentication":"no","challengeresponseauthentication":"no","printmotd":"yes","printlastlog":"yes","x11forwarding":"yes","x11uselocalhost":"yes","permittty":"yes","permituserrc":"yes","strictmodes":"yes","tcpkeepalive":"yes","permitemptypasswords":"no","permituserenvironment":"no","compression":"yes","gatewayports":"no","showpatchlevel":"no","usedns":"yes","allowtcpforwarding":"yes","allowagentforwarding":"yes","disableforwarding":"no","allowstreamlocalforwarding":"yes","streamlocalbindunlink":"no","useprivilegeseparation":"sandbox","kerberosusekuserok":"yes","gssapienablek5users":"no","exposeauthenticationmethods":"never","fingerprinthash":"SHA256","pidfile":"/var/run/sshd.pid","xauthlocation":"/usr/bin/xauth","ciphers":["chacha20-poly1305@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr","aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-cbc","aes192-cbc","aes256-cbc","blowfish-cbc","cast128-cbc","3des-cbc"],"macs":["umac-64-etm@openssh.com","umac-128-etm@openssh.com","hmac-sha2-256-etm@openssh.com","hmac-sha2-512-etm@openssh.com","hmac-sha1-etm@openssh.com","umac-64@openssh.com","umac-128@openssh.com","hmac-sha2-256","hmac-sha2-512","hmac-sha1"],"banner":"none","forcecommand":"none","chrootdirectory":"none","trustedusercakeys":"none","revokedkeys":"none","authorizedprincipalsfile":"none","versionaddendum":"none","authorizedkeyscommand":"none","authorizedkeyscommanduser":"none","authorizedprincipalscommand":"none","authorizedprincipalscommanduser":"none","hostkeyagent":"none","kexalgorithms":["curve25519-sha256","curve25519-sha256@libssh.org","ecdh-sha2-nistp256","ecdh-sha2-nistp384","ecdh-sha2-nistp521","diffie-hellman-group-exchange-sha256","diffie-hellman-group16-sha512","diffie-hellman-group18-sha512","diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha256","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"],"hostbasedacceptedkeytypes":["ecdsa-sha2-nistp256-cert-v01@openssh.com","ecdsa-sha2-nistp384-cert-v01@openssh.com","ecdsa-sha2-nistp521-cert-v01@openssh.com","ssh-ed25519-cert-v01@openssh.com","ssh-rsa-cert-v01@openssh.com","ssh-dss-cert-v01@openssh.com","ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","ssh-ed25519","rsa-sha2-512","rsa-sha2-256","ssh-rsa","ssh-dss"],"hostkeyalgorithms":["ecdsa-sha2-nistp256-cert-v01@openssh.com","ecdsa-sha2-nistp384-cert-v01@openssh.com","ecdsa-sha2-nistp521-cert-v01@openssh.com","ssh-ed25519-cert-v01@openssh.com","ssh-rsa-cert-v01@openssh.com","ssh-dss-cert-v01@openssh.com","ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","ssh-ed25519","rsa-sha2-512","rsa-sha2-256","ssh-rsa","ssh-dss"],"pubkeyacceptedkeytypes":["ecdsa-sha2-nistp256-cert-v01@openssh.com","ecdsa-sha2-nistp384-cert-v01@openssh.com","ecdsa-sha2-nistp521-cert-v01@openssh.com","ssh-ed25519-cert-v01@openssh.com","ssh-rsa-cert-v01@openssh.com","ssh-dss-cert-v01@openssh.com","ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","ssh-ed25519","rsa-sha2-512","rsa-sha2-256","ssh-rsa","ssh-dss"],"loglevel":"INFO","syslogfacility":"AUTHPRIV","authorizedkeysfile":[".ssh/authorized_keys"],"hostkey":["/etc/ssh/ssh_host_rsa_key","/etc/ssh/ssh_host_ecdsa_key","/etc/ssh/ssh_host_ed25519_key"],"acceptenv":["LANG","LC_CTYPE","LC_NUMERIC","LC_TIME","LC_COLLATE","LC_MONETARY","LC_MESSAGES","LC_PAPER","LC_NAME","LC_ADDRESS","LC_TELEPHONE","LC_MEASUREMENT","LC_IDENTIFICATION","LC_ALL","LANGUAGE","XMODIFIERS"],"authenticationmethods":"any","subsystem":"sftp","maxstartups":10,"permittunnel":"no","ipqos":["lowdelay","throughput"],"rekeylimit":0,"permitopen":["any"],"subsystem_command":"/usr/libexec/openssh/sftp-server","maxstartups_rate":30,"maxstartups_full":100,"rekeylimit_time":0}
|
104
tests/fixtures/generic/sshd-T-2.out
vendored
Normal file
104
tests/fixtures/generic/sshd-T-2.out
vendored
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
port 22
|
||||||
|
addressfamily any
|
||||||
|
listenaddress [::]:22
|
||||||
|
listenaddress 0.0.0.0:22
|
||||||
|
usepam yes
|
||||||
|
logingracetime 120
|
||||||
|
x11displayoffset 10
|
||||||
|
x11maxdisplays 1000
|
||||||
|
maxauthtries 6
|
||||||
|
maxsessions 10
|
||||||
|
clientaliveinterval 0
|
||||||
|
clientalivecountmax 3
|
||||||
|
streamlocalbindmask 0177
|
||||||
|
permitrootlogin yes
|
||||||
|
ignorerhosts yes
|
||||||
|
ignoreuserknownhosts no
|
||||||
|
hostbasedauthentication no
|
||||||
|
hostbasedusesnamefrompacketonly no
|
||||||
|
pubkeyauthentication yes
|
||||||
|
kerberosauthentication no
|
||||||
|
kerberosorlocalpasswd yes
|
||||||
|
kerberosticketcleanup yes
|
||||||
|
gssapiauthentication yes
|
||||||
|
gssapicleanupcredentials no
|
||||||
|
gssapikeyexchange no
|
||||||
|
gssapistrictacceptorcheck yes
|
||||||
|
gssapistorecredentialsonrekey no
|
||||||
|
gssapikexalgorithms gss-gex-sha1-,gss-group1-sha1-,gss-group14-sha1-
|
||||||
|
passwordauthentication yes
|
||||||
|
kbdinteractiveauthentication no
|
||||||
|
challengeresponseauthentication no
|
||||||
|
printmotd yes
|
||||||
|
printlastlog yes
|
||||||
|
x11forwarding yes
|
||||||
|
x11uselocalhost yes
|
||||||
|
permittty yes
|
||||||
|
permituserrc yes
|
||||||
|
strictmodes yes
|
||||||
|
tcpkeepalive yes
|
||||||
|
permitemptypasswords no
|
||||||
|
permituserenvironment no
|
||||||
|
compression yes
|
||||||
|
gatewayports no
|
||||||
|
showpatchlevel no
|
||||||
|
usedns yes
|
||||||
|
allowtcpforwarding yes
|
||||||
|
allowagentforwarding yes
|
||||||
|
disableforwarding no
|
||||||
|
allowstreamlocalforwarding yes
|
||||||
|
streamlocalbindunlink no
|
||||||
|
useprivilegeseparation sandbox
|
||||||
|
kerberosusekuserok yes
|
||||||
|
gssapienablek5users no
|
||||||
|
exposeauthenticationmethods never
|
||||||
|
fingerprinthash SHA256
|
||||||
|
pidfile /var/run/sshd.pid
|
||||||
|
xauthlocation /usr/bin/xauth
|
||||||
|
ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
|
||||||
|
macs umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
|
||||||
|
banner none
|
||||||
|
forcecommand none
|
||||||
|
chrootdirectory none
|
||||||
|
trustedusercakeys none
|
||||||
|
revokedkeys none
|
||||||
|
authorizedprincipalsfile none
|
||||||
|
versionaddendum none
|
||||||
|
authorizedkeyscommand none
|
||||||
|
authorizedkeyscommanduser none
|
||||||
|
authorizedprincipalscommand none
|
||||||
|
authorizedprincipalscommanduser none
|
||||||
|
hostkeyagent none
|
||||||
|
kexalgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
|
||||||
|
hostbasedacceptedkeytypes ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss
|
||||||
|
hostkeyalgorithms ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss
|
||||||
|
pubkeyacceptedkeytypes ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss
|
||||||
|
loglevel INFO
|
||||||
|
syslogfacility AUTHPRIV
|
||||||
|
authorizedkeysfile .ssh/authorized_keys
|
||||||
|
hostkey /etc/ssh/ssh_host_rsa_key
|
||||||
|
hostkey /etc/ssh/ssh_host_ecdsa_key
|
||||||
|
hostkey /etc/ssh/ssh_host_ed25519_key
|
||||||
|
acceptenv LANG
|
||||||
|
acceptenv LC_CTYPE
|
||||||
|
acceptenv LC_NUMERIC
|
||||||
|
acceptenv LC_TIME
|
||||||
|
acceptenv LC_COLLATE
|
||||||
|
acceptenv LC_MONETARY
|
||||||
|
acceptenv LC_MESSAGES
|
||||||
|
acceptenv LC_PAPER
|
||||||
|
acceptenv LC_NAME
|
||||||
|
acceptenv LC_ADDRESS
|
||||||
|
acceptenv LC_TELEPHONE
|
||||||
|
acceptenv LC_MEASUREMENT
|
||||||
|
acceptenv LC_IDENTIFICATION
|
||||||
|
acceptenv LC_ALL
|
||||||
|
acceptenv LANGUAGE
|
||||||
|
acceptenv XMODIFIERS
|
||||||
|
authenticationmethods any
|
||||||
|
subsystem sftp /usr/libexec/openssh/sftp-server
|
||||||
|
maxstartups 10:30:100
|
||||||
|
permittunnel no
|
||||||
|
ipqos lowdelay throughput
|
||||||
|
rekeylimit 0 0
|
||||||
|
permitopen any
|
1
tests/fixtures/generic/sshd-T.json
vendored
Normal file
1
tests/fixtures/generic/sshd-T.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"acceptenv":["LANG","LC_*","test1","test2"],"addressfamily":"any","allowagentforwarding":"yes","allowstreamlocalforwarding":"yes","allowtcpforwarding":"yes","authenticationmethods":"any","authorizedkeyscommand":"none","authorizedkeyscommanduser":"none","authorizedkeysfile":[".ssh/authorized_keys",".ssh/authorized_keys2"],"authorizedprincipalscommand":"none","authorizedprincipalscommanduser":"none","authorizedprincipalsfile":"none","banner":"none","casignaturealgorithms":["ssh-ed25519","ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","sk-ssh-ed25519@openssh.com","sk-ecdsa-sha2-nistp256@openssh.com","rsa-sha2-512","rsa-sha2-256"],"chrootdirectory":"none","ciphers":["chacha20-poly1305@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr","aes128-gcm@openssh.com","aes256-gcm@openssh.com"],"ciphers_strategy":"+","clientalivecountmax":3,"clientaliveinterval":0,"compression":"yes","disableforwarding":"no","exposeauthinfo":"no","fingerprinthash":"SHA256","forcecommand":"none","gatewayports":"no","gssapiauthentication":"no","gssapicleanupcredentials":"yes","gssapikexalgorithms":["gss-group14-sha256-","gss-group16-sha512-","gss-nistp256-sha256-","gss-curve25519-sha256-","gss-group14-sha1-","gss-gex-sha1-"],"gssapikeyexchange":"no","gssapistorecredentialsonrekey":"no","gssapistrictacceptorcheck":"yes","hostbasedacceptedalgorithms":["ssh-ed25519-cert-v01@openssh.com","ecdsa-sha2-nistp256-cert-v01@openssh.com","ecdsa-sha2-nistp384-cert-v01@openssh.com","ecdsa-sha2-nistp521-cert-v01@openssh.com","sk-ssh-ed25519-cert-v01@openssh.com","sk-ecdsa-sha2-nistp256-cert-v01@openssh.com","rsa-sha2-512-cert-v01@openssh.com","rsa-sha2-256-cert-v01@openssh.com","ssh-ed25519","ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","sk-ssh-ed25519@openssh.com","sk-ecdsa-sha2-nistp256@openssh.com","rsa-sha2-512","rsa-sha2-256"],"hostbasedauthentication":"no","hostbasedusesnamefrompacketonly":"no","hostkeyagent":"none","hostkeyalgorithms":["ssh-ed25519-cert-v01@openssh.com","ecdsa-sha2-nistp256-cert-v01@openssh.com","ecdsa-sha2-nistp384-cert-v01@openssh.com","ecdsa-sha2-nistp521-cert-v01@openssh.com","sk-ssh-ed25519-cert-v01@openssh.com","sk-ecdsa-sha2-nistp256-cert-v01@openssh.com","rsa-sha2-512-cert-v01@openssh.com","rsa-sha2-256-cert-v01@openssh.com","ssh-ed25519","ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","sk-ssh-ed25519@openssh.com","sk-ecdsa-sha2-nistp256@openssh.com","rsa-sha2-512","rsa-sha2-256"],"hostkey":["/etc/ssh/ssh_host_ecdsa_key","/etc/ssh/ssh_host_ed25519_key","/etc/ssh/ssh_host_rsa_key"],"ignorerhosts":"yes","ignoreuserknownhosts":"no","ipqos":["lowdelay","throughput"],"kbdinteractiveauthentication":"no","kerberosauthentication":"no","kerberosorlocalpasswd":"yes","kerberosticketcleanup":"yes","kexalgorithms":["sntrup761x25519-sha512@openssh.com","curve25519-sha256","curve25519-sha256@libssh.org","ecdh-sha2-nistp256","ecdh-sha2-nistp384","ecdh-sha2-nistp521","diffie-hellman-group-exchange-sha256","diffie-hellman-group16-sha512","diffie-hellman-group18-sha512","diffie-hellman-group14-sha256"],"listenaddress":["0.0.0.0:22","[::]:22"],"logingracetime":120,"loglevel":"INFO","macs":["umac-64-etm@openssh.com","umac-128-etm@openssh.com","hmac-sha2-256-etm@openssh.com","hmac-sha2-512-etm@openssh.com","hmac-sha1-etm@openssh.com","umac-64@openssh.com","umac-128@openssh.com","hmac-sha2-256","hmac-sha2-512","hmac-sha1"],"macs_strategy":"^","maxauthtries":6,"maxsessions":10,"maxstartups":10,"modulifile":"/etc/ssh/moduli","passwordauthentication":"yes","permitemptypasswords":"no","permitlisten":["any"],"permitopen":["any"],"permitrootlogin":"without-password","permittty":"yes","permittunnel":"no","permituserenvironment":"no","permituserrc":"yes","persourcemaxstartups":"none","persourcenetblocksize":"32:128","pidfile":"/run/sshd.pid","port":[22],"printlastlog":"yes","printmotd":"no","pubkeyacceptedalgorithms":["ssh-ed25519-cert-v01@openssh.com","ecdsa-sha2-nistp256-cert-v01@openssh.com","ecdsa-sha2-nistp384-cert-v01@openssh.com","ecdsa-sha2-nistp521-cert-v01@openssh.com","sk-ssh-ed25519-cert-v01@openssh.com","sk-ecdsa-sha2-nistp256-cert-v01@openssh.com","rsa-sha2-512-cert-v01@openssh.com","rsa-sha2-256-cert-v01@openssh.com","ssh-ed25519","ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","sk-ssh-ed25519@openssh.com","sk-ecdsa-sha2-nistp256@openssh.com","rsa-sha2-512","rsa-sha2-256"],"pubkeyauthentication":"yes","pubkeyauthoptions":"none","rekeylimit":0,"revokedkeys":"none","securitykeyprovider":"internal","streamlocalbindmask":"0177","streamlocalbindunlink":"no","strictmodes":"yes","subsystem":"sftp","syslogfacility":"AUTH","tcpkeepalive":"yes","trustedusercakeys":"none","usedns":"no","usepam":"yes","versionaddendum":"none","x11displayoffset":10,"x11forwarding":"yes","x11uselocalhost":"yes","xauthlocation":"/usr/bin/xauth","maxstartups_rate":30,"maxstartups_full":100,"rekeylimit_time":0,"subsystem_command":"/usr/lib/openssh/sftp-server"}
|
92
tests/fixtures/generic/sshd-T.out
vendored
Normal file
92
tests/fixtures/generic/sshd-T.out
vendored
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
acceptenv LANG
|
||||||
|
acceptenv LC_*
|
||||||
|
acceptenv test1 test2
|
||||||
|
addressfamily any
|
||||||
|
allowagentforwarding yes
|
||||||
|
allowstreamlocalforwarding yes
|
||||||
|
allowtcpforwarding yes
|
||||||
|
authenticationmethods any
|
||||||
|
authorizedkeyscommand none
|
||||||
|
authorizedkeyscommanduser none
|
||||||
|
authorizedkeysfile .ssh/authorized_keys .ssh/authorized_keys2
|
||||||
|
authorizedprincipalscommand none
|
||||||
|
authorizedprincipalscommanduser none
|
||||||
|
authorizedprincipalsfile none
|
||||||
|
banner none
|
||||||
|
casignaturealgorithms ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256
|
||||||
|
chrootdirectory none
|
||||||
|
ciphers +chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
|
||||||
|
clientalivecountmax 3
|
||||||
|
clientaliveinterval 0
|
||||||
|
compression yes
|
||||||
|
disableforwarding no
|
||||||
|
exposeauthinfo no
|
||||||
|
fingerprinthash SHA256
|
||||||
|
forcecommand none
|
||||||
|
gatewayports no
|
||||||
|
gssapiauthentication no
|
||||||
|
gssapicleanupcredentials yes
|
||||||
|
gssapikexalgorithms gss-group14-sha256-,gss-group16-sha512-,gss-nistp256-sha256-,gss-curve25519-sha256-,gss-group14-sha1-,gss-gex-sha1-
|
||||||
|
gssapikeyexchange no
|
||||||
|
gssapistorecredentialsonrekey no
|
||||||
|
gssapistrictacceptorcheck yes
|
||||||
|
hostbasedacceptedalgorithms ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256
|
||||||
|
hostbasedauthentication no
|
||||||
|
hostbasedusesnamefrompacketonly no
|
||||||
|
hostkeyagent none
|
||||||
|
hostkeyalgorithms ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256
|
||||||
|
hostkey /etc/ssh/ssh_host_ecdsa_key
|
||||||
|
hostkey /etc/ssh/ssh_host_ed25519_key
|
||||||
|
hostkey /etc/ssh/ssh_host_rsa_key
|
||||||
|
ignorerhosts yes
|
||||||
|
ignoreuserknownhosts no
|
||||||
|
ipqos lowdelay throughput
|
||||||
|
kbdinteractiveauthentication no
|
||||||
|
kerberosauthentication no
|
||||||
|
kerberosorlocalpasswd yes
|
||||||
|
kerberosticketcleanup yes
|
||||||
|
kexalgorithms sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
|
||||||
|
listenaddress 0.0.0.0:22
|
||||||
|
listenaddress [::]:22
|
||||||
|
logingracetime 120
|
||||||
|
loglevel INFO
|
||||||
|
macs ^umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
|
||||||
|
maxauthtries 6
|
||||||
|
maxsessions 10
|
||||||
|
maxstartups 10:30:100
|
||||||
|
modulifile /etc/ssh/moduli
|
||||||
|
passwordauthentication yes
|
||||||
|
permitemptypasswords no
|
||||||
|
permitlisten any
|
||||||
|
permitopen any
|
||||||
|
permitrootlogin without-password
|
||||||
|
permittty yes
|
||||||
|
permittunnel no
|
||||||
|
permituserenvironment no
|
||||||
|
permituserrc yes
|
||||||
|
persourcemaxstartups none
|
||||||
|
persourcenetblocksize 32:128
|
||||||
|
pidfile /run/sshd.pid
|
||||||
|
port 22
|
||||||
|
printlastlog yes
|
||||||
|
printmotd no
|
||||||
|
pubkeyacceptedalgorithms ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256
|
||||||
|
pubkeyauthentication yes
|
||||||
|
pubkeyauthoptions none
|
||||||
|
rekeylimit 0 0
|
||||||
|
revokedkeys none
|
||||||
|
securitykeyprovider internal
|
||||||
|
streamlocalbindmask 0177
|
||||||
|
streamlocalbindunlink no
|
||||||
|
strictmodes yes
|
||||||
|
subsystem sftp /usr/lib/openssh/sftp-server
|
||||||
|
syslogfacility AUTH
|
||||||
|
tcpkeepalive yes
|
||||||
|
trustedusercakeys none
|
||||||
|
usedns no
|
||||||
|
usepam yes
|
||||||
|
versionaddendum none
|
||||||
|
x11displayoffset 10
|
||||||
|
x11forwarding yes
|
||||||
|
x11uselocalhost yes
|
||||||
|
xauthlocation /usr/bin/xauth
|
155
tests/fixtures/generic/sshd_config
vendored
Normal file
155
tests/fixtures/generic/sshd_config
vendored
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
Include foo/bar foo/baz
|
||||||
|
Include foo/buz
|
||||||
|
|
||||||
|
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
|
||||||
|
|
||||||
|
# This is the sshd server system-wide configuration file. See
|
||||||
|
# sshd_config(5) for more information.
|
||||||
|
|
||||||
|
# This sshd was compiled with PATH=/usr/local/bin:/usr/bin
|
||||||
|
|
||||||
|
# The strategy used for options in the default sshd_config shipped with
|
||||||
|
# OpenSSH is to specify options with their default value where
|
||||||
|
# possible, but leave them commented. Uncommented options override the
|
||||||
|
# default value.
|
||||||
|
|
||||||
|
# If you want to change the port on a SELinux system, you have to tell
|
||||||
|
# SELinux about this change.
|
||||||
|
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
|
||||||
|
#
|
||||||
|
Port 22
|
||||||
|
AddressFamily any
|
||||||
|
ListenAddress 0.0.0.0
|
||||||
|
ListenAddress ::
|
||||||
|
|
||||||
|
Match group chroot
|
||||||
|
this should be ignored
|
||||||
|
this line too should be ignored
|
||||||
|
|
||||||
|
keep ignoring
|
||||||
|
Match all
|
||||||
|
|
||||||
|
HostKey /etc/ssh/ssh_host_rsa_key
|
||||||
|
#HostKey /etc/ssh/ssh_host_dsa_key
|
||||||
|
HostKey /etc/ssh/ssh_host_ecdsa_key
|
||||||
|
|
||||||
|
Match group anything
|
||||||
|
ignore this
|
||||||
|
don't look at this
|
||||||
|
Match all
|
||||||
|
|
||||||
|
HostKey /etc/ssh/ssh_host_ed25519_key
|
||||||
|
|
||||||
|
# Ciphers and keying
|
||||||
|
#RekeyLimit default none
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
#SyslogFacility AUTH
|
||||||
|
SyslogFacility AUTHPRIV
|
||||||
|
#LogLevel INFO
|
||||||
|
|
||||||
|
# Authentication:
|
||||||
|
|
||||||
|
#LoginGraceTime 2m
|
||||||
|
#PermitRootLogin yes
|
||||||
|
#StrictModes yes
|
||||||
|
#MaxAuthTries 6
|
||||||
|
#MaxSessions 10
|
||||||
|
|
||||||
|
#PubkeyAuthentication yes
|
||||||
|
|
||||||
|
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
|
||||||
|
# but this is overridden so installations will only check .ssh/authorized_keys
|
||||||
|
AuthorizedKeysFile .ssh/authorized_keys
|
||||||
|
|
||||||
|
#AuthorizedPrincipalsFile none
|
||||||
|
|
||||||
|
#AuthorizedKeysCommand none
|
||||||
|
#AuthorizedKeysCommandUser nobody
|
||||||
|
|
||||||
|
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
|
||||||
|
#HostbasedAuthentication no
|
||||||
|
# Change to yes if you don't trust ~/.ssh/known_hosts for
|
||||||
|
# HostbasedAuthentication
|
||||||
|
#IgnoreUserKnownHosts no
|
||||||
|
# Don't read the user's ~/.rhosts and ~/.shosts files
|
||||||
|
#IgnoreRhosts yes
|
||||||
|
|
||||||
|
# To disable tunneled clear text passwords, change to no here!
|
||||||
|
#PasswordAuthentication yes
|
||||||
|
#PermitEmptyPasswords no
|
||||||
|
PasswordAuthentication yes
|
||||||
|
|
||||||
|
# Change to no to disable s/key passwords
|
||||||
|
#ChallengeResponseAuthentication yes
|
||||||
|
ChallengeResponseAuthentication no
|
||||||
|
|
||||||
|
# Kerberos options
|
||||||
|
#KerberosAuthentication no
|
||||||
|
#KerberosOrLocalPasswd yes
|
||||||
|
#KerberosTicketCleanup yes
|
||||||
|
#KerberosGetAFSToken no
|
||||||
|
#KerberosUseKuserok yes
|
||||||
|
|
||||||
|
# GSSAPI options
|
||||||
|
GSSAPIAuthentication yes
|
||||||
|
GSSAPICleanupCredentials no
|
||||||
|
#GSSAPIStrictAcceptorCheck yes
|
||||||
|
#GSSAPIKeyExchange no
|
||||||
|
#GSSAPIEnablek5users no
|
||||||
|
|
||||||
|
# Set this to 'yes' to enable PAM authentication, account processing,
|
||||||
|
# and session processing. If this is enabled, PAM authentication will
|
||||||
|
# be allowed through the ChallengeResponseAuthentication and
|
||||||
|
# PasswordAuthentication. Depending on your PAM configuration,
|
||||||
|
# PAM authentication via ChallengeResponseAuthentication may bypass
|
||||||
|
# the setting of "PermitRootLogin without-password".
|
||||||
|
# If you just want the PAM account and session checks to run without
|
||||||
|
# PAM authentication, then enable this but set PasswordAuthentication
|
||||||
|
# and ChallengeResponseAuthentication to 'no'.
|
||||||
|
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
|
||||||
|
# problems.
|
||||||
|
UsePAM yes
|
||||||
|
|
||||||
|
#AllowAgentForwarding yes
|
||||||
|
#AllowTcpForwarding yes
|
||||||
|
#GatewayPorts no
|
||||||
|
X11Forwarding yes
|
||||||
|
#X11DisplayOffset 10
|
||||||
|
#X11UseLocalhost yes
|
||||||
|
#PermitTTY yes
|
||||||
|
#PrintMotd yes
|
||||||
|
#PrintLastLog yes
|
||||||
|
#TCPKeepAlive yes
|
||||||
|
#UseLogin no
|
||||||
|
#UsePrivilegeSeparation sandbox
|
||||||
|
#PermitUserEnvironment no
|
||||||
|
#Compression delayed
|
||||||
|
#ClientAliveInterval 0
|
||||||
|
#ClientAliveCountMax 3
|
||||||
|
#ShowPatchLevel no
|
||||||
|
#UseDNS yes
|
||||||
|
#PidFile /var/run/sshd.pid
|
||||||
|
#MaxStartups 10:30:100
|
||||||
|
#PermitTunnel no
|
||||||
|
#ChrootDirectory none
|
||||||
|
#VersionAddendum none
|
||||||
|
|
||||||
|
# no default banner path
|
||||||
|
#Banner none
|
||||||
|
|
||||||
|
# Accept locale-related environment variables
|
||||||
|
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
|
||||||
|
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
|
||||||
|
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
|
||||||
|
AcceptEnv XMODIFIERS
|
||||||
|
|
||||||
|
# override default of no subsystems
|
||||||
|
Subsystem sftp /usr/libexec/openssh/sftp-server
|
||||||
|
|
||||||
|
# Example of overriding settings on a per-user basis
|
||||||
|
#Match User anoncvs
|
||||||
|
# X11Forwarding no
|
||||||
|
# AllowTcpForwarding no
|
||||||
|
# PermitTTY no
|
||||||
|
# ForceCommand cvs server
|
1
tests/fixtures/generic/sshd_config.json
vendored
Normal file
1
tests/fixtures/generic/sshd_config.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"include":["foo/bar","foo/baz","foo/buz"],"port":[22],"addressfamily":"any","listenaddress":["0.0.0.0","::"],"hostkey":["/etc/ssh/ssh_host_rsa_key","/etc/ssh/ssh_host_ecdsa_key","/etc/ssh/ssh_host_ed25519_key"],"syslogfacility":"AUTHPRIV","authorizedkeysfile":[".ssh/authorized_keys"],"passwordauthentication":"yes","challengeresponseauthentication":"no","gssapiauthentication":"yes","gssapicleanupcredentials":"no","usepam":"yes","x11forwarding":"yes","acceptenv":["LANG","LC_CTYPE","LC_NUMERIC","LC_TIME","LC_COLLATE","LC_MONETARY","LC_MESSAGES","LC_PAPER","LC_NAME","LC_ADDRESS","LC_TELEPHONE","LC_MEASUREMENT","LC_IDENTIFICATION","LC_ALL","LANGUAGE","XMODIFIERS"],"subsystem":"sftp","subsystem_command":"/usr/libexec/openssh/sftp-server"}
|
1
tests/fixtures/generic/xml-nmap-raw.json
vendored
Normal file
1
tests/fixtures/generic/xml-nmap-raw.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"nmaprun":{"_scanner":"nmap","_args":"nmap -oX - -p 443 galaxy.ansible.com","_start":"1666781498","_startstr":"Wed Oct 26 11:51:38 2022","_version":"7.92","_xmloutputversion":"1.05","scaninfo":{"_type":"connect","_protocol":"tcp","_numservices":"1","_services":"443"},"verbose":{"_level":"0"},"debugging":{"_level":"0"},"hosthint":{"status":{"_state":"up","_reason":"unknown-response","_reason_ttl":"0"},"address":{"_addr":"172.67.68.251","_addrtype":"ipv4"},"hostnames":{"hostname":{"_name":"galaxy.ansible.com","_type":"user"}}},"host":{"_starttime":"1666781498","_endtime":"1666781498","status":{"_state":"up","_reason":"syn-ack","_reason_ttl":"0"},"address":{"_addr":"172.67.68.251","_addrtype":"ipv4"},"hostnames":{"hostname":[{"_name":"galaxy.ansible.com","_type":"user"},{"_name":"galaxy.ansible.com","_type":"PTR"}]},"ports":{"port":{"_protocol":"tcp","_portid":"443","state":{"_state":"open","_reason":"syn-ack","_reason_ttl":"0"},"service":{"_name":"https","_method":"table","_conf":"3"}}},"times":{"_srtt":"12260","_rttvar":"9678","_to":"100000"}},"runstats":{"finished":{"_time":"1666781498","_timestr":"Wed Oct 26 11:51:38 2022","_summary":"Nmap done at Wed Oct 26 11:51:38 2022; 1 IP address (1 host up) scanned in 0.10 seconds","_elapsed":"0.10","_exit":"success"},"hosts":{"_up":"1","_down":"0","_total":"1"}}}}
|
1
tests/fixtures/generic/xml-nmap.json
vendored
Normal file
1
tests/fixtures/generic/xml-nmap.json
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"nmaprun":{"@scanner":"nmap","@args":"nmap -oX - -p 443 galaxy.ansible.com","@start":"1666781498","@startstr":"Wed Oct 26 11:51:38 2022","@version":"7.92","@xmloutputversion":"1.05","scaninfo":{"@type":"connect","@protocol":"tcp","@numservices":"1","@services":"443"},"verbose":{"@level":"0"},"debugging":{"@level":"0"},"hosthint":{"status":{"@state":"up","@reason":"unknown-response","@reason_ttl":"0"},"address":{"@addr":"172.67.68.251","@addrtype":"ipv4"},"hostnames":{"hostname":{"@name":"galaxy.ansible.com","@type":"user"}}},"host":{"@starttime":"1666781498","@endtime":"1666781498","status":{"@state":"up","@reason":"syn-ack","@reason_ttl":"0"},"address":{"@addr":"172.67.68.251","@addrtype":"ipv4"},"hostnames":{"hostname":[{"@name":"galaxy.ansible.com","@type":"user"},{"@name":"galaxy.ansible.com","@type":"PTR"}]},"ports":{"port":{"@protocol":"tcp","@portid":"443","state":{"@state":"open","@reason":"syn-ack","@reason_ttl":"0"},"service":{"@name":"https","@method":"table","@conf":"3"}}},"times":{"@srtt":"12260","@rttvar":"9678","@to":"100000"}},"runstats":{"finished":{"@time":"1666781498","@timestr":"Wed Oct 26 11:51:38 2022","@summary":"Nmap done at Wed Oct 26 11:51:38 2022; 1 IP address (1 host up) scanned in 0.10 seconds","@elapsed":"0.10","@exit":"success"},"hosts":{"@up":"1","@down":"0","@total":"1"}}}}
|
36
tests/fixtures/generic/xml-nmap.xml
vendored
Normal file
36
tests/fixtures/generic/xml-nmap.xml
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE nmaprun>
|
||||||
|
<?xml-stylesheet href="file:///usr/bin/../share/nmap/nmap.xsl" type="text/xsl"?>
|
||||||
|
<!-- Nmap 7.92 scan initiated Wed Oct 26 11:51:38 2022 as: nmap -oX - -p 443 galaxy.ansible.com -->
|
||||||
|
<nmaprun scanner="nmap" args="nmap -oX - -p 443 galaxy.ansible.com" start="1666781498" startstr="Wed Oct 26 11:51:38 2022" version="7.92" xmloutputversion="1.05">
|
||||||
|
<scaninfo type="connect" protocol="tcp" numservices="1" services="443"/>
|
||||||
|
<verbose level="0"/>
|
||||||
|
<debugging level="0"/>
|
||||||
|
<hosthint>
|
||||||
|
<status state="up" reason="unknown-response" reason_ttl="0"/>
|
||||||
|
<address addr="172.67.68.251" addrtype="ipv4"/>
|
||||||
|
<hostnames>
|
||||||
|
<hostname name="galaxy.ansible.com" type="user"/>
|
||||||
|
</hostnames>
|
||||||
|
</hosthint>
|
||||||
|
<host starttime="1666781498" endtime="1666781498">
|
||||||
|
<status state="up" reason="syn-ack" reason_ttl="0"/>
|
||||||
|
<address addr="172.67.68.251" addrtype="ipv4"/>
|
||||||
|
<hostnames>
|
||||||
|
<hostname name="galaxy.ansible.com" type="user"/>
|
||||||
|
<hostname name="galaxy.ansible.com" type="PTR"/>
|
||||||
|
</hostnames>
|
||||||
|
<ports>
|
||||||
|
<port protocol="tcp" portid="443">
|
||||||
|
<state state="open" reason="syn-ack" reason_ttl="0"/>
|
||||||
|
<service name="https" method="table" conf="3"/>
|
||||||
|
</port>
|
||||||
|
</ports>
|
||||||
|
<times srtt="12260" rttvar="9678" to="100000"/>
|
||||||
|
</host>
|
||||||
|
<runstats>
|
||||||
|
<finished time="1666781498" timestr="Wed Oct 26 11:51:38 2022" summary="Nmap done at Wed Oct 26 11:51:38 2022; 1 IP address (1 host up) scanned in 0.10 seconds" elapsed="0.10" exit="success"/>
|
||||||
|
<hosts up="1" down="0" total="1"/>
|
||||||
|
</runstats>
|
||||||
|
</nmaprun>
|
||||||
|
|
2
tests/fixtures/osx-10.11.6/ifconfig.json
vendored
2
tests/fixtures/osx-10.11.6/ifconfig.json
vendored
@ -1 +1 @@
|
|||||||
[{"name": "lo0", "flags": 8049, "state": ["UP", "LOOPBACK", "RUNNING", "MULTICAST"], "mtu": 16384, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "fe80::1", "ipv6_mask": 64, "ipv6_scope": "0x1", "type": null, "mac_addr": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "gif0", "flags": 8010, "state": ["POINTOPOINT", "MULTICAST"], "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "stf0", "flags": 0, "state": null, "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "ipv4_addr": "192.168.1.81", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.1.255", "ipv6_addr": "fe80::6aa8:6dff:fe12:f575", "ipv6_mask": 64, "ipv6_scope": "0x4", "mac_addr": "68:a8:6d:12:f5:75", "type": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en1", "flags": 963, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "PROMISC", "SIMPLEX"], "mtu": 1500, "mac_addr": "b2:00:19:cb:f5:50", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "p2p0", "flags": 8843, "state": ["UP", "BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 2304, "mac_addr": "0a:a8:6d:12:f5:75", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "bridge0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "mac_addr": "6a:a8:6d:21:38:00", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}]
|
[{"name":"lo0","flags":8049,"state":["UP","LOOPBACK","RUNNING","MULTICAST"],"mtu":16384,"type":null,"mac_addr":null,"ipv4_addr":"127.0.0.1","ipv4_mask":"255.0.0.0","ipv4_bcast":null,"ipv6_addr":"fe80::1","ipv6_mask":64,"ipv6_scope":"0x1","ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"options":"3","options_flags":["RXCSUM","TXCSUM"],"nd6_options":1,"nd6_flags":["PERFORMNUD"],"ipv4":[{"address":"127.0.0.1","mask":"255.0.0.0","broadcast":null}],"ipv6":[{"address":"fe80::1","mask":64,"scope":"0x1"}]},{"name":"gif0","flags":8010,"state":["POINTOPOINT","MULTICAST"],"mtu":1280,"type":null,"mac_addr":null,"ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null},{"name":"stf0","flags":0,"state":null,"mtu":1280,"type":null,"mac_addr":null,"ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null},{"name":"en0","flags":8863,"state":["UP","BROADCAST","SMART","RUNNING","SIMPLEX","MULTICAST"],"mtu":1500,"type":null,"mac_addr":"68:a8:6d:12:f5:75","ipv4_addr":"192.168.1.81","ipv4_mask":"255.255.255.0","ipv4_bcast":"192.168.1.255","ipv6_addr":"fe80::6aa8:6dff:fe12:f575","ipv6_mask":64,"ipv6_scope":"0x4","ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"nd6_options":1,"nd6_flags":["PERFORMNUD"],"status":"active","ipv4":[{"address":"192.168.1.81","mask":"255.255.255.0","broadcast":"192.168.1.255"}],"ipv6":[{"address":"fe80::6aa8:6dff:fe12:f575","mask":64,"scope":"0x4"}]},{"name":"en1","flags":963,"state":["UP","BROADCAST","SMART","RUNNING","PROMISC","SIMPLEX"],"mtu":1500,"type":null,"mac_addr":"b2:00:19:cb:f5:50","ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"options":"60","options_flags":["TSO4","TSO6"],"media":"autoselect","media_flags":["full-duplex"],"status":"inactive"},{"name":"p2p0","flags":8843,"state":["UP","BROADCAST","RUNNING","SIMPLEX","MULTICAST"],"mtu":2304,"type":null,"mac_addr":"0a:a8:6d:12:f5:75","ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"status":"inactive"},{"name":"bridge0","flags":8863,"state":["UP","BROADCAST","SMART","RUNNING","SIMPLEX","MULTICAST"],"mtu":1500,"type":null,"mac_addr":"6a:a8:6d:21:38:00","ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"options":"63","options_flags":["RXCSUM","TXCSUM","TSO4","TSO6"],"nd6_options":1,"nd6_flags":["PERFORMNUD"],"status":"inactive"}]
|
||||||
|
2
tests/fixtures/osx-10.11.6/ifconfig2.json
vendored
2
tests/fixtures/osx-10.11.6/ifconfig2.json
vendored
@ -1 +1 @@
|
|||||||
[{"name": "lo0", "flags": 8049, "state": ["UP", "LOOPBACK", "RUNNING", "MULTICAST"], "mtu": 16384, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "fe80::1", "ipv6_mask": 64, "ipv6_scope": "0x1", "type": null, "mac_addr": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "gif0", "flags": 8010, "state": ["POINTOPOINT", "MULTICAST"], "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "stf0", "flags": 0, "state": null, "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "ipv4_addr": "192.168.1.65", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.1.255", "ipv6_addr": "fe80::62c5:47ff:fe0a:ce0b", "ipv6_mask": 64, "ipv6_scope": "0x4", "mac_addr": "60:c5:47:0a:ce:0b", "type": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en1", "flags": 963, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "PROMISC", "SIMPLEX"], "mtu": 1500, "mac_addr": "b2:00:14:06:39:21", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "p2p0", "flags": 8843, "state": ["UP", "BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 2304, "mac_addr": "02:c5:47:0a:ce:0b", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "bridge0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "mac_addr": "62:c5:47:a0:f7:10", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}]
|
[{"name":"lo0","flags":8049,"state":["UP","LOOPBACK","RUNNING","MULTICAST"],"mtu":16384,"type":null,"mac_addr":null,"ipv4_addr":"127.0.0.1","ipv4_mask":"255.0.0.0","ipv4_bcast":null,"ipv6_addr":"fe80::1","ipv6_mask":64,"ipv6_scope":"0x1","ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"options":"3","options_flags":["RXCSUM","TXCSUM"],"nd6_options":1,"nd6_flags":["PERFORMNUD"],"ipv4":[{"address":"127.0.0.1","mask":"255.0.0.0","broadcast":null}],"ipv6":[{"address":"fe80::1","mask":64,"scope":"0x1"}]},{"name":"gif0","flags":8010,"state":["POINTOPOINT","MULTICAST"],"mtu":1280,"type":null,"mac_addr":null,"ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null},{"name":"stf0","flags":0,"state":null,"mtu":1280,"type":null,"mac_addr":null,"ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null},{"name":"en0","flags":8863,"state":["UP","BROADCAST","SMART","RUNNING","SIMPLEX","MULTICAST"],"mtu":1500,"type":null,"mac_addr":"60:c5:47:0a:ce:0b","ipv4_addr":"192.168.1.65","ipv4_mask":"255.255.255.0","ipv4_bcast":"192.168.1.255","ipv6_addr":"fe80::62c5:47ff:fe0a:ce0b","ipv6_mask":64,"ipv6_scope":"0x4","ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"nd6_options":1,"nd6_flags":["PERFORMNUD"],"status":"active","ipv4":[{"address":"192.168.1.65","mask":"255.255.255.0","broadcast":"192.168.1.255"}],"ipv6":[{"address":"fe80::62c5:47ff:fe0a:ce0b","mask":64,"scope":"0x4"}]},{"name":"en1","flags":963,"state":["UP","BROADCAST","SMART","RUNNING","PROMISC","SIMPLEX"],"mtu":1500,"type":null,"mac_addr":"b2:00:14:06:39:21","ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"options":"60","options_flags":["TSO4","TSO6"],"media":"autoselect","media_flags":["full-duplex"],"status":"inactive"},{"name":"p2p0","flags":8843,"state":["UP","BROADCAST","RUNNING","SIMPLEX","MULTICAST"],"mtu":2304,"type":null,"mac_addr":"02:c5:47:0a:ce:0b","ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"status":"inactive"},{"name":"bridge0","flags":8863,"state":["UP","BROADCAST","SMART","RUNNING","SIMPLEX","MULTICAST"],"mtu":1500,"type":null,"mac_addr":"62:c5:47:a0:f7:10","ipv4_addr":null,"ipv4_mask":null,"ipv4_bcast":null,"ipv6_addr":null,"ipv6_mask":null,"ipv6_scope":null,"ipv6_type":null,"metric":null,"rx_packets":null,"rx_errors":null,"rx_dropped":null,"rx_overruns":null,"rx_frame":null,"tx_packets":null,"tx_errors":null,"tx_dropped":null,"tx_overruns":null,"tx_carrier":null,"tx_collisions":null,"rx_bytes":null,"tx_bytes":null,"options":"63","options_flags":["RXCSUM","TXCSUM","TSO4","TSO6"],"nd6_options":1,"nd6_flags":["PERFORMNUD"],"status":"inactive"}]
|
||||||
|
2
tests/fixtures/osx-10.14.6/ifconfig.json
vendored
2
tests/fixtures/osx-10.14.6/ifconfig.json
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/osx-10.14.6/ifconfig2.json
vendored
2
tests/fixtures/osx-10.14.6/ifconfig2.json
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/ubuntu-18.04/ifconfig.json
vendored
2
tests/fixtures/ubuntu-18.04/ifconfig.json
vendored
@ -1 +1 @@
|
|||||||
[{"name": "ens33", "flags": 4163, "state": ["UP", "BROADCAST", "RUNNING", "MULTICAST"], "mtu": 1500, "ipv4_addr": "192.168.71.131", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.71.255", "ipv6_addr": "fe80::20c:29ff:fe99:4517", "ipv6_mask": 64, "ipv6_scope": "0x20", "mac_addr": "00:0c:29:99:45:17", "type": "Ethernet", "rx_packets": 138830, "rx_bytes": 178583682, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 30490, "tx_bytes": 3772041, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}, {"name": "lo", "flags": 73, "state": ["UP", "LOOPBACK", "RUNNING"], "mtu": 65536, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "::1", "ipv6_mask": 128, "ipv6_scope": "0x10", "mac_addr": null, "type": "Local Loopback", "rx_packets": 825, "rx_bytes": 76797, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 825, "tx_bytes": 76797, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}]
|
[{"name":"ens33","flags":4163,"state":["UP","BROADCAST","RUNNING","MULTICAST"],"mtu":1500,"ipv4_addr":"192.168.71.131","ipv4_mask":"255.255.255.0","ipv4_bcast":"192.168.71.255","ipv6_addr":"fe80::20c:29ff:fe99:4517","ipv6_mask":64,"ipv6_scope":"0x20","ipv6_type":"link","mac_addr":"00:0c:29:99:45:17","type":"Ethernet","rx_packets":138830,"rx_bytes":178583682,"rx_errors":0,"rx_dropped":0,"rx_overruns":0,"rx_frame":0,"tx_packets":30490,"tx_bytes":3772041,"tx_errors":0,"tx_dropped":0,"tx_overruns":0,"tx_carrier":0,"tx_collisions":0,"metric":null,"ipv4":[{"address":"192.168.71.131","mask":"255.255.255.0","broadcast":"192.168.71.255"}],"ipv6":[{"address":"fe80::20c:29ff:fe99:4517","mask":64,"scope":"0x20","type":"link"}]},{"name":"lo","flags":73,"state":["UP","LOOPBACK","RUNNING"],"mtu":65536,"ipv4_addr":"127.0.0.1","ipv4_mask":"255.0.0.0","ipv4_bcast":null,"ipv6_addr":"::1","ipv6_mask":128,"ipv6_scope":"0x10","ipv6_type":"host","mac_addr":null,"type":"Local Loopback","rx_packets":825,"rx_bytes":76797,"rx_errors":0,"rx_dropped":0,"rx_overruns":0,"rx_frame":0,"tx_packets":825,"tx_bytes":76797,"tx_errors":0,"tx_dropped":0,"tx_overruns":0,"tx_carrier":0,"tx_collisions":0,"metric":null,"ipv4":[{"address":"127.0.0.1","mask":"255.0.0.0","broadcast":null}],"ipv6":[{"address":"::1","mask":128,"scope":"0x10","type":"host"}]}]
|
||||||
|
@ -2,7 +2,7 @@ import os
|
|||||||
import unittest
|
import unittest
|
||||||
import json
|
import json
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
import jc.parsers.foo
|
from jc.parsers.foo import parse
|
||||||
|
|
||||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
@ -30,14 +30,17 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
Test 'foo' with no data
|
Test 'foo' with no data
|
||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.foo.parse('', quiet=True), [])
|
self.assertEqual(parse('', quiet=True), [])
|
||||||
|
|
||||||
|
|
||||||
def test_foo_centos_7_7(self):
|
def test_foo_centos_7_7(self):
|
||||||
"""
|
"""
|
||||||
Test 'foo' on Centos 7.7
|
Test 'foo' on Centos 7.7
|
||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.foo.parse(self.f_in['centos_7_7_foo'], quiet=True),
|
self.assertEqual(parse(
|
||||||
self.f_json['centos_7_7_foo'])
|
self.f_in['centos_7_7_foo'], quiet=True),
|
||||||
|
self.f_json['centos_7_7_foo']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -2,7 +2,7 @@ import os
|
|||||||
import json
|
import json
|
||||||
import unittest
|
import unittest
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
import jc.parsers.foo_s
|
from jc.parsers.foo_s import parse
|
||||||
|
|
||||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
@ -33,14 +33,17 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
Test 'foo' with no data
|
Test 'foo' with no data
|
||||||
"""
|
"""
|
||||||
self.assertEqual(list(jc.parsers.foo_s.parse([], quiet=True)), [])
|
self.assertEqual(list(parse([], quiet=True)), [])
|
||||||
|
|
||||||
|
|
||||||
def test_foo_s_centos_7_7(self):
|
def test_foo_s_centos_7_7(self):
|
||||||
"""
|
"""
|
||||||
Test 'foo' on Centos 7.7
|
Test 'foo' on Centos 7.7
|
||||||
"""
|
"""
|
||||||
self.assertEqual(list(jc.parsers.foo_s.parse(self.f_in['centos_7_7_foo'].splitlines(), quiet=True)),
|
self.assertEqual(
|
||||||
self.f_json['centos_7_7_foo'])
|
list(parse(self.f_in['centos_7_7_foo'].splitlines(), quiet=True)),
|
||||||
|
self.f_json['centos_7_7_foo']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -36,8 +36,11 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-insurance.csv'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-insurance.csv'), 'r', encoding='utf-8') as f:
|
||||||
generic_csv_insurance = f.read()
|
generic_csv_insurance = f.read()
|
||||||
|
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-doubleqouted.csv'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-doublequoted.csv'), 'r', encoding='utf-8') as f:
|
||||||
generic_csv_doubleqouted = f.read()
|
generic_csv_doublequoted = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-utf-8-bom.csv'), 'r', encoding='utf-8') as f:
|
||||||
|
generic_csv_utf8_bom = f.read()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-biostats.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-biostats.json'), 'r', encoding='utf-8') as f:
|
||||||
@ -67,8 +70,11 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-insurance.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-insurance.json'), 'r', encoding='utf-8') as f:
|
||||||
generic_csv_insurance_json = json.loads(f.read())
|
generic_csv_insurance_json = json.loads(f.read())
|
||||||
|
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-doubleqouted.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-doublequoted.json'), 'r', encoding='utf-8') as f:
|
||||||
generic_csv_doubleqouted_json = json.loads(f.read())
|
generic_csv_doublequoted_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-utf-8-bom.json'), 'r', encoding='utf-8') as f:
|
||||||
|
generic_csv_utf8_bom_json = json.loads(f.read())
|
||||||
|
|
||||||
|
|
||||||
def test_csv_nodata(self):
|
def test_csv_nodata(self):
|
||||||
@ -131,11 +137,17 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.csv.parse(self.generic_csv_insurance, quiet=True), self.generic_csv_insurance_json)
|
self.assertEqual(jc.parsers.csv.parse(self.generic_csv_insurance, quiet=True), self.generic_csv_insurance_json)
|
||||||
|
|
||||||
def test_doubleqouted(self):
|
def test_csv_doublequoted(self):
|
||||||
"""
|
"""
|
||||||
Test 'csv-doubleqouted.csv' file
|
Test 'csv-doublequoted.csv' file
|
||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.csv.parse(self.generic_csv_doubleqouted, quiet=True), self.generic_csv_doubleqouted_json)
|
self.assertEqual(jc.parsers.csv.parse(self.generic_csv_doublequoted, quiet=True), self.generic_csv_doublequoted_json)
|
||||||
|
|
||||||
|
def test_csv_utf8_bom(self):
|
||||||
|
"""
|
||||||
|
Test 'csv-utf-8-bom.csv' file to ensure the first column is correct if UTF-8 BOM bytes are present
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.csv.parse(self.generic_csv_utf8_bom, quiet=True), self.generic_csv_utf8_bom_json)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -41,8 +41,11 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-10k-sales-records.csv'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-10k-sales-records.csv'), 'r', encoding='utf-8') as f:
|
||||||
generic_csv_10k_sales_records = f.read()
|
generic_csv_10k_sales_records = f.read()
|
||||||
|
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-doubleqouted.csv'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-doublequoted.csv'), 'r', encoding='utf-8') as f:
|
||||||
generic_csv_doubleqouted = f.read()
|
generic_csv_doublequoted = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-utf-8-bom.csv'), 'r', encoding='utf-8') as f:
|
||||||
|
generic_csv_utf8_bom = f.read()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-biostats-streaming.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-biostats-streaming.json'), 'r', encoding='utf-8') as f:
|
||||||
@ -72,9 +75,12 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-10k-sales-records-streaming.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-10k-sales-records-streaming.json'), 'r', encoding='utf-8') as f:
|
||||||
generic_csv_10k_sales_records_streaming_json = json.loads(f.read())
|
generic_csv_10k_sales_records_streaming_json = json.loads(f.read())
|
||||||
|
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-doubleqouted-streaming.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-doublequoted-streaming.json'), 'r', encoding='utf-8') as f:
|
||||||
generic_csv_doublequoted_streaming_json = json.loads(f.read())
|
generic_csv_doublequoted_streaming_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-utf-8-bom-streaming.json'), 'r', encoding='utf-8') as f:
|
||||||
|
generic_csv_utf8_bom_streaming_json = json.loads(f.read())
|
||||||
|
|
||||||
|
|
||||||
def test_csv_s_nodata(self):
|
def test_csv_s_nodata(self):
|
||||||
"""
|
"""
|
||||||
@ -151,7 +157,13 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
Test 'doublequoted.csv' file
|
Test 'doublequoted.csv' file
|
||||||
"""
|
"""
|
||||||
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_doubleqouted.splitlines(), quiet=True)), self.generic_csv_doublequoted_streaming_json)
|
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_doublequoted.splitlines(), quiet=True)), self.generic_csv_doublequoted_streaming_json)
|
||||||
|
|
||||||
|
def test_csv_s_utf8_bom(self):
|
||||||
|
"""
|
||||||
|
Test 'csv-utf-8-bom.csv' file to ensure the first column is correct if UTF-8 BOM bytes are present
|
||||||
|
"""
|
||||||
|
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_utf8_bom.splitlines(), quiet=True)), self.generic_csv_utf8_bom_streaming_json)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
70
tests/test_findmnt.py
Normal file
70
tests/test_findmnt.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
import json
|
||||||
|
from typing import Dict
|
||||||
|
from jc.parsers.findmnt import parse
|
||||||
|
|
||||||
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
class MyTests(unittest.TestCase):
|
||||||
|
f_in: Dict = {}
|
||||||
|
f_json: Dict = {}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
fixtures = {
|
||||||
|
'centos_7_7_findmnt': (
|
||||||
|
'fixtures/centos-7.7/findmnt.out',
|
||||||
|
'fixtures/centos-7.7/findmnt.json'),
|
||||||
|
'centos_7_7_findmnt_a': (
|
||||||
|
'fixtures/centos-7.7/findmnt-a.out',
|
||||||
|
'fixtures/centos-7.7/findmnt-a.json'),
|
||||||
|
'centos_7_7_findmnt_l': (
|
||||||
|
'fixtures/centos-7.7/findmnt-l.out',
|
||||||
|
'fixtures/centos-7.7/findmnt-l.json')
|
||||||
|
}
|
||||||
|
|
||||||
|
for file, filepaths in fixtures.items():
|
||||||
|
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||||
|
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||||
|
cls.f_in[file] = a.read()
|
||||||
|
cls.f_json[file] = json.loads(b.read())
|
||||||
|
|
||||||
|
|
||||||
|
def test_findmnt_nodata(self):
|
||||||
|
"""
|
||||||
|
Test 'findmnt' with no data
|
||||||
|
"""
|
||||||
|
self.assertEqual(parse('', quiet=True), [])
|
||||||
|
|
||||||
|
def test_findmnt_centos_7_7(self):
|
||||||
|
"""
|
||||||
|
Test 'findmnt' on Centos 7.7
|
||||||
|
"""
|
||||||
|
self.assertEqual(
|
||||||
|
parse(self.f_in['centos_7_7_findmnt'], quiet=True),
|
||||||
|
self.f_json['centos_7_7_findmnt']
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_findmnt_a_centos_7_7(self):
|
||||||
|
"""
|
||||||
|
Test 'findmnt -a' on Centos 7.7
|
||||||
|
"""
|
||||||
|
self.assertEqual(
|
||||||
|
parse(self.f_in['centos_7_7_findmnt_a'], quiet=True),
|
||||||
|
self.f_json['centos_7_7_findmnt_a']
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_findmnt_l_centos_7_7(self):
|
||||||
|
"""
|
||||||
|
Test 'findmnt -l' on Centos 7.7
|
||||||
|
"""
|
||||||
|
self.assertEqual(
|
||||||
|
parse(self.f_in['centos_7_7_findmnt_l'], quiet=True),
|
||||||
|
self.f_json['centos_7_7_findmnt_l']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
58
tests/test_git_ls_remote.py
Normal file
58
tests/test_git_ls_remote.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
import json
|
||||||
|
from typing import Dict
|
||||||
|
from jc.parsers.git_ls_remote import parse
|
||||||
|
|
||||||
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
class MyTests(unittest.TestCase):
|
||||||
|
f_in: Dict = {}
|
||||||
|
f_json: Dict = {}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
fixtures = {
|
||||||
|
'git_ls_remote': (
|
||||||
|
'fixtures/generic/git-ls-remote.out',
|
||||||
|
'fixtures/generic/git-ls-remote.json'),
|
||||||
|
'git_ls_remote_raw': (
|
||||||
|
'fixtures/generic/git-ls-remote.out',
|
||||||
|
'fixtures/generic/git-ls-remote-raw.json')
|
||||||
|
}
|
||||||
|
|
||||||
|
for file, filepaths in fixtures.items():
|
||||||
|
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||||
|
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||||
|
cls.f_in[file] = a.read()
|
||||||
|
cls.f_json[file] = json.loads(b.read())
|
||||||
|
|
||||||
|
|
||||||
|
def test_git_ls_remote_nodata(self):
|
||||||
|
"""
|
||||||
|
Test 'git_ls_remote' with no data
|
||||||
|
"""
|
||||||
|
self.assertEqual(parse('', quiet=True), {})
|
||||||
|
|
||||||
|
def test_git_ls_remote(self):
|
||||||
|
"""
|
||||||
|
Test 'git_ls_remote'
|
||||||
|
"""
|
||||||
|
self.assertEqual(parse(
|
||||||
|
self.f_in['git_ls_remote'], quiet=True),
|
||||||
|
self.f_json['git_ls_remote']
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_git_ls_remote_raw(self):
|
||||||
|
"""
|
||||||
|
Test 'git_ls_remote' with raw option
|
||||||
|
"""
|
||||||
|
self.assertEqual(parse(
|
||||||
|
self.f_in['git_ls_remote_raw'], quiet=True, raw=True),
|
||||||
|
self.f_json['git_ls_remote_raw']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -27,6 +27,15 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/ifconfig2.out'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/ifconfig2.out'), 'r', encoding='utf-8') as f:
|
||||||
osx_10_14_6_ifconfig2 = f.read()
|
osx_10_14_6_ifconfig2 = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/ifconfig-extra-fields.out'), 'r', encoding='utf-8') as f:
|
||||||
|
osx_freebsd12_ifconfig_extra_fields = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/ifconfig-extra-fields2.out'), 'r', encoding='utf-8') as f:
|
||||||
|
osx_freebsd12_ifconfig_extra_fields2 = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/ifconfig-extra-fields3.out'), 'r', encoding='utf-8') as f:
|
||||||
|
osx_freebsd12_ifconfig_extra_fields3 = f.read()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/ifconfig.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/ifconfig.json'), 'r', encoding='utf-8') as f:
|
||||||
centos_7_7_ifconfig_json = json.loads(f.read())
|
centos_7_7_ifconfig_json = json.loads(f.read())
|
||||||
@ -46,6 +55,15 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/ifconfig2.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/ifconfig2.json'), 'r', encoding='utf-8') as f:
|
||||||
osx_10_14_6_ifconfig2_json = json.loads(f.read())
|
osx_10_14_6_ifconfig2_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/ifconfig-extra-fields.json'), 'r', encoding='utf-8') as f:
|
||||||
|
freebsd12_ifconfig_extra_fields_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/ifconfig-extra-fields2.json'), 'r', encoding='utf-8') as f:
|
||||||
|
freebsd12_ifconfig_extra_fields2_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/freebsd12/ifconfig-extra-fields3.json'), 'r', encoding='utf-8') as f:
|
||||||
|
freebsd12_ifconfig_extra_fields3_json = json.loads(f.read())
|
||||||
|
|
||||||
def test_ifconfig_nodata(self):
|
def test_ifconfig_nodata(self):
|
||||||
"""
|
"""
|
||||||
Test 'ifconfig' with no data
|
Test 'ifconfig' with no data
|
||||||
@ -88,6 +106,23 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.ifconfig.parse(self.osx_10_14_6_ifconfig2, quiet=True), self.osx_10_14_6_ifconfig2_json)
|
self.assertEqual(jc.parsers.ifconfig.parse(self.osx_10_14_6_ifconfig2, quiet=True), self.osx_10_14_6_ifconfig2_json)
|
||||||
|
|
||||||
|
def test_ifconfig_freebsd_extra_fields(self):
|
||||||
|
"""
|
||||||
|
Test 'ifconfig' on freebsd12
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.ifconfig.parse(self.osx_freebsd12_ifconfig_extra_fields, quiet=True), self.freebsd12_ifconfig_extra_fields_json)
|
||||||
|
|
||||||
|
def test_ifconfig_freebsd_extra_fields2(self):
|
||||||
|
"""
|
||||||
|
Test 'ifconfig' on freebsd12 with other fields
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.ifconfig.parse(self.osx_freebsd12_ifconfig_extra_fields2, quiet=True), self.freebsd12_ifconfig_extra_fields2_json)
|
||||||
|
|
||||||
|
def test_ifconfig_freebsd_extra_fields3(self):
|
||||||
|
"""
|
||||||
|
Test 'ifconfig' on freebsd12 with other extra fields
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.ifconfig.parse(self.osx_freebsd12_ifconfig_extra_fields3, quiet=True), self.freebsd12_ifconfig_extra_fields3_json)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
47
tests/test_os_prober.py
Normal file
47
tests/test_os_prober.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
import json
|
||||||
|
from typing import Dict
|
||||||
|
from jc.parsers.os_prober import parse
|
||||||
|
|
||||||
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
class MyTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_os_prober_nodata(self):
|
||||||
|
"""
|
||||||
|
Test 'os_prober' with no data
|
||||||
|
"""
|
||||||
|
self.assertEqual(parse('', quiet=True), {})
|
||||||
|
|
||||||
|
def test_os_prober_1(self):
|
||||||
|
"""
|
||||||
|
Test 'os_prober' 1
|
||||||
|
"""
|
||||||
|
self.assertEqual(parse(
|
||||||
|
'/dev/sda1:Windows 7 (loader):Windows:chain', quiet=True),
|
||||||
|
{"partition":"/dev/sda1","name":"Windows 7 (loader)","short_name":"Windows","type":"chain"}
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_os_prober_2(self):
|
||||||
|
"""
|
||||||
|
Test 'os_prober' 2
|
||||||
|
"""
|
||||||
|
self.assertEqual(parse(
|
||||||
|
'/dev/sda1:Windows 10:Windows:chain', quiet=True),
|
||||||
|
{"partition":"/dev/sda1","name":"Windows 10","short_name":"Windows","type":"chain"}
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_os_prober_3(self):
|
||||||
|
"""
|
||||||
|
Test 'os_prober' 3
|
||||||
|
"""
|
||||||
|
self.assertEqual(parse(
|
||||||
|
'/dev/sda1@/efi/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi', quiet=True),
|
||||||
|
{"partition":"/dev/sda1@/efi/Microsoft/Boot/bootmgfw.efi","name":"Windows Boot Manager","short_name":"Windows","type":"efi"}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -221,11 +221,11 @@ class MyTests(unittest.TestCase):
|
|||||||
cls.f_json[file] = json.loads(b.read())
|
cls.f_json[file] = json.loads(b.read())
|
||||||
|
|
||||||
|
|
||||||
def test_foo_nodata(self):
|
def test_proc_nodata(self):
|
||||||
"""
|
"""
|
||||||
Test 'foo' with no data
|
Test proc parser with no data
|
||||||
"""
|
"""
|
||||||
self.assertRaises(ParseError, jc.parsers.proc.parse, '')
|
self.assertRaises(ParseError, jc.parsers.proc.parse, '', quiet=True)
|
||||||
|
|
||||||
def test_proc_file_signature_detection(self):
|
def test_proc_file_signature_detection(self):
|
||||||
"""
|
"""
|
||||||
|
101
tests/test_semver.py
Normal file
101
tests/test_semver.py
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import unittest
|
||||||
|
import jc.parsers.semver
|
||||||
|
|
||||||
|
|
||||||
|
class MyTests(unittest.TestCase):
|
||||||
|
def test_semver_nodata(self):
|
||||||
|
"""
|
||||||
|
Test 'semver' with no data
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.semver.parse('', quiet=True), {})
|
||||||
|
|
||||||
|
|
||||||
|
def test_semver_good_strings(self):
|
||||||
|
good_strings = {
|
||||||
|
'0.0.4': {'major': 0, 'minor': 0, 'patch': 4, 'prerelease': None, 'build': None},
|
||||||
|
'1.2.3': {'major': 1, 'minor': 2, 'patch': 3, 'prerelease': None, 'build': None},
|
||||||
|
'10.20.30': {'major': 10, 'minor': 20, 'patch': 30, 'prerelease': None, 'build': None},
|
||||||
|
'1.1.2-prerelease+meta': {'major': 1, 'minor': 1, 'patch': 2, 'prerelease': 'prerelease', 'build': 'meta'},
|
||||||
|
'1.1.2+meta': {'major': 1, 'minor': 1, 'patch': 2, 'prerelease': None, 'build': 'meta'},
|
||||||
|
'1.1.2+meta-valid': {'major': 1, 'minor': 1, 'patch': 2, 'prerelease': None, 'build': 'meta-valid'},
|
||||||
|
'1.0.0-alpha': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': 'alpha', 'build': None},
|
||||||
|
'1.0.0-beta': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': 'beta', 'build': None},
|
||||||
|
'1.0.0-alpha.beta': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': 'alpha.beta', 'build': None},
|
||||||
|
'1.0.0-alpha.beta.1': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': 'alpha.beta.1', 'build': None},
|
||||||
|
'1.0.0-alpha.1': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': 'alpha.1', 'build': None},
|
||||||
|
'1.0.0-alpha0.valid': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': 'alpha0.valid', 'build': None},
|
||||||
|
'1.0.0-alpha.0valid': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': 'alpha.0valid', 'build': None},
|
||||||
|
'1.0.0-alpha-a.b-c-somethinglong+build.1-aef.1-its-okay': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': 'alpha-a.b-c-somethinglong', 'build': 'build.1-aef.1-its-okay'},
|
||||||
|
'1.0.0-rc.1+build.1': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': 'rc.1', 'build': 'build.1'},
|
||||||
|
'2.0.0-rc.1+build.123': {'major': 2, 'minor': 0, 'patch': 0, 'prerelease': 'rc.1', 'build': 'build.123'},
|
||||||
|
'1.2.3-beta': {'major': 1, 'minor': 2, 'patch': 3, 'prerelease': 'beta', 'build': None},
|
||||||
|
'10.2.3-DEV-SNAPSHOT': {'major': 10, 'minor': 2, 'patch': 3, 'prerelease': 'DEV-SNAPSHOT', 'build': None},
|
||||||
|
'1.2.3-SNAPSHOT-123': {'major': 1, 'minor': 2, 'patch': 3, 'prerelease': 'SNAPSHOT-123', 'build': None},
|
||||||
|
'1.0.0': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': None, 'build': None},
|
||||||
|
'2.0.0': {'major': 2, 'minor': 0, 'patch': 0, 'prerelease': None, 'build': None},
|
||||||
|
'1.1.7': {'major': 1, 'minor': 1, 'patch': 7, 'prerelease': None, 'build': None},
|
||||||
|
'2.0.0+build.1848': {'major': 2, 'minor': 0, 'patch': 0, 'prerelease': None, 'build': 'build.1848'},
|
||||||
|
'2.0.1-alpha.1227': {'major': 2, 'minor': 0, 'patch': 1, 'prerelease': 'alpha.1227', 'build': None},
|
||||||
|
'1.0.0-alpha+beta': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': 'alpha', 'build': 'beta'},
|
||||||
|
'1.2.3----RC-SNAPSHOT.12.9.1--.12+788': {'major': 1, 'minor': 2, 'patch': 3, 'prerelease': '---RC-SNAPSHOT.12.9.1--.12', 'build': '788'},
|
||||||
|
'1.2.3----R-S.12.9.1--.12+meta': {'major': 1, 'minor': 2, 'patch': 3, 'prerelease': '---R-S.12.9.1--.12', 'build': 'meta'},
|
||||||
|
'1.2.3----RC-SNAPSHOT.12.9.1--.12': {'major': 1, 'minor': 2, 'patch': 3, 'prerelease': '---RC-SNAPSHOT.12.9.1--.12', 'build': None},
|
||||||
|
'1.0.0+0.build.1-rc.10000aaa-kk-0.1': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': None, 'build': '0.build.1-rc.10000aaa-kk-0.1'},
|
||||||
|
'99999999999999999999999.999999999999999999.99999999999999999': {'major': 99999999999999999999999, 'minor': 999999999999999999, 'patch': 99999999999999999, 'prerelease': None, 'build': None},
|
||||||
|
'1.0.0-0A.is.legal': {'major': 1, 'minor': 0, 'patch': 0, 'prerelease': '0A.is.legal', 'build': None}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ver_string, expected in good_strings.items():
|
||||||
|
self.assertEqual(jc.parsers.semver.parse(ver_string, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
|
def test_semver_bad_strings(self):
|
||||||
|
bad_strings = [
|
||||||
|
'1',
|
||||||
|
'1.2',
|
||||||
|
'1.2.3-0123',
|
||||||
|
'1.2.3-0123.0123',
|
||||||
|
'1.1.2+.123',
|
||||||
|
'+invalid',
|
||||||
|
'-invalid',
|
||||||
|
'-invalid+invalid',
|
||||||
|
'-invalid.01',
|
||||||
|
'alpha',
|
||||||
|
'alpha.beta',
|
||||||
|
'alpha.beta.1',
|
||||||
|
'alpha.1',
|
||||||
|
'alpha+beta',
|
||||||
|
'alpha_beta',
|
||||||
|
'alpha.',
|
||||||
|
'alpha..',
|
||||||
|
'beta',
|
||||||
|
'1.0.0-alpha_beta',
|
||||||
|
'-alpha.',
|
||||||
|
'1.0.0-alpha..',
|
||||||
|
'1.0.0-alpha..1',
|
||||||
|
'1.0.0-alpha...1',
|
||||||
|
'1.0.0-alpha....1',
|
||||||
|
'1.0.0-alpha.....1',
|
||||||
|
'1.0.0-alpha......1',
|
||||||
|
'1.0.0-alpha.......1',
|
||||||
|
'01.1.1',
|
||||||
|
'1.01.1',
|
||||||
|
'1.1.01',
|
||||||
|
'1.2',
|
||||||
|
'1.2.3.DEV',
|
||||||
|
'1.2-SNAPSHOT',
|
||||||
|
'1.2.31.2.3----RC-SNAPSHOT.12.09.1--..12+788',
|
||||||
|
'1.2-RC-SNAPSHOT',
|
||||||
|
'-1.0.3-gamma+b7718',
|
||||||
|
'+justmeta',
|
||||||
|
'9.8.7+meta+meta',
|
||||||
|
'9.8.7-whatever+meta+meta',
|
||||||
|
'99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12'
|
||||||
|
]
|
||||||
|
|
||||||
|
for item in bad_strings:
|
||||||
|
self.assertEqual(jc.parsers.semver.parse(item, quiet=True), {})
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
64
tests/test_sshd_conf.py
Normal file
64
tests/test_sshd_conf.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
import json
|
||||||
|
from typing import Dict
|
||||||
|
import jc.parsers.sshd_conf
|
||||||
|
|
||||||
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
class MyTests(unittest.TestCase):
|
||||||
|
f_in: Dict = {}
|
||||||
|
f_json: Dict = {}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
fixtures = {
|
||||||
|
'sshd_t': (
|
||||||
|
'fixtures/generic/sshd-T.out',
|
||||||
|
'fixtures/generic/sshd-T.json'),
|
||||||
|
'sshd_t_2': (
|
||||||
|
'fixtures/generic/sshd-T-2.out',
|
||||||
|
'fixtures/generic/sshd-T-2.json'),
|
||||||
|
'sshd_config': (
|
||||||
|
'fixtures/generic/sshd_config',
|
||||||
|
'fixtures/generic/sshd_config.json')
|
||||||
|
}
|
||||||
|
|
||||||
|
for file, filepaths in fixtures.items():
|
||||||
|
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||||
|
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||||
|
cls.f_in[file] = a.read()
|
||||||
|
cls.f_json[file] = json.loads(b.read())
|
||||||
|
|
||||||
|
|
||||||
|
def test_sshd_conf_nodata(self):
|
||||||
|
"""
|
||||||
|
Test 'sshd_conf' with no data
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.sshd_conf.parse('', quiet=True), {})
|
||||||
|
|
||||||
|
def test_sshd_T(self):
|
||||||
|
"""
|
||||||
|
Test 'sshd -T'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.sshd_conf.parse(self.f_in['sshd_t'], quiet=True),
|
||||||
|
self.f_json['sshd_t'])
|
||||||
|
|
||||||
|
def test_sshd_T_2(self):
|
||||||
|
"""
|
||||||
|
Test 'sshd -T' with another sample
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.sshd_conf.parse(self.f_in['sshd_t_2'], quiet=True),
|
||||||
|
self.f_json['sshd_t_2'])
|
||||||
|
|
||||||
|
def test_sshd_config(self):
|
||||||
|
"""
|
||||||
|
Test 'cat sshd_config'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.sshd_conf.parse(self.f_in['sshd_config'], quiet=True),
|
||||||
|
self.f_json['sshd_config'])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -11,7 +11,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse('', quiet=True), {})
|
self.assertEqual(jc.parsers.url.parse('', quiet=True), {})
|
||||||
|
|
||||||
|
|
||||||
def test_mailto(self):
|
def test_url_mailto(self):
|
||||||
"""
|
"""
|
||||||
Test mailto URL
|
Test mailto URL
|
||||||
"""
|
"""
|
||||||
@ -20,7 +20,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
def test_ftp(self):
|
def test_url_ftp(self):
|
||||||
"""
|
"""
|
||||||
Test ftp URL
|
Test ftp URL
|
||||||
"""
|
"""
|
||||||
@ -29,7 +29,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
def test_http_ipv4(self):
|
def test_url_http_ipv4(self):
|
||||||
"""
|
"""
|
||||||
Test HTTP URL with encodable characters (ipv4 host)
|
Test HTTP URL with encodable characters (ipv4 host)
|
||||||
"""
|
"""
|
||||||
@ -38,7 +38,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
def test_http_ipv6(self):
|
def test_url_http_ipv6(self):
|
||||||
"""
|
"""
|
||||||
Test HTTP URL with encodable characters (ipv6 host)
|
Test HTTP URL with encodable characters (ipv6 host)
|
||||||
"""
|
"""
|
||||||
@ -47,7 +47,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
def test_http_domain(self):
|
def test_url_http_domain(self):
|
||||||
"""
|
"""
|
||||||
Test HTTP URL with encodable characters (domain name host)
|
Test HTTP URL with encodable characters (domain name host)
|
||||||
"""
|
"""
|
||||||
@ -56,7 +56,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
def test_http_encoded(self):
|
def test_url_http_encoded(self):
|
||||||
"""
|
"""
|
||||||
Test HTTP URL with encoded characters
|
Test HTTP URL with encoded characters
|
||||||
"""
|
"""
|
||||||
@ -65,7 +65,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
def test_http_encodable_host_and_port(self):
|
def test_url_http_encodable_host_and_port(self):
|
||||||
"""
|
"""
|
||||||
Test HTTP URL with encodable characters in the hostname and port
|
Test HTTP URL with encodable characters in the hostname and port
|
||||||
"""
|
"""
|
||||||
@ -74,7 +74,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
def test_http_encoded_host_and_port(self):
|
def test_url_http_encoded_host_and_port(self):
|
||||||
"""
|
"""
|
||||||
Test HTTP URL with encoded characters in the hostname and port
|
Test HTTP URL with encoded characters in the hostname and port
|
||||||
"""
|
"""
|
||||||
@ -83,7 +83,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
def test_http_encoded_host_and_invalid_port(self):
|
def test_url_http_encoded_host_and_invalid_port(self):
|
||||||
"""
|
"""
|
||||||
Test HTTP URL with encoded characters in the hostname and an invalid encoded port
|
Test HTTP URL with encoded characters in the hostname and an invalid encoded port
|
||||||
"""
|
"""
|
||||||
@ -92,7 +92,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
def test_http_path_ends_in_slash(self):
|
def test_url_http_path_ends_in_slash(self):
|
||||||
"""
|
"""
|
||||||
Test HTTP URL with a forward slash as the last part of the path
|
Test HTTP URL with a forward slash as the last part of the path
|
||||||
"""
|
"""
|
||||||
@ -101,7 +101,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
def test_http_path_only_slash(self):
|
def test_url_http_path_only_slash(self):
|
||||||
"""
|
"""
|
||||||
Test HTTP URL with a forward slash as the last only part of the path
|
Test HTTP URL with a forward slash as the last only part of the path
|
||||||
"""
|
"""
|
||||||
@ -110,7 +110,7 @@ class MyTests(unittest.TestCase):
|
|||||||
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
self.assertEqual(jc.parsers.url.parse(data, quiet=True), expected)
|
||||||
|
|
||||||
|
|
||||||
def test_http_path_no_end_slash(self):
|
def test_url_http_path_no_end_slash(self):
|
||||||
"""
|
"""
|
||||||
Test HTTP URL with no forward slash at the end
|
Test HTTP URL with no forward slash at the end
|
||||||
"""
|
"""
|
||||||
|
@ -15,6 +15,9 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/xml-foodmenu.xml'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/xml-foodmenu.xml'), 'r', encoding='utf-8') as f:
|
||||||
generic_xml_foodmenu = f.read()
|
generic_xml_foodmenu = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/xml-nmap.xml'), 'r', encoding='utf-8') as f:
|
||||||
|
generic_xml_nmap = f.read()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/xml-cd_catalog.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/xml-cd_catalog.json'), 'r', encoding='utf-8') as f:
|
||||||
generic_xml_cd_catalog_json = json.loads(f.read())
|
generic_xml_cd_catalog_json = json.loads(f.read())
|
||||||
@ -22,6 +25,12 @@ class MyTests(unittest.TestCase):
|
|||||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/xml-foodmenu.json'), 'r', encoding='utf-8') as f:
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/xml-foodmenu.json'), 'r', encoding='utf-8') as f:
|
||||||
generic_xml_foodmenu_json = json.loads(f.read())
|
generic_xml_foodmenu_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/xml-nmap.json'), 'r', encoding='utf-8') as f:
|
||||||
|
generic_xml_nmap_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/xml-nmap-raw.json'), 'r', encoding='utf-8') as f:
|
||||||
|
generic_xml_nmap_r_json = json.loads(f.read())
|
||||||
|
|
||||||
|
|
||||||
def test_xml_nodata(self):
|
def test_xml_nodata(self):
|
||||||
"""
|
"""
|
||||||
@ -29,6 +38,12 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.xml.parse('', quiet=True), [])
|
self.assertEqual(jc.parsers.xml.parse('', quiet=True), [])
|
||||||
|
|
||||||
|
def test_xml_nodata_r(self):
|
||||||
|
"""
|
||||||
|
Test xml parser with no data and raw output
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.xml.parse('', raw=True, quiet=True), [])
|
||||||
|
|
||||||
def test_xml_cd_catalog(self):
|
def test_xml_cd_catalog(self):
|
||||||
"""
|
"""
|
||||||
Test the cd catalog xml file
|
Test the cd catalog xml file
|
||||||
@ -41,6 +56,18 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.xml.parse(self.generic_xml_foodmenu, quiet=True), self.generic_xml_foodmenu_json)
|
self.assertEqual(jc.parsers.xml.parse(self.generic_xml_foodmenu, quiet=True), self.generic_xml_foodmenu_json)
|
||||||
|
|
||||||
|
def test_xml_nmap(self):
|
||||||
|
"""
|
||||||
|
Test nmap xml output
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.xml.parse(self.generic_xml_nmap, quiet=True), self.generic_xml_nmap_json)
|
||||||
|
|
||||||
|
def test_xml_nmap_r(self):
|
||||||
|
"""
|
||||||
|
Test nmap xml raw output
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.xml.parse(self.generic_xml_nmap, raw=True, quiet=True), self.generic_xml_nmap_r_json)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user