1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2026-04-03 17:44:07 +02:00

Compare commits

..

20 Commits

Author SHA1 Message Date
Kelly Brazil
a43e2e1991 add -m option info 2020-04-02 17:40:06 -07:00
Kelly Brazil
c8b721d4f6 version bump to 1.10.0 2020-04-02 17:35:35 -07:00
Kelly Brazil
d0bfddc3d9 add color and -m monochrome option 2020-04-02 17:29:25 -07:00
Kelly Brazil
6b925a16c8 add tests badge 2020-04-02 10:55:32 -07:00
Kelly Brazil
89ebd9fc22 add axfr info to schema 2020-03-27 07:31:08 -07:00
Kelly Brazil
6b4ba66231 Merge pull request #52 from kellyjonbrazil/dev
Dev v1.9.3
2020-03-26 17:15:13 -07:00
Kelly Brazil
5b697dc381 add more dig tests 2020-03-26 17:09:29 -07:00
Kelly Brazil
9ba73c95d1 add tests 2020-03-26 16:45:29 -07:00
Kelly Brazil
93aa390447 version bump to v1.9.3 2020-03-26 16:30:17 -07:00
Kelly Brazil
3cfb8945dd use startswith() instead of find 2020-03-26 16:29:59 -07:00
Kelly Brazil
cd8d38f2a1 add axfr support 2020-03-26 16:22:53 -07:00
Kelly Brazil
8ec8cd6294 Merge pull request #50 from kellyjonbrazil/dev
Dev v1.9.2
2020-03-12 17:09:04 -07:00
Kelly Brazil
c028113561 version bump to v1.9.2 2020-03-12 17:06:55 -07:00
Kelly Brazil
5f22e1c803 fix and test for osx arp entries without ifscope 2020-03-12 17:02:26 -07:00
Kelly Brazil
d3351787e5 change osx detection 2020-03-12 16:52:33 -07:00
Kelly Brazil
e5bea9ae3b version bump 2020-03-12 08:52:01 -07:00
Kelly Brazil
93c710abe9 Merge pull request #49 from kellyjonbrazil/dev
Dev v1.9.1
2020-03-12 08:23:10 -07:00
Kelly Brazil
c29e7cfe5c version bump to 1.9.1 2020-03-12 08:17:28 -07:00
Kelly Brazil
cb5c1ba00d add tests for fix to make the file parser splitting more robust 2020-03-11 17:04:48 -07:00
Kelly Brazil
9a012b94e1 make splitting more robust 2020-03-11 15:40:34 -07:00
22 changed files with 578 additions and 34 deletions

View File

@@ -1,3 +1,5 @@
![Test code](https://github.com/kellyjonbrazil/jc/workflows/Test%20code/badge.svg?branch=master)
# JC
JSON CLI output utility
@@ -136,6 +138,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
### Options
- `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of course!)
- `-d` debug mode. Prints trace messages if parsing issues encountered
- `-m` monochrome JSON output
- `-p` pretty format the JSON output
- `-q` quiet mode. Suppresses warning messages
- `-r` raw output. Provides a more literal JSON output with all values as text and no additional sematic processing
@@ -170,7 +173,7 @@ Tested on:
## Examples
### airport -I
```
$ airport -I | jc --airport -p
$ airport -I | jc --airport -p # or: jc -p airport -I
{
"agrctlrssi": -66,
"agrextrssi": 0,
@@ -191,7 +194,7 @@ $ airport -I | jc --airport -p
```
### airport -s
```
$ airport -s | jc --airport-s -p
$ airport -s | jc --airport-s -p # or: jc -p airport -s
[
{
"ssid": "DIRECT-4A-HP OfficeJet 3830",
@@ -764,7 +767,7 @@ $ env | jc --env -p # or: jc -p env
```
### file
```
$ file * | jc --file -p
$ file * | jc --file -p # or: jc -p file *
[
{
"filename": "Applications",
@@ -2127,7 +2130,7 @@ $ systemctl list-unit-files | jc --systemctl-luf -p # or: jc -p system
```
### timedatectl status
```
$ timedatectl | jc --timedatectl -p
$ timedatectl | jc --timedatectl -p # or: jc -p timedatectl
{
"local_time": "Tue 2020-03-10 17:53:21 PDT",
"universal_time": "Wed 2020-03-11 00:53:21 UTC",

View File

@@ -1,5 +1,18 @@
jc changelog
20200402 v1.10.0
- Add color output by default when not piping data to another program
- Add -m option for monochrome output
20200326 v1.9.3
- Add axfr support for dig command parser
20200312 v1.9.2
- Updated arp parser to fix OSX detection for some edge cases
20200312 v1.9.1
- Updated file command parser to make filename splitting more robust
20200311 v1.9.0
- Added ntpq command parser
- Added timedatectl status command parser

View File

@@ -353,6 +353,15 @@ Returns:
"answer_num": integer,
"authority_num": integer,
"additional_num": integer,
"axfr": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"question": {
"name": string,
"class": string,
@@ -380,6 +389,7 @@ Returns:
"server": string,
"when": string,
"rcvd": integer
"size": string
}
]

View File

@@ -9,11 +9,16 @@ import importlib
import textwrap
import signal
import json
from pygments import highlight
from pygments.style import Style
from pygments.token import (Name, Number, String, Keyword)
from pygments.lexers import JsonLexer
from pygments.formatters import Terminal256Formatter
import jc.utils
class info():
version = '1.9.0'
version = '1.10.0'
description = 'jc cli output JSON conversion tool'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -75,6 +80,28 @@ parsers = [
]
class JcStyle(Style):
BLUE = '#2c5dcd'
GREY = '#4d4d4d'
PURPLE = '#5918bb'
GREEN = '#00cc00'
styles = {
Name.Tag: 'bold {}'.format(BLUE), # key names
Keyword: GREY, # true, false, null
Number: PURPLE, # int, float
String: GREEN # string
}
def piped_output():
"""returns False if stdout is a TTY. True if output is being piped to another program"""
if sys.stdout.isatty():
return False
else:
return True
def ctrlc(signum, frame):
"""exit with error on SIGINT"""
sys.exit(1)
@@ -167,6 +194,7 @@ def helptext(message):
Options:
-a about jc
-d debug - show trace messages
-m monochrome output
-p pretty print output
-q quiet - suppress warnings
-r raw JSON output
@@ -181,11 +209,17 @@ def helptext(message):
print(textwrap.dedent(helptext_string), file=sys.stderr)
def json_out(data, pretty=False):
if pretty:
print(json.dumps(data, indent=2))
def json_out(data, pretty=False, mono=False, piped_out=False):
if not mono and not piped_out:
if pretty:
print(highlight(json.dumps(data, indent=2), JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
else:
print(highlight(json.dumps(data), JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
else:
print(json.dumps(data))
if pretty:
print(json.dumps(data, indent=2))
else:
print(json.dumps(data))
def generate_magic_command(args):
@@ -271,12 +305,13 @@ def main():
options.extend(opt[1:])
debug = 'd' in options
mono = 'm' in options
pretty = 'p' in options
quiet = 'q' in options
raw = 'r' in options
if 'a' in options:
json_out(about_jc(), pretty=pretty)
json_out(about_jc(), pretty=pretty, mono=mono, piped_out=piped_output())
exit()
if sys.stdin.isatty():
@@ -317,7 +352,7 @@ def main():
helptext('missing or incorrect arguments')
sys.exit(1)
json_out(result, pretty=pretty)
json_out(result, pretty=pretty, mono=mono, piped_out=piped_output())
if __name__ == '__main__':

View File

@@ -91,7 +91,7 @@ import jc.parsers.universal
class info():
version = '1.1'
version = '1.2'
description = 'arp command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -160,16 +160,17 @@ def parse(data, raw=False, quiet=False):
cleandata.pop(-1)
# detect if osx style was used
if cleandata[0].find(' ifscope ') != -1:
if cleandata[0][-1] == ']':
raw_output = []
for line in cleandata:
line = line.split()
output_line = {}
output_line['name'] = line[0]
output_line['address'] = line[1].lstrip('(').rstrip(')')
output_line['hwtype'] = line[-1].lstrip('[').rstrip(']')
output_line['hwaddress'] = line[3]
output_line['iface'] = line[5]
splitline = line.split()
output_line = {
'name': splitline[0],
'address': splitline[1].lstrip('(').rstrip(')'),
'hwtype': splitline[-1].lstrip('[').rstrip(']'),
'hwaddress': splitline[3],
'iface': splitline[5]
}
raw_output.append(output_line)
if raw:

View File

@@ -324,7 +324,7 @@ import jc.utils
class info():
version = '1.0'
version = '1.1'
description = 'dig command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -361,6 +361,15 @@ def process(proc_data):
"answer_num": integer,
"authority_num": integer,
"additional_num": integer,
"axfr": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"question": {
"name": string,
"class": string,
@@ -388,6 +397,7 @@ def process(proc_data):
"server": string,
"when": string,
"rcvd": integer
"size": string
}
]
"""
@@ -402,6 +412,14 @@ def process(proc_data):
except (ValueError):
entry[key] = None
if 'axfr' in entry:
for ax in entry['axfr']:
try:
ttl_int = int(ax['ttl'])
ax['ttl'] = ttl_int
except (ValueError):
ax['ttl'] = None
if 'answer' in entry:
for ans in entry['answer']:
try:
@@ -507,6 +525,24 @@ def parse_answer(answer):
'ttl': answer_ttl,
'data': answer_data}
def parse_axfr(axfr):
#; <<>> DiG 9.11.14-3-Debian <<>> @81.4.108.41 axfr zonetransfer.me +nocookie
#; (1 server found)
#;; global options: +cmd
#zonetransfer.me. 7200 IN A 5.196.105.14
axfr = axfr.split(maxsplit=4)
axfr_name = axfr[0]
axfr_ttl = axfr[1]
axfr_class = axfr[2]
axfr_type = axfr[3]
axfr_data = axfr[4]
return {'name': axfr_name,
'ttl': axfr_ttl,
'class': axfr_class,
'type': axfr_type,
'data': axfr_data}
def parse(data, raw=False, quiet=False):
"""
@@ -534,23 +570,38 @@ def parse(data, raw=False, quiet=False):
question = False
authority = False
answer = False
axfr = False
output_entry = {}
for line in cleandata:
if line.find(';; ->>HEADER<<-') == 0:
if line.startswith('; <<>> ') and line.lower().find(' axfr ') != -1:
question = False
authority = False
answer = False
axfr = True
axfr_list = []
continue
if line.find(';') == -1 and axfr:
axfr_list.append(parse_axfr(line))
output_entry.update({'axfr': axfr_list})
continue
if line.startswith(';; ->>HEADER<<-'):
output_entry = {}
output_entry.update(parse_header(line))
continue
if line.find(';; flags:') == 0:
if line.startswith(';; flags:'):
output_entry.update(parse_flags_line(line))
continue
if line.find(';; QUESTION SECTION:') == 0:
if line.startswith(';; QUESTION SECTION:'):
question = True
authority = False
answer = False
axfr = False
continue
if question:
@@ -558,12 +609,14 @@ def parse(data, raw=False, quiet=False):
question = False
authority = False
answer = False
axfr = False
continue
if line.find(';; AUTHORITY SECTION:') == 0:
if line.startswith(';; AUTHORITY SECTION:'):
question = False
authority = True
answer = False
axfr = False
authority_list = []
continue
@@ -572,10 +625,11 @@ def parse(data, raw=False, quiet=False):
output_entry.update({'authority': authority_list})
continue
if line.find(';; ANSWER SECTION:') == 0:
if line.startswith(';; ANSWER SECTION:'):
question = False
authority = False
answer = True
axfr = False
answer_list = []
continue
@@ -586,24 +640,29 @@ def parse(data, raw=False, quiet=False):
# footer consists of 4 lines
# footer line 1
if line.find(';; Query time:') == 0:
if line.startswith(';; Query time:'):
output_entry.update({'query_time': line.split(':')[1].lstrip()})
continue
# footer line 2
if line.find(';; SERVER:') == 0:
if line.startswith(';; SERVER:'):
output_entry.update({'server': line.split(':')[1].lstrip()})
continue
# footer line 3
if line.find(';; WHEN:') == 0:
if line.startswith(';; WHEN:'):
output_entry.update({'when': line.split(':', maxsplit=1)[1].lstrip()})
continue
# footer line 4 (last line)
if line.find(';; MSG SIZE rcvd:') == 0:
if line.startswith(';; MSG SIZE rcvd:'):
output_entry.update({'rcvd': line.split(':')[1].lstrip()})
if output_entry:
raw_output.append(output_entry)
elif line.startswith(';; XFR size:'):
output_entry.update({'size': line.split(':')[1].lstrip()})
if output_entry:
raw_output.append(output_entry)

View File

@@ -48,7 +48,7 @@ import jc.parsers.universal
class info():
version = '1.0'
version = '1.1'
description = 'file command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -105,7 +105,7 @@ def parse(data, raw=False, quiet=False):
warned = False
for line in filter(None, data.splitlines()):
linedata = line.rsplit(':', maxsplit=1)
linedata = line.rsplit(': ', maxsplit=1)
try:
filename = linedata[0].strip()

View File

@@ -1,3 +1,4 @@
ifconfig-parser>=0.0.5
ruamel.yaml>=0.15.0
xmltodict>=0.12.0
Pygments>=2.5.2

View File

@@ -5,14 +5,15 @@ with open('README.md', 'r') as f:
setuptools.setup(
name='jc',
version='1.9.0',
version='1.10.0',
author='Kelly Brazil',
author_email='kellyjonbrazil@gmail.com',
description='This tool serializes the output of popular command line tools and filetypes to structured JSON output.',
install_requires=[
'ifconfig-parser>=0.0.5',
'ruamel.yaml>=0.15.0',
'xmltodict>=0.12.0'
'xmltodict>=0.12.0',
'Pygments>=2.5.2'
],
license='MIT',
long_description=long_description,

File diff suppressed because one or more lines are too long

60
tests/fixtures/centos-7.7/dig-axfr.out vendored Normal file
View File

@@ -0,0 +1,60 @@
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> @81.4.108.41 AXFR zonetransfer.me +nocookie
; (1 server found)
;; global options: +cmd
zonetransfer.me. 7200 IN SOA nsztm1.digi.ninja. robin.digi.ninja. 2019100801 172800 900 1209600 3600
zonetransfer.me. 300 IN HINFO "Casio fx-700G" "Windows XP"
zonetransfer.me. 301 IN TXT "google-site-verification=tyP28J7JAUHA9fw2sHXMgcCC0I6XBmmoVi04VlMewxA"
zonetransfer.me. 7200 IN MX 0 ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 10 ALT1.ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 10 ALT2.ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX2.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX3.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX4.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX5.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN A 5.196.105.14
zonetransfer.me. 7200 IN NS nsztm1.digi.ninja.
zonetransfer.me. 7200 IN NS nsztm2.digi.ninja.
_acme-challenge.zonetransfer.me. 301 IN TXT "6Oa05hbUJ9xSsvYy7pApQvwCUSSGgxvrbdizjePEsZI"
_sip._tcp.zonetransfer.me. 14000 IN SRV 0 0 5060 www.zonetransfer.me.
14.105.196.5.IN-ADDR.ARPA.zonetransfer.me. 7200 IN PTR www.zonetransfer.me.
asfdbauthdns.zonetransfer.me. 7900 IN AFSDB 1 asfdbbox.zonetransfer.me.
asfdbbox.zonetransfer.me. 7200 IN A 127.0.0.1
asfdbvolume.zonetransfer.me. 7800 IN AFSDB 1 asfdbbox.zonetransfer.me.
canberra-office.zonetransfer.me. 7200 IN A 202.14.81.230
cmdexec.zonetransfer.me. 300 IN TXT "; ls"
contact.zonetransfer.me. 2592000 IN TXT "Remember to call or email Pippa on +44 123 4567890 or pippa@zonetransfer.me when making DNS changes"
dc-office.zonetransfer.me. 7200 IN A 143.228.181.132
deadbeef.zonetransfer.me. 7201 IN AAAA dead:beaf::
dr.zonetransfer.me. 300 IN LOC 53 20 56.558 N 1 38 33.526 W 0.00m 1m 10000m 10m
DZC.zonetransfer.me. 7200 IN TXT "AbCdEfG"
email.zonetransfer.me. 2222 IN NAPTR 1 1 "P" "E2U+email" "" email.zonetransfer.me.zonetransfer.me.
email.zonetransfer.me. 7200 IN A 74.125.206.26
Hello.zonetransfer.me. 7200 IN TXT "Hi to Josh and all his class"
home.zonetransfer.me. 7200 IN A 127.0.0.1
Info.zonetransfer.me. 7200 IN TXT "ZoneTransfer.me service provided by Robin Wood - robin@digi.ninja. See http://digi.ninja/projects/zonetransferme.php for more information."
internal.zonetransfer.me. 300 IN NS intns1.zonetransfer.me.
internal.zonetransfer.me. 300 IN NS intns2.zonetransfer.me.
intns1.zonetransfer.me. 300 IN A 81.4.108.41
intns2.zonetransfer.me. 300 IN A 167.88.42.94
office.zonetransfer.me. 7200 IN A 4.23.39.254
ipv6actnow.org.zonetransfer.me. 7200 IN AAAA 2001:67c:2e8:11::c100:1332
owa.zonetransfer.me. 7200 IN A 207.46.197.32
robinwood.zonetransfer.me. 302 IN TXT "Robin Wood"
rp.zonetransfer.me. 321 IN RP robin.zonetransfer.me. robinwood.zonetransfer.me.
sip.zonetransfer.me. 3333 IN NAPTR 2 3 "P" "E2U+sip" "!^.*$!sip:customer-service@zonetransfer.me!" .
sqli.zonetransfer.me. 300 IN TXT "' or 1=1 --"
sshock.zonetransfer.me. 7200 IN TXT "() { :]}; echo ShellShocked"
staging.zonetransfer.me. 7200 IN CNAME www.sydneyoperahouse.com.
alltcpportsopen.firewall.test.zonetransfer.me. 301 IN A 127.0.0.1
testing.zonetransfer.me. 301 IN CNAME www.zonetransfer.me.
vpn.zonetransfer.me. 4000 IN A 174.36.59.154
www.zonetransfer.me. 7200 IN A 5.196.105.14
xss.zonetransfer.me. 300 IN TXT "'><script>alert('Boo')</script>"
zonetransfer.me. 7200 IN SOA nsztm1.digi.ninja. robin.digi.ninja. 2019100801 172800 900 1209600 3600
;; Query time: 182 msec
;; SERVER: 81.4.108.41#53(81.4.108.41)
;; WHEN: Wed Mar 25 20:01:47 PDT 2020
;; XFR size: 50 records (messages 1, bytes 1994)

View File

@@ -0,0 +1 @@
[{"name": null, "address": "169.254.81.142", "hwtype": "ethernet", "hwaddress": "60:93:17:3a:28:fc", "iface": "en0"}, {"name": "my-iphone.attlocal.net", "address": "192.168.1.64", "hwtype": "ethernet", "hwaddress": "e0:33:8f:68:39:d6", "iface": "en0"}, {"name": "my-mbp.attlocal.net", "address": "192.168.1.72", "hwtype": "ethernet", "hwaddress": "f0:18:98:3:d7:34", "iface": "en0"}, {"name": "c6180.attlocal.net", "address": "192.168.1.74", "hwtype": "ethernet", "hwaddress": "9c:b6:54:5f:fa:7c", "iface": "en0"}, {"name": "ipad.attlocal.net", "address": "192.168.1.75", "hwtype": "ethernet", "hwaddress": "4c:56:9e:5f:c7:4c", "iface": "en0"}, {"name": "mycloudex2ultra.attlocal.net", "address": "192.168.1.80", "hwtype": "ethernet", "hwaddress": "0:90:a9:ed:f4:3f", "iface": "en0"}, {"name": "family-room-5.attlocal.net", "address": "192.168.1.88", "hwtype": "ethernet", "hwaddress": "c8:d0:84:c3:e3:2d", "iface": "en0"}, {"name": "bedroom.attlocal.net", "address": "192.168.1.89", "hwtype": "ethernet", "hwaddress": "d0:3:4b:3b:29:a5", "iface": "en0"}, {"name": "heriphone.attlocal.net", "address": "192.168.1.178", "hwtype": "ethernet", "hwaddress": "90:e1:7b:ef:1:45", "iface": "en0"}, {"name": "upstairs.attlocal.net", "address": "192.168.1.186", "hwtype": "ethernet", "hwaddress": "50:32:37:d7:e5:7b", "iface": "en0"}, {"name": "rbr50.attlocal.net", "address": "192.168.1.216", "hwtype": "ethernet", "hwaddress": "3c:37:86:25:fd:f7", "iface": "en0"}, {"name": "my-mac.attlocal.net", "address": "192.168.1.221", "hwtype": "ethernet", "hwaddress": "a4:83:e7:2e:f2:8f", "iface": "en0"}, {"name": "irobot-d41934.attlocal.net", "address": "192.168.1.242", "hwtype": "ethernet", "hwaddress": "50:14:79:f2:4f:3e", "iface": "en0"}, {"name": "rbs50.attlocal.net", "address": "192.168.1.253", "hwtype": "ethernet", "hwaddress": "3c:37:86:1f:dd:a3", "iface": "en0"}, {"name": "dsldevice.attlocal.net", "address": "192.168.1.254", "hwtype": "ethernet", "hwaddress": "fc:ae:34:f1:3f:80", "iface": "en0"}, {"name": null, "address": "192.168.1.255", "hwtype": "ethernet", "hwaddress": "ff:ff:ff:ff:ff:ff", "iface": "en0"}, {"name": null, "address": "192.168.71.255", "hwtype": "ethernet", "hwaddress": "ff:ff:ff:ff:ff:ff", "iface": "vmnet8"}, {"name": null, "address": "192.168.101.255", "hwtype": "ethernet", "hwaddress": "ff:ff:ff:ff:ff:ff", "iface": "vmnet1"}, {"name": null, "address": "224.0.0.251", "hwtype": "ethernet", "hwaddress": "1:0:5e:0:0:eb", "iface": "en0"}, {"name": null, "address": "239.255.255.250", "hwtype": "ethernet", "hwaddress": "1:0:5e:7f:ff:fe", "iface": "en0"}]

20
tests/fixtures/osx-10.14.6/arp-a2.out vendored Normal file
View File

@@ -0,0 +1,20 @@
? (169.254.81.142) at 60:93:17:3a:28:fc on en0 [ethernet]
my-iphone.attlocal.net (192.168.1.64) at e0:33:8f:68:39:d6 on en0 ifscope [ethernet]
my-mbp.attlocal.net (192.168.1.72) at f0:18:98:3:d7:34 on en0 ifscope [ethernet]
c6180.attlocal.net (192.168.1.74) at 9c:b6:54:5f:fa:7c on en0 ifscope [ethernet]
ipad.attlocal.net (192.168.1.75) at 4c:56:9e:5f:c7:4c on en0 ifscope [ethernet]
mycloudex2ultra.attlocal.net (192.168.1.80) at 0:90:a9:ed:f4:3f on en0 ifscope [ethernet]
family-room-5.attlocal.net (192.168.1.88) at c8:d0:84:c3:e3:2d on en0 ifscope [ethernet]
bedroom.attlocal.net (192.168.1.89) at d0:3:4b:3b:29:a5 on en0 ifscope [ethernet]
heriphone.attlocal.net (192.168.1.178) at 90:e1:7b:ef:1:45 on en0 ifscope [ethernet]
upstairs.attlocal.net (192.168.1.186) at 50:32:37:d7:e5:7b on en0 ifscope [ethernet]
rbr50.attlocal.net (192.168.1.216) at 3c:37:86:25:fd:f7 on en0 ifscope [ethernet]
my-mac.attlocal.net (192.168.1.221) at a4:83:e7:2e:f2:8f on en0 ifscope permanent [ethernet]
irobot-d41934.attlocal.net (192.168.1.242) at 50:14:79:f2:4f:3e on en0 ifscope [ethernet]
rbs50.attlocal.net (192.168.1.253) at 3c:37:86:1f:dd:a3 on en0 ifscope [ethernet]
dsldevice.attlocal.net (192.168.1.254) at fc:ae:34:f1:3f:80 on en0 ifscope [ethernet]
? (192.168.1.255) at ff:ff:ff:ff:ff:ff on en0 ifscope [ethernet]
? (192.168.71.255) at ff:ff:ff:ff:ff:ff on vmnet8 ifscope [ethernet]
? (192.168.101.255) at ff:ff:ff:ff:ff:ff on vmnet1 ifscope [ethernet]
? (224.0.0.251) at 1:0:5e:0:0:eb on en0 ifscope permanent [ethernet]
? (239.255.255.250) at 1:0:5e:7f:ff:fe on en0 ifscope permanent [ethernet]

File diff suppressed because one or more lines are too long

59
tests/fixtures/osx-10.14.6/dig-axfr.out vendored Normal file
View File

@@ -0,0 +1,59 @@
; <<>> DiG 9.10.6 <<>> @81.4.108.41 AXFR zonetransfer.me
; (1 server found)
;; global options: +cmd
zonetransfer.me. 7200 IN SOA nsztm1.digi.ninja. robin.digi.ninja. 2019100801 172800 900 1209600 3600
zonetransfer.me. 300 IN HINFO "Casio fx-700G" "Windows XP"
zonetransfer.me. 301 IN TXT "google-site-verification=tyP28J7JAUHA9fw2sHXMgcCC0I6XBmmoVi04VlMewxA"
zonetransfer.me. 7200 IN MX 0 ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 10 ALT1.ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 10 ALT2.ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX2.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX3.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX4.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX5.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN A 5.196.105.14
zonetransfer.me. 7200 IN NS nsztm1.digi.ninja.
zonetransfer.me. 7200 IN NS nsztm2.digi.ninja.
_acme-challenge.zonetransfer.me. 301 IN TXT "6Oa05hbUJ9xSsvYy7pApQvwCUSSGgxvrbdizjePEsZI"
_sip._tcp.zonetransfer.me. 14000 IN SRV 0 0 5060 www.zonetransfer.me.
14.105.196.5.IN-ADDR.ARPA.zonetransfer.me. 7200 IN PTR www.zonetransfer.me.
asfdbauthdns.zonetransfer.me. 7900 IN AFSDB 1 asfdbbox.zonetransfer.me.
asfdbbox.zonetransfer.me. 7200 IN A 127.0.0.1
asfdbvolume.zonetransfer.me. 7800 IN AFSDB 1 asfdbbox.zonetransfer.me.
canberra-office.zonetransfer.me. 7200 IN A 202.14.81.230
cmdexec.zonetransfer.me. 300 IN TXT "; ls"
contact.zonetransfer.me. 2592000 IN TXT "Remember to call or email Pippa on +44 123 4567890 or pippa@zonetransfer.me when making DNS changes"
dc-office.zonetransfer.me. 7200 IN A 143.228.181.132
deadbeef.zonetransfer.me. 7201 IN AAAA dead:beaf::
dr.zonetransfer.me. 300 IN LOC 53 20 56.558 N 1 38 33.526 W 0.00m 1m 10000m 10m
DZC.zonetransfer.me. 7200 IN TXT "AbCdEfG"
email.zonetransfer.me. 2222 IN NAPTR 1 1 "P" "E2U+email" "" email.zonetransfer.me.zonetransfer.me.
email.zonetransfer.me. 7200 IN A 74.125.206.26
Hello.zonetransfer.me. 7200 IN TXT "Hi to Josh and all his class"
home.zonetransfer.me. 7200 IN A 127.0.0.1
Info.zonetransfer.me. 7200 IN TXT "ZoneTransfer.me service provided by Robin Wood - robin@digi.ninja. See http://digi.ninja/projects/zonetransferme.php for more information."
internal.zonetransfer.me. 300 IN NS intns1.zonetransfer.me.
internal.zonetransfer.me. 300 IN NS intns2.zonetransfer.me.
intns1.zonetransfer.me. 300 IN A 81.4.108.41
intns2.zonetransfer.me. 300 IN A 167.88.42.94
office.zonetransfer.me. 7200 IN A 4.23.39.254
ipv6actnow.org.zonetransfer.me. 7200 IN AAAA 2001:67c:2e8:11::c100:1332
owa.zonetransfer.me. 7200 IN A 207.46.197.32
robinwood.zonetransfer.me. 302 IN TXT "Robin Wood"
rp.zonetransfer.me. 321 IN RP robin.zonetransfer.me. robinwood.zonetransfer.me.
sip.zonetransfer.me. 3333 IN NAPTR 2 3 "P" "E2U+sip" "!^.*$!sip:customer-service@zonetransfer.me!" .
sqli.zonetransfer.me. 300 IN TXT "' or 1=1 --"
sshock.zonetransfer.me. 7200 IN TXT "() { :]}; echo ShellShocked"
staging.zonetransfer.me. 7200 IN CNAME www.sydneyoperahouse.com.
alltcpportsopen.firewall.test.zonetransfer.me. 301 IN A 127.0.0.1
testing.zonetransfer.me. 301 IN CNAME www.zonetransfer.me.
vpn.zonetransfer.me. 4000 IN A 174.36.59.154
www.zonetransfer.me. 7200 IN A 5.196.105.14
xss.zonetransfer.me. 300 IN TXT "'><script>alert('Boo')</script>"
zonetransfer.me. 7200 IN SOA nsztm1.digi.ninja. robin.digi.ninja. 2019100801 172800 900 1209600 3600
;; Query time: 170 msec
;; SERVER: 81.4.108.41#53(81.4.108.41)
;; WHEN: Thu Mar 26 16:31:06 PDT 2020
;; XFR size: 50 records (messages 1, bytes 1994)

1
tests/fixtures/osx-10.14.6/file2.json vendored Normal file
View File

@@ -0,0 +1 @@
[{"filename": "AFP.conf", "type": "data"}, {"filename": "afpovertcp.cfg", "type": "ASCII text"}, {"filename": "aliases", "type": "ASCII text"}, {"filename": "aliases.db", "type": "Berkeley DB 1.85 (Hash, version 2, native byte-order)"}, {"filename": "apache2", "type": "directory"}, {"filename": "asl", "type": "directory"}, {"filename": "asl.conf", "type": "ASCII text"}, {"filename": "auto_home", "type": "ASCII text"}, {"filename": "auto_master", "type": "ASCII text"}, {"filename": "autofs.conf", "type": "ASCII text"}, {"filename": "bashrc", "type": "ASCII text"}, {"filename": "bashrc_Apple_Terminal", "type": "ASCII text"}, {"filename": "com.apple.screensharing.agent.launchd", "type": "ASCII text, with no line terminators"}, {"filename": "csh.cshrc", "type": "ASCII text"}, {"filename": "csh.login", "type": "ASCII text"}, {"filename": "csh.logout", "type": "ASCII text"}, {"filename": "cups", "type": "directory"}, {"filename": "defaults", "type": "directory"}, {"filename": "dnsextd.conf", "type": "ASCII text"}, {"filename": "emond.d", "type": "directory"}, {"filename": "find.codes", "type": "empty"}, {"filename": "fstab.hd", "type": "ASCII text"}, {"filename": "ftpusers", "type": "ASCII text"}, {"filename": "gettytab", "type": "ASCII text"}, {"filename": "group", "type": "ASCII text"}, {"filename": "hosts", "type": "ASCII text"}, {"filename": "hosts.equiv", "type": "empty"}, {"filename": "irbrc", "type": "Ruby script text, ASCII text"}, {"filename": "kern_loader.conf", "type": "empty"}, {"filename": "krb5.keytab", "type": "Kerberos Keytab file, realm=LKDC:SHA1.15090DD365668FBA1B0D2D3DD43FCB7CB9381160, principal=afpserver/LKDC:SHA1.15090DD365668FBA1B0D2D3DD43FCB7CB9381160, type=1, date=Tue Jul 2 15:52:04 2019, kvno=2"}, {"filename": "localtime", "type": "timezone data, version 2, 4 gmt time flags, 4 std time flags, no leap seconds, 185 transition times, 4 abbreviation chars"}, {"filename": "locate.rc", "type": "ASCII text"}, {"filename": "mach_init.d", "type": "directory"}, {"filename": "mach_init_per_login_session.d", "type": "directory"}, {"filename": "mach_init_per_user.d", "type": "directory"}, {"filename": "mail.rc", "type": "ASCII text"}, {"filename": "man.conf", "type": "ASCII text"}, {"filename": "manpaths", "type": "ASCII text"}, {"filename": "manpaths.d", "type": "directory"}, {"filename": "master.passwd", "type": "ASCII text"}, {"filename": "nanorc", "type": "ASCII text"}, {"filename": "networks", "type": "ASCII text"}, {"filename": "newsyslog.conf", "type": "ASCII text"}, {"filename": "newsyslog.d", "type": "directory"}, {"filename": "nfs.conf", "type": "ASCII text"}, {"filename": "notify.conf", "type": "ASCII text"}, {"filename": "ntp.conf", "type": "ASCII text"}, {"filename": "ntp_opendirectory.conf", "type": "ASCII text"}, {"filename": "openldap", "type": "directory"}, {"filename": "pam.d", "type": "directory"}, {"filename": "passwd", "type": "ASCII text"}, {"filename": "paths", "type": "ASCII text"}, {"filename": "paths.d", "type": "directory"}, {"filename": "periodic", "type": "directory"}, {"filename": "pf.anchors", "type": "directory"}, {"filename": "pf.conf", "type": "ASCII text"}, {"filename": "pf.os", "type": "ASCII text"}, {"filename": "php-fpm.conf.default", "type": "ASCII text"}, {"filename": "php-fpm.d", "type": "directory"}, {"filename": "php.ini.default", "type": "ASCII text"}, {"filename": "postfix", "type": "directory"}, {"filename": "ppp", "type": "directory"}, {"filename": "profile", "type": "ASCII text"}, {"filename": "protocols", "type": "ASCII text"}, {"filename": "racoon", "type": "directory"}, {"filename": "rc.common", "type": "ASCII text"}, {"filename": "rc.netboot", "type": "POSIX shell script text executable, ASCII text"}, {"filename": "resolv.conf", "type": "ASCII text"}, {"filename": "rmtab", "type": "empty"}, {"filename": "rpc", "type": "ASCII text"}, {"filename": "rtadvd.conf", "type": "ASCII text"}, {"filename": "security", "type": "directory"}, {"filename": "services", "type": "ASCII text"}, {"filename": "services.broker", "type": "ASCII text"}, {"filename": "shells", "type": "ASCII text"}, {"filename": "snmp", "type": "directory"}, {"filename": "ssh", "type": "directory"}, {"filename": "ssl", "type": "directory"}, {"filename": "sudo_lecture", "type": "ASCII text"}, {"filename": "sudoers", "type": "c program text, ASCII text"}, {"filename": "sudoers.d", "type": "directory"}, {"filename": "syslog.conf", "type": "ASCII text"}, {"filename": "thnuclnt", "type": "directory"}, {"filename": "ttys", "type": "ASCII text"}, {"filename": "wfs", "type": "directory"}, {"filename": "xtab", "type": "empty"}, {"filename": "zprofile", "type": "ASCII text"}, {"filename": "zshrc", "type": "ASCII text"}]

88
tests/fixtures/osx-10.14.6/file2.out vendored Normal file
View File

@@ -0,0 +1,88 @@
AFP.conf: data
afpovertcp.cfg: ASCII text
aliases: ASCII text
aliases.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)
apache2: directory
asl: directory
asl.conf: ASCII text
auto_home: ASCII text
auto_master: ASCII text
autofs.conf: ASCII text
bashrc: ASCII text
bashrc_Apple_Terminal: ASCII text
com.apple.screensharing.agent.launchd: ASCII text, with no line terminators
csh.cshrc: ASCII text
csh.login: ASCII text
csh.logout: ASCII text
cups: directory
defaults: directory
dnsextd.conf: ASCII text
emond.d: directory
find.codes: empty
fstab.hd: ASCII text
ftpusers: ASCII text
gettytab: ASCII text
group: ASCII text
hosts: ASCII text
hosts.equiv: empty
irbrc: Ruby script text, ASCII text
kern_loader.conf: empty
krb5.keytab: Kerberos Keytab file, realm=LKDC:SHA1.15090DD365668FBA1B0D2D3DD43FCB7CB9381160, principal=afpserver/LKDC:SHA1.15090DD365668FBA1B0D2D3DD43FCB7CB9381160, type=1, date=Tue Jul 2 15:52:04 2019, kvno=2
localtime: timezone data, version 2, 4 gmt time flags, 4 std time flags, no leap seconds, 185 transition times, 4 abbreviation chars
locate.rc: ASCII text
mach_init.d: directory
mach_init_per_login_session.d: directory
mach_init_per_user.d: directory
mail.rc: ASCII text
man.conf: ASCII text
manpaths: ASCII text
manpaths.d: directory
master.passwd: ASCII text
nanorc: ASCII text
networks: ASCII text
newsyslog.conf: ASCII text
newsyslog.d: directory
nfs.conf: ASCII text
notify.conf: ASCII text
ntp.conf: ASCII text
ntp_opendirectory.conf: ASCII text
openldap: directory
pam.d: directory
passwd: ASCII text
paths: ASCII text
paths.d: directory
periodic: directory
pf.anchors: directory
pf.conf: ASCII text
pf.os: ASCII text
php-fpm.conf.default: ASCII text
php-fpm.d: directory
php.ini.default: ASCII text
postfix: directory
ppp: directory
profile: ASCII text
protocols: ASCII text
racoon: directory
rc.common: ASCII text
rc.netboot: POSIX shell script text executable, ASCII text
resolv.conf: ASCII text
rmtab: empty
rpc: ASCII text
rtadvd.conf: ASCII text
security: directory
services: ASCII text
services.broker: ASCII text
shells: ASCII text
snmp: directory
ssh: directory
ssl: directory
sudo_lecture: ASCII text
sudoers: c program text, ASCII text
sudoers.d: directory
syslog.conf: ASCII text
thnuclnt: directory
ttys: ASCII text
wfs: directory
xtab: empty
zprofile: ASCII text
zshrc: ASCII text

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,57 @@
; <<>> DiG 9.11.14-3-Debian <<>> @81.4.108.41 axfr zonetransfer.me +nocookie
; (1 server found)
;; global options: +cmd
zonetransfer.me. 7200 IN SOA nsztm1.digi.ninja. robin.digi.ninja. 2019100801 172800 900 1209600 3600
zonetransfer.me. 300 IN HINFO "Casio fx-700G" "Windows XP"
zonetransfer.me. 301 IN TXT "google-site-verification=tyP28J7JAUHA9fw2sHXMgcCC0I6XBmmoVi04VlMewxA"
zonetransfer.me. 7200 IN MX 0 ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 10 ALT1.ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 10 ALT2.ASPMX.L.GOOGLE.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX2.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX3.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX4.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN MX 20 ASPMX5.GOOGLEMAIL.COM.
zonetransfer.me. 7200 IN A 5.196.105.14
zonetransfer.me. 7200 IN NS nsztm1.digi.ninja.
zonetransfer.me. 7200 IN NS nsztm2.digi.ninja.
_acme-challenge.zonetransfer.me. 301 IN TXT "6Oa05hbUJ9xSsvYy7pApQvwCUSSGgxvrbdizjePEsZI"
_sip._tcp.zonetransfer.me. 14000 IN SRV 0 0 5060 www.zonetransfer.me.
14.105.196.5.IN-ADDR.ARPA.zonetransfer.me. 7200 IN PTR www.zonetransfer.me.
asfdbauthdns.zonetransfer.me. 7900 IN AFSDB 1 asfdbbox.zonetransfer.me.
asfdbbox.zonetransfer.me. 7200 IN A 127.0.0.1
asfdbvolume.zonetransfer.me. 7800 IN AFSDB 1 asfdbbox.zonetransfer.me.
canberra-office.zonetransfer.me. 7200 IN A 202.14.81.230
cmdexec.zonetransfer.me. 300 IN TXT "; ls"
contact.zonetransfer.me. 2592000 IN TXT "Remember to call or email Pippa on +44 123 4567890 or pippa@zonetransfer.me when making DNS changes"
dc-office.zonetransfer.me. 7200 IN A 143.228.181.132
deadbeef.zonetransfer.me. 7201 IN AAAA dead:beaf::
dr.zonetransfer.me. 300 IN LOC 53 20 56.558 N 1 38 33.526 W 0.00m 1m 10000m 10m
DZC.zonetransfer.me. 7200 IN TXT "AbCdEfG"
email.zonetransfer.me. 2222 IN NAPTR 1 1 "P" "E2U+email" "" email.zonetransfer.me.zonetransfer.me.
email.zonetransfer.me. 7200 IN A 74.125.206.26
Hello.zonetransfer.me. 7200 IN TXT "Hi to Josh and all his class"
home.zonetransfer.me. 7200 IN A 127.0.0.1
Info.zonetransfer.me. 7200 IN TXT "ZoneTransfer.me service provided by Robin Wood - robin@digi.ninja. See http://digi.ninja/projects/zonetransferme.php for more information."
internal.zonetransfer.me. 300 IN NS intns1.zonetransfer.me.
internal.zonetransfer.me. 300 IN NS intns2.zonetransfer.me.
intns1.zonetransfer.me. 300 IN A 81.4.108.41
intns2.zonetransfer.me. 300 IN A 167.88.42.94
office.zonetransfer.me. 7200 IN A 4.23.39.254
ipv6actnow.org.zonetransfer.me. 7200 IN AAAA 2001:67c:2e8:11::c100:1332
owa.zonetransfer.me. 7200 IN A 207.46.197.32
robinwood.zonetransfer.me. 302 IN TXT "Robin Wood"
rp.zonetransfer.me. 321 IN RP robin.zonetransfer.me. robinwood.zonetransfer.me.
sip.zonetransfer.me. 3333 IN NAPTR 2 3 "P" "E2U+sip" "!^.*$!sip:customer-service@zonetransfer.me!" .
sqli.zonetransfer.me. 300 IN TXT "' or 1=1 --"
sshock.zonetransfer.me. 7200 IN TXT "() { :]}; echo ShellShocked"
staging.zonetransfer.me. 7200 IN CNAME www.sydneyoperahouse.com.
alltcpportsopen.firewall.test.zonetransfer.me. 301 IN A 127.0.0.1
testing.zonetransfer.me. 301 IN CNAME www.zonetransfer.me.
vpn.zonetransfer.me. 4000 IN A 174.36.59.154
www.zonetransfer.me. 7200 IN A 5.196.105.14
xss.zonetransfer.me. 300 IN TXT "'><script>alert('Boo')</script>"
zonetransfer.me. 7200 IN SOA nsztm1.digi.ninja. robin.digi.ninja. 2019100801 172800 900 1209600 3600
;; Query time: 105 msec
;; SERVER: 81.4.108.41#53(81.4.108.41)
;; WHEN: Wed Mar 25 14:34:55 EDT 2020
;; XFR size: 50 records (messages 1, bytes 1994)

View File

@@ -34,6 +34,9 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/arp-a.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_arp_a = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/arp-a2.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_arp_a2 = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/arp.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_arp_json = json.loads(f.read())
@@ -59,6 +62,9 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/arp-a.json'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_arp_a_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/arp-a2.json'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_arp_a2_json = json.loads(f.read())
def test_arp_centos_7_7(self):
"""
Test 'arp' on Centos 7.7
@@ -107,6 +113,12 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.arp.parse(self.osx_10_14_6_arp_a, quiet=True), self.osx_10_14_6_arp_a_json)
def test_arp_a2_osx_10_14_6(self):
"""
Test 'arp -a' with entries with no ifscope on OSX 10.14.6
"""
self.assertEqual(jc.parsers.arp.parse(self.osx_10_14_6_arp_a2, quiet=True), self.osx_10_14_6_arp_a2_json)
if __name__ == '__main__':
unittest.main()

View File

@@ -28,6 +28,33 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dig-aaaa.out'), 'r', encoding='utf-8') as f:
self.ubuntu_18_4_dig_aaaa = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/dig-axfr.out'), 'r', encoding='utf-8') as f:
self.centos_7_7_dig_axfr = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dig-axfr.out'), 'r', encoding='utf-8') as f:
self.ubuntu_18_4_dig_axfr = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.11.6/dig.out'), 'r', encoding='utf-8') as f:
self.osx_10_11_6_dig = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.11.6/dig-x.out'), 'r', encoding='utf-8') as f:
self.osx_10_11_6_dig_x = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.11.6/dig-aaaa.out'), 'r', encoding='utf-8') as f:
self.osx_10_11_6_dig_aaaa = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/dig.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_dig = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/dig-x.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_dig_x = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/dig-aaaa.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_dig_aaaa = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/dig-axfr.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_dig_axfr = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/dig.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_dig_json = json.loads(f.read())
@@ -47,6 +74,33 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dig-aaaa.json'), 'r', encoding='utf-8') as f:
self.ubuntu_18_4_dig_aaaa_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/dig-axfr.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_dig_axfr_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/dig-axfr.json'), 'r', encoding='utf-8') as f:
self.ubuntu_18_4_dig_axfr_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.11.6/dig.json'), 'r', encoding='utf-8') as f:
self.osx_10_11_6_dig_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.11.6/dig-x.json'), 'r', encoding='utf-8') as f:
self.osx_10_11_6_dig_x_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.11.6/dig-aaaa.json'), 'r', encoding='utf-8') as f:
self.osx_10_11_6_dig_aaaa_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/dig.json'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_dig_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/dig-x.json'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_dig_x_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/dig-aaaa.json'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_dig_aaaa_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/dig-axfr.json'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_dig_axfr_json = json.loads(f.read())
def test_dig_centos_7_7(self):
"""
Test 'dig' on Centos 7.7
@@ -83,6 +137,60 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.dig.parse(self.ubuntu_18_4_dig_aaaa, quiet=True), self.ubuntu_18_4_dig_aaaa_json)
def test_dig_axfr_centos_7_7(self):
"""
Test 'dig axfr' on Centos 7.7
"""
self.assertEqual(jc.parsers.dig.parse(self.centos_7_7_dig_axfr, quiet=True), self.centos_7_7_dig_axfr_json)
def test_dig_axfr_ubuntu_18_4(self):
"""
Test 'dig axfr' on Ubuntu 18.4
"""
self.assertEqual(jc.parsers.dig.parse(self.ubuntu_18_4_dig_axfr, quiet=True), self.ubuntu_18_4_dig_axfr_json)
def test_dig_osx_10_11_6(self):
"""
Test 'dig' on OSX 10.11.6
"""
self.assertEqual(jc.parsers.dig.parse(self.osx_10_11_6_dig, quiet=True), self.osx_10_11_6_dig_json)
def test_dig_x_osx_10_11_6(self):
"""
Test 'dig -x' on OSX 10.11.6
"""
self.assertEqual(jc.parsers.dig.parse(self.osx_10_11_6_dig_x, quiet=True), self.osx_10_11_6_dig_x_json)
def test_dig_aaaa_osx_10_11_6(self):
"""
Test 'dig -aaaa' on OSX 10.11.6
"""
self.assertEqual(jc.parsers.dig.parse(self.osx_10_11_6_dig_aaaa, quiet=True), self.osx_10_11_6_dig_aaaa_json)
def test_dig_osx_10_14_6(self):
"""
Test 'dig' on OSX 10.14.6
"""
self.assertEqual(jc.parsers.dig.parse(self.osx_10_14_6_dig, quiet=True), self.osx_10_14_6_dig_json)
def test_dig_x_osx_10_14_6(self):
"""
Test 'dig -x' on OSX 10.14.6
"""
self.assertEqual(jc.parsers.dig.parse(self.osx_10_14_6_dig_x, quiet=True), self.osx_10_14_6_dig_x_json)
def test_dig_aaaa_osx_10_14_6(self):
"""
Test 'dig -aaaa' on OSX 10.14.6
"""
self.assertEqual(jc.parsers.dig.parse(self.osx_10_14_6_dig_aaaa, quiet=True), self.osx_10_14_6_dig_aaaa_json)
def test_dig_axfr_osx_10_14_6(self):
"""
Test 'dig axfr' on OSX 10.14.6
"""
self.assertEqual(jc.parsers.dig.parse(self.osx_10_14_6_dig_axfr, quiet=True), self.osx_10_14_6_dig_axfr_json)
if __name__ == '__main__':
unittest.main()

View File

@@ -19,6 +19,9 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/file.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_file = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/file2.out'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_file2 = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/file.json'), 'r', encoding='utf-8') as f:
self.centos_7_7_file_json = json.loads(f.read())
@@ -29,6 +32,9 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/file.json'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_file_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/file2.json'), 'r', encoding='utf-8') as f:
self.osx_10_14_6_file2_json = json.loads(f.read())
def test_file_centos_7_7(self):
"""
Test 'file *' on Centos 7.7
@@ -47,6 +53,12 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.file.parse(self.osx_10_14_6_file, quiet=True), self.osx_10_14_6_file_json)
def test_file2_osx_10_14_6(self):
"""
Test 'file *' with filetpe descriptions including colons on OSX 10.14.6
"""
self.assertEqual(jc.parsers.file.parse(self.osx_10_14_6_file2, quiet=True), self.osx_10_14_6_file2_json)
if __name__ == '__main__':
unittest.main()