From 28762aea15cabc9cd8293d725e7f1f0550f8e15d Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Tue, 29 Dec 2020 11:36:20 -0800 Subject: [PATCH 01/24] add hashsum parser --- jc/cli.py | 1 + jc/parsers/hashsum.py | 110 ++++++++++++++++++ tests/fixtures/centos-7.7/md5sum.out | 56 ++++++++++ tests/fixtures/centos-7.7/sha256sum.out | 55 +++++++++ tests/fixtures/centos-7.7/sha384sum.out | 56 ++++++++++ tests/fixtures/osx-10.14.6/md5.out | 104 +++++++++++++++++ tests/fixtures/osx-10.14.6/shasum.out | 142 ++++++++++++++++++++++++ 7 files changed, 524 insertions(+) create mode 100644 jc/parsers/hashsum.py create mode 100644 tests/fixtures/centos-7.7/md5sum.out create mode 100644 tests/fixtures/centos-7.7/sha256sum.out create mode 100644 tests/fixtures/centos-7.7/sha384sum.out create mode 100644 tests/fixtures/osx-10.14.6/md5.out create mode 100644 tests/fixtures/osx-10.14.6/shasum.out diff --git a/jc/cli.py b/jc/cli.py index 516d607a3..c396226d3 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -48,6 +48,7 @@ class info(): 'fstab', 'group', 'gshadow', + 'hashsum', 'history', 'hosts', 'id', diff --git a/jc/parsers/hashsum.py b/jc/parsers/hashsum.py new file mode 100644 index 000000000..6c9791a47 --- /dev/null +++ b/jc/parsers/hashsum.py @@ -0,0 +1,110 @@ +"""jc - JSON CLI output utility `hash sum` command output parser + +Usage (cli): + + $ md5sum | jc --hashsum + + or + + $ jc md5sum file.txt + +Usage (module): + + import jc.parsers.hashsum + result = jc.parsers.hashsum.parse(md5sum_command_output) + +Compatibility: + + 'linux', 'darwin', 'cygwin', 'aix', 'freebsd' + +Examples: + + $ md5sum file.txt | jc --hashsum -p + [] +""" +import jc.utils + + +class info(): + version = '1.0' + description = 'hashsum command and file parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + details = 'Parses MD5 and SHA hash program output' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + magic_commands = ['md5sum', 'md5', 'shasum', 'sha1sum', 'sha224sum', 'sha256sum', 'sha384sum', 'sha512sum'] + + +__version__ = info.version + + +def process(proc_data): + """ + Final processing to conform to the schema. + + Parameters: + + proc_data: (dictionary) raw structured data to process + + Returns: + + List of dictionaries. Structured data with the following schema: + + [ + { + "md5sum": string, + "bar": boolean, + "baz": integer + } + ] + """ + + # rebuild output for added semantic information + return proc_data + + +def parse(data, raw=False, quiet=False): + """ + Main text parsing function + + Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + + Returns: + + List of dictionaries. Raw or processed structured data. + """ + if not quiet: + jc.utils.compatibility(__name__, info.compatible) + + raw_output = [] + + if jc.utils.has_data(data): + + for line in filter(None, data.splitlines()): + # check for legacy md5 command output + if line.startswith('MD5 ('): + file_hash = line.split('=')[1].strip() + file_name = line.split('=')[0].strip() + file_name = file_name[5:] + file_name = file_name[:-1] + # standard md5sum and shasum command output + else: + file_hash = line.split()[0] + file_name = line.split()[1] + + item = { + 'filename': file_name, + 'hash': file_hash + } + raw_output.append(item) + + if raw: + return raw_output + else: + return process(raw_output) diff --git a/tests/fixtures/centos-7.7/md5sum.out b/tests/fixtures/centos-7.7/md5sum.out new file mode 100644 index 000000000..a4e35182b --- /dev/null +++ b/tests/fixtures/centos-7.7/md5sum.out @@ -0,0 +1,56 @@ +65fc958c1add637ec23c4b137aecf3d3 devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm +5b9312ee5aff080927753c63a347707d digout +716fd11c2ac00db109281f7110b8fb9d dmidecode.out +d41d8cd98f00b204e9800998ecf8427e file with spaces in the name +4295be239a14ad77ef3253103de976d2 id-centos.out +01fda0d9ba9a75618b072e64ff512b43 ifcfg.json +e3bff970404527b132dca58031c7286f ifconfig.out +b8b604dc8213d9a6515f2c04bdccfb3b jc +14236ca18714d2b6282758e9b7b46000 jc-1.10.5-linux.sha256 +a13b2843c1e8029a98503bc07613862c jc-1.10.5-linux.tar.gz +d0e05de2651857155f8673dc113272ae jc-1.10.5.rpm +53e4b33fa99c53c28972db666de9b7b3 jc-1.11.1-linux.sha256 +ea4145789224b142361016412cd613b7 jc-1.11.1-linux.tar.gz +c6c5fd21ef572dd6d2629c44ad566425 jc-1.11.1.sha256 +d838680555f84aff7f286dd440b2490b jc-1.11.1.tar.gz +e7d5c22044848539c2cbd9f5b562de9a jc-1.11.2-linux.sha256 +e6d842ead8cfc9a58df9dce7814ee657 jc-1.11.2-linux.tar.gz +24a5005717ab949fd7608aaa77bfeade jc-1.11.8-linux.sha256 +6a84320c7551c51051a748c873d91194 jc-1.11.8-linux.tar.gz +54431e32a1ffa7a90f520a6d8ae966fc jc-1.13.1-linux.sha256 +c7a084d9de6bf1193ea0601a2239fc2b jc-1.13.1-linux.tar.gz +1adf518be9a071131ab105155fee176a jc-1.13.2-linux.sha256 +4d8dd74578bc7817de0834e2349c4466 jc-1.13.2-linux.tar.gz +3b63bfaff06d9c825aa0a1e0d062a10e jc-1.13.4-linux.sha256 +a5d7feae690e2c3d6bc4acef4205b308 jc-1.13.4-linux.tar.gz +90d4fe29d8860adb46f14c99bd27306f jello-1.2.8-linux.sha256 +ea4eadde3abe740d23feb38225e8fe46 jello-1.2.8-linux.tar.gz +c690e9126ed296535046e68bfa02de94 jello-1.2.9-linux.sha256 +28d6899def6cb63e69d6bb8f53365ecd jello-1.2.9-linux.tar.gz +5fed1973e223d1f1e45fccec089cb285 journaljson +e49f9acb33479f59b7be1f94e8daa3db jp +ef49750c3f69ae22b8c456e38e4ea39c jp_1.1.12_linux_x86_64.zip +b86c4c8487e3c0bb656d068886c413b7 jq_twitter.json +d1427e00cbe4e0d1b5b239993ca474b5 jtbl-1.1.6-linux.sha256 +87d36c9c35c5ce23f691634d3faad06e jtbl-1.1.6-linux.tar.gz +b3d0c62d77c4f2861cb1dd7464faaa24 kbls.out +7907a2a62c9f3e1a558ad24ff93fac2c lastb.out +d9920641b832e86c52e1ef380f777f63 lsblk-cols +9ab7407b788aa94b95fe49dbc131b2cb ping-ip-O-D.out +969a0243a76a3bf407e3a24082af8068 ping-ip-O.out +e1e61d18b3e96359940a22c10f30ad34 psfile.txt +9aa6b53e55b3134219c061441d5c0b3f resizeterm.sh +e1e1084c23889b46a055d0f8101c0947 route-6-n.out +4e75a36fcbf5b1f74c42849c641eb7d4 route-6.out +fbb00b1c066988b8d4ce285309fc2a55 routeout +a54b97e7ffb498130a5807c492fd06bd shafile.txt +4aa7a33ccd4d863f2dc34570bc9a4761 ss-aeep.out +9e61faf4a86f484745e9361a6c33249b ssout +eea802ae7bcbb6b63678b5ec68df6212 systemctl.out +8fc90c98a0b0455ba359199e98a3951a top.out +cdbfa0898a3c089a24ecdab4b62e0241 tracepath6.out +c5a2a5d40fcf6617d3ca1fae4766f70c tracepath-cnn.out +dedcbcfcf486d1620c7495c7c9700a02 tr.out +6a90a054f9df3abdfe936c03e53b71d4 who-aH.out +d5c25156c301c14125aaa5d1e8f5adbb who.out +cbe28a0722637d2ea2c07378eba2206e whotext diff --git a/tests/fixtures/centos-7.7/sha256sum.out b/tests/fixtures/centos-7.7/sha256sum.out new file mode 100644 index 000000000..8247a1215 --- /dev/null +++ b/tests/fixtures/centos-7.7/sha256sum.out @@ -0,0 +1,55 @@ +1955249927f4d64b17188766c346ecb8db77010efd9e44f875b41debe8255b44 devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm +ce1b491e2ef2a20964b52dc852b411b0fdeaae8f5b5d30efed1f44657c01777b digout +59f22892a2c115a41e1f0b26c64150ea8d3b00f1ea25f1909a0b67e5f6b1dcb6 dmidecode.out +e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 file with spaces in the name +0757f114c4383437d1b013ebf335360ff24475253ea54d2708a0f28ceddbc7a8 id-centos.out +7afa0e7d4404ff0f45e51176430261eab140ed1940743f298323646a27ce3005 ifcfg.json +a06f5e6c47eabfb1b7e32cee847d120d25f8c7393345546001405b792f762173 ifconfig.out +2a2faee2eea4ce0a6d10069cd95932bbc5ae4b70c6dc913502edbfe39a3f759f jc +1545a9426548e5fd74f32ad7db964c513b933e2bf6608abc08ba562908fa5c19 jc-1.10.5-linux.sha256 +89d4d3b5f978fdf8ad379501c011723486ae09923d778d68ae381b74b3eb0255 jc-1.10.5-linux.tar.gz +e46c5a7921629157c42416d2f47ea30ab815be016a7502f6e4b0f56788c15ba2 jc-1.10.5.rpm +18587497e5b8155d4fb063a0712e968f49770f9f2c3166e5ac6dacbaf24dbfc6 jc-1.11.1-linux.sha256 +70c0c66b9f687eb8b214984238578fba1424f8e5dbf90fe6eab4a5e0db55c40d jc-1.11.1-linux.tar.gz +4f0069a8501a7f9b6e52187ce1e5ec3606ab0be94eeec887a813cae29c3d4c44 jc-1.11.1.sha256 +4847c84a14e76365b81278120261450565344d499b20472f55bb501a3da87350 jc-1.11.1.tar.gz +11c00413590b4f84d6b816d00e9de146f3033de1a800584b50679bc819e6a727 jc-1.11.2-linux.sha256 +bc4a507c807972bff6c736c6932875556d0534ae4ff95530120e75c0d61ddc85 jc-1.11.2-linux.tar.gz +649b292cec88e0792a81113288782a536a7a068652675b971bd114ddd110efa2 jc-1.11.8-linux.sha256 +11b9b8d775d2c9c912f26c851f4e1d8b7ed1274148856e644713f9c48f9a3d04 jc-1.11.8-linux.tar.gz +47f56c6b164cd7cc5875c6a8f29d5fe34ebb6288352a8c6526621563803e2dcb jc-1.13.1-linux.sha256 +6bd22a6cd7fd25d002f167fa9e1af46abc581ac3da8aacbcfec31a403fd2021d jc-1.13.1-linux.tar.gz +b170212b843b6de279937f9601345f955f28ccf41fcfd94d802fc3cc7611c358 jc-1.13.2-linux.sha256 +3e1a4bb0af20f90e040b68eab2a8fe84fa4818099eae5c834a95a5042019007d jc-1.13.2-linux.tar.gz +9c1168b67782627617f806c4e7282a2a9fe133cbbf592baa0ec96dec46e6f27e jc-1.13.4-linux.sha256 +e5419e799b71127636f7c630396c531c358c5f94660a73b3bf03b51ee0982b83 jc-1.13.4-linux.tar.gz +3c2084cebfeb26aa237c893c1543371a0c29aa356114d05c091b5c2e9b188054 jello-1.2.8-linux.sha256 +65afd200472dcf20d8f629f2f20ee2e2bddaabd60cebb751e7cc9ed814f458ce jello-1.2.8-linux.tar.gz +9aac7a7bbdcb5f64b75cc2a5f17d206510ce064d93b58dee13fa5236ea5ad28e jello-1.2.9-linux.sha256 +a95e7d67721430e00e6a342e6aac9fb6343069d6197b0b3c057262e6bf53c4ca jello-1.2.9-linux.tar.gz +fc49676c9cd6282009389f91758ec50bc1ee2110ccd8ec5aa70bb27c2d6a6532 journaljson +cd381415eb8283c41aba775bf18b8557c969a1502024f366d39fd89f72671f95 jp +4edf3eb53ed6e039cb07727cd14c4a6f4d6707fbd04d5cb0e3618fa3b791b329 jp_1.1.12_linux_x86_64.zip +3205543a4e6a28b40c86c4bf8509fb767242883e3ed0713a619d5432e308ae16 jq_twitter.json +dcc894867b1db84699df8a79d6a1d414151d444cec7feed42e8e136bf844d08c jtbl-1.1.6-linux.sha256 +d18d1bb545c534e4cabc9754881fec08a1a3adb96f3c4578517ad191bd49604b jtbl-1.1.6-linux.tar.gz +54bd2863b30de34da9733e7a46edd2485c32ecd74cf2ed7a4af1e59902dd99bd kbls.out +cff67b694bd444870dbc499267a455a0a5fd4809e283a644126579930aee614a lastb.out +46cf694a46f04293b3e5faf0dd1fa00d53e9f04a590136aa0df96611d9af3bdb lsblk-cols +3d27980f6cff1b2ebea4c7e27f00d9d4239022ffc976e146eada539867e89a66 ping-ip-O-D.out +3cbed448e88079c7a4cbf801146e877c844b68ecd35b5181bf85f5efef62864b ping-ip-O.out +98cd30e314cce9f9fe96f6fd4935358ef336da46e001781ab4f09970c02cc8f9 psfile.txt +dc0224031da7b5cecf2a2f17f2d3478e14de1ea14a12fb074972f5fa3ecac751 resizeterm.sh +c60aecaa7f75e7675d1e9fb6dac4ff12d111bdab81e1cc92e3f8f5ba257bf31e route-6-n.out +d9aee0bbfab4b35e2c09aab45f9859ba74cd4384f30a3a728696d29e6b8c6be0 route-6.out +4e72611aea8d9a1a65acbcc516e7ac255fc7d94a4f2915b0746193ccb00d7fd9 routeout +9793d970259c55437667bae568d913a7e4a2c0894ac758214e8478847405dc06 ss-aeep.out +5a3b23c271fe17c4fb34bb96c20233d1eb64e1a3c5f07d8818cd86cc53f97a54 ssout +5ebf02f674876f72fe2f4282fa81af22f4b799e1999122bb18ed4d03c8f6eb60 systemctl.out +a66c17407fe22279bf76d35080ada3918cd96c65f7bc4160ce4267c13a9743d2 top.out +45cfd9c83a151e21efa57b7d7b08691810b6ed4cfd55cb91671a7a6c1cd02487 tracepath6.out +8e9fdb6774a59eed03a81430bbbe4ea44e3df544e92265d774112090b00f051d tracepath-cnn.out +891c97e4c4f32263c1c99c52f50c6d4e8e3fbab94bdf2d6f71f7a44fa4e00239 tr.out +a8494cbbc24713274d96c522c40b44d8528be25e8beb35096f34efdf95679771 who-aH.out +1956b4a9ebf50db3734976d4f2cab0fb929aca2a81043bf37f2b219c4c4c9a1f who.out +64f0a22247fcb0b3aad4be8300a0da942cd09b90e5fea2eab00fae1529e781d1 whotext diff --git a/tests/fixtures/centos-7.7/sha384sum.out b/tests/fixtures/centos-7.7/sha384sum.out new file mode 100644 index 000000000..b74c73967 --- /dev/null +++ b/tests/fixtures/centos-7.7/sha384sum.out @@ -0,0 +1,56 @@ +13dfec928ddd0b8ca477868a2aa8c56b6cf85fe8745f952671e0b0fe52315c4f8500b94ebabfd572cc6f942875c4f17f devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm +75f6c510781b37878f4168a3224b64f49fe6320289fa004579928d58fefb5ceaf91b5af6d431713e2b43dae1b2aefb4a digout +31ca9016e7cdfeba9b8ddef08e34efcf7a45369e890ac4bd57e5336617ebead1f911d8fcc91a8bdb1a86c3512f024a1f dmidecode.out +38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b file with spaces in the name +10efecdd95d23b6a29ae311dd906b24a5c90e2ccd59872b77bdcaa7f55d32d9a95e145b9e1a1208708e9b7cadbe9edab id-centos.out +012fdcea79d9d6a59dcd474f2d9535b2ac9d3a2740709b7de6f54674976537e1361da8f46af4cf465840663267f0f55e ifcfg.json +480e4ba8cfd4fdd25113f518e1b5fb875b398c23b02959bec87ea0cb47e5b6fcfc1d8bc80c208777101c54fc5903cb98 ifconfig.out +485c03f413b3beb95efc2bda08b16804904ccac985eadecb75d52dd91bba2c2601145d51d5ae26568319bf54d0d688ca jc +e732bea551ada4e3254fc339aeaf424859bfc02718e985ad66fee9fed41dcc61cc87f07d648dbf69d32f72eee268ffdb jc-1.10.5-linux.sha256 +2d7400f179eb7c2a43eaa0879c074ed46acd867aafd1947ffd7e9916d32fef55d48c93ac34c75d5931ac84f2b39b4101 jc-1.10.5-linux.tar.gz +5a9762aa33c4dfcf9fdd7fa8c94574f489117497bedced5527e4881c16712a90e2fca9da9a5254ef7dbe294d0a7cd736 jc-1.10.5.rpm +b16c7a5c51f15bbab9d30270f24f2a95cec840dc24e30fc52806cc110b55a2440c9597f69115f1db7bb9bc3d4fefbbf2 jc-1.11.1-linux.sha256 +4ef3741864807f19da58e2c74a0ff2a95f2cc92030f315b9cca5d8a1592f64493bc91ad8a567a4c01e4fd5068964ff9c jc-1.11.1-linux.tar.gz +04bb4b8b79c4dfb6b978ce467b9451a71d3b1e3c5c42d16eab4b918308ffc9ceb7730cab077764705f8e5cc7d4a2fa3e jc-1.11.1.sha256 +7b507374c22cb5f169980453d9e2a661505bb20260f079d3e0cd0c4b751ec75f3d3390b8f8d7290b6d748e9057af7377 jc-1.11.1.tar.gz +1020219aa19a10478b870c9195602c1f22766aed751d05272ea8a6a1dd04c0f8bc030b8906eb6dbbb0194fbd63a5c204 jc-1.11.2-linux.sha256 +40207fa8a89b7d9dbbbbf76d155e12f2f8664f929c88367eac6257b0f617343d08b27e8daea1598ac77e27d47d3f9e28 jc-1.11.2-linux.tar.gz +2b5bf8c4e623f02f8e75ba352206e36f5c5e049d8b8dc4f33e3fe93465947c0a28af2a4505cd55ae6f8f328dd7db978f jc-1.11.8-linux.sha256 +76bf73980528612ce2229e4fa0ae6111092c31e1a5593efd3870aba40e1a2c8651ef9cb3e9fbb607a1cfab246f489327 jc-1.11.8-linux.tar.gz +3d6bc8c0e43d5d46c786e5a6ca1fe21001997a3eae0aee3b04faec8f592ee4bd40bc84511cec23b1d8bd74569499d3cb jc-1.13.1-linux.sha256 +adc8bea97698073f9c382788a7f60f906019255e23f98b4997ebae0146351f7ae365d12cf60b359c6c94ee338524a729 jc-1.13.1-linux.tar.gz +60b43d3431dd2a4d214b66b1752449a8c43ec01b3ace18661dd5485d4d3bae98fd83ea4c01c2cff5f9038ac7cec4f7b4 jc-1.13.2-linux.sha256 +8a44aa9777fa63320ffc16b75da5cfa5c45ca8d6a47f49d06b719e251c7296aef23b471c3ba55d12bb530fedaf962303 jc-1.13.2-linux.tar.gz +03991acac3c3ae520604c949e8e3dbc62ab13a9d031b29a983b7ff28853adff1fe206f14937035f4219c7f5e56dc2571 jc-1.13.4-linux.sha256 +60f2939c9dcb700e3ef7b258e460e49d3ec650c36a4bab107ac6eb55c7f587b242fcb50d81b0fd1739df6261b26674c0 jc-1.13.4-linux.tar.gz +367a0c7423ea4541372b6e04ecd453b9d39346b05739debbfdf2e7e037db469bfc7b16b25be3a252b1927284023201c9 jello-1.2.8-linux.sha256 +d44cd208c480d0cb212483225e16fe85944dbd608d67ad9e40ee5868948a3822f64087567e4da096ae0004cb60055f15 jello-1.2.8-linux.tar.gz +008370792aa150cdcb54eb13810e9acce56ae1ebfe2d63cc75529e3caf86f5f9573157dca932d448a43c7f3e05c242b3 jello-1.2.9-linux.sha256 +4433710be95f6a2bddf213fbd6d0c85a763c6043b09d00a863f6903d09d00c6167277bd32ae77c8fc943d7753f682a0b jello-1.2.9-linux.tar.gz +655ef2c57cf0bccc47853bc11e20b3ebf4c3fb6a65c63d2389983425e95081ab1f2e70a557932037846b35c5f3db7b2a journaljson +a7723d2c9aad90303866d1bed77cca43a7f88bdd6956a23d6b24767c1abadbd26d3a5d01d39af5305f0f0be49c596313 jp +3410d5208919ab9b336fdedcb06f647666eb5be9c2cb887256aa67406f971b845985ba6c3c9f7152f3ded6b6f4c683d3 jp_1.1.12_linux_x86_64.zip +1c9a0249597bdf89590091c41a21020c4805adb89e9c40a85359c99a2faac2cb4b9c3c80c4535064e3a263c285a773f6 jq_twitter.json +351c7b0459e35fd87e9ce2957d58a73e5c55d72ddf2429f37a989bd69d9c9ad5c7e8a9885f989e3e56ee1d50a9627a55 jtbl-1.1.6-linux.sha256 +b6053a4bdf2bcc87c6ee2dc6d1c5572c1a78b1060d8a7f21dd6bca950cdf1518515df16b1f83dfecea2f498f1be23fac jtbl-1.1.6-linux.tar.gz +6f149d8f1a8c41a480b21f815537beabd97107358038c406b88f285c6637504c7d70f0fe4f3609ea55be35cc6267fb45 kbls.out +343bb57833a3629596d7fbfb0a7a56a5b775a5bb660773071f8c68ab9c8c84ceb3bdaf9ef8067fedc655627ba4d61a8b lastb.out +de0c500038bdeb1f57aa3789f74c630862cf3dbb83e9a8140d071959e048d8c144f190a9039975fe1d28c97982d80675 lsblk-cols +8debc85c75c169ded39bc8e91ce752c791d63df52f7aa8c7d110a755f764e41f2cbb4ef89650652971e7e76576662982 ping-ip-O-D.out +b93bf926e1e202a13cf5d122be10ffc69f15843f7f419f4b8e631d5ad0d4efd4123e5d9fc64b220ee906a5731c169d84 ping-ip-O.out +61f62147b30c6027548e04154c79548667853afdd930223183c96d13c484bda9251150e81ab8da86fcd15be8eb533aa8 psfile.txt +82fa64a5e3fd3c54a9f7c32c7407b2134bbc3826b66d66a95c7f673a5c6b8c9190cfdfba6c0dde858399cd680cf4ddaa resizeterm.sh +1da45fcd09bb7fe5d4805fc4a550dfa893c99c968568ca28c3c075f201579ff862f160bb80bcdda0b2276f35ebe0300f route-6-n.out +5ae84602fda703c954ae735d99a5b9b8ba31ae4967c2e647f91ea4199da1bd3a7467346272cdc217eecdf157802d4e45 route-6.out +dfc31420a5bc92730403711c71cc8e7939792c6c43d9cdead33673e6a37615a37d109c844643dc0308f84187d6ce51ff routeout +0d16335ada920c8003d571a33087ebc67e2183c069231ff949bb2f0f90df0bad99903a5db7aa5d21954de476a77b1ff9 shafile.txt +dceaccf3fa9161ca1f658f14dfb2b005f0737b8bc128d459ed60850964182e7a311446019ed93d00341f300aa2c4dc33 ss-aeep.out +9d72cdff3306fb0c14fd270e5dac3a07cd01163a529d57d6d36b761e9d4bfda458f73ddf55c2e352cd382e8d8d1cd7b5 ssout +7a33126d2954e2b295da2672219b1a4e6a30775c9c5da56832b1e9c89c9827846394bef5d22960e3b24e1dfd721061ad systemctl.out +90ce1a3b0ec04b9c96d50abe52956ef66327324dc9295cac734d69386ce2a280bc95baadd87b9f175f1272066b90804d top.out +0435b36b1ca56d7af51d42c73cc12c5fca6e559047c264e0945426958143aa6380d2e7ed22ced18cf4efdbfe454b23dd tracepath6.out +ab22a6cd069cc3e92da92aa09c807e75aa4fb98c495ae51a09b7231e2299773af32a901fadccd4d1dfbea6bfdfaafdfb tracepath-cnn.out +ad02ffb0876c5a7407034d128b5bc3a158e9cea4ba060b99062d2d2c12f2c1130826e8196b879f271254a46d69e9e450 tr.out +2c3b90566c37f9a900497ff58824943ad029c13a7db4b3e04d453cd7163c21e2da330a7e8b45084da68755d7aa7771e6 who-aH.out +873f8c55de4f8e24f1a355fde9da07bba0b8cd74271c194a101f7478e7b5464bf4e8f708da48d9439af0be8c298a94eb who.out +230ddb573e3b9c83389fcb358603d944bb20ed3603cdd45727bcda6f1e366cb6715676ec4bc19c6db8e427e45ca696b6 whotext diff --git a/tests/fixtures/osx-10.14.6/md5.out b/tests/fixtures/osx-10.14.6/md5.out new file mode 100644 index 000000000..501bd8caf --- /dev/null +++ b/tests/fixtures/osx-10.14.6/md5.out @@ -0,0 +1,104 @@ +MD5 (arp-a.out) = cd645f685a1e57ebf3bc4fd44a7f87b8 +MD5 (arp-v.out) = f4a00c29e88f61b90df90fb845560008 +MD5 (arp.out) = d6581a3e0cab3addca50055467478f62 +MD5 (blkid-ip-multi.out) = 3350258648ce551b8c2bd34474626ddf +MD5 (blkid-ip-udev-multi.out) = ea53b01490770a7c7ae3dd949c4cc331 +MD5 (blkid-ip-udev.out) = 886b05fcfde5d3260597f33ff06133c5 +MD5 (blkid-sda2.out) = ce61777185a52166672aab2b47456f76 +MD5 (blkid.out) = f96852cc8becd6ab7ef896157b75f83f +MD5 (crontab-u.out) = 1971d74d4503c38c8cba9a20950c7142 +MD5 (crontab.out) = 79d08ddb75d959e66a77a880711a589c +MD5 (df-h.out) = fe0aca4e47216d2a6023afb83dbcacc1 +MD5 (df.out) = b03b56e8c8aa7ffcc2c7263aa452b9b8 +MD5 (dig-aaaa.out) = 65cb08b0527f1aaa5fd9af528e01fa93 +MD5 (dig-axfr.out) = e14018715ac457a9c8221acc635423c0 +MD5 (dig-x.out) = f899dca2cdd00cf6857f076d2c146544 +MD5 (dig.out) = 87c94ba4aedf74b58f7ad1dd1be39fd6 +MD5 (dmidecode.out) = 716fd11c2ac00db109281f7110b8fb9d +MD5 (du.out) = 5e6effd8e33d5603112e11b70154b594 +MD5 (env.out) = f6649e65066f4f58ae322d590f60b21c +MD5 (file.out) = b31670a7e4374d3733efe061efd990b6 +MD5 (free-h.out) = 791202071bba2f4ec186465c1eb72cb2 +MD5 (free.out) = f60e300aeeec5e14f787fc64286ef881 +MD5 (fstab.out) = 172d0b92d95b0add305e1633cd89d5e7 +MD5 (group.out) = 7f9d72d4fbe5bb0d3dd03350362b7668 +MD5 (gshadow.out) = 7f3fbc5f73010bbb3e0c119cf99f4767 +MD5 (history.out) = 0dfd64d0491e5d4c5d31e6276da2ff2e +MD5 (hosts.out) = 09fc278fadbac8d2bbf48176eaaf036e +MD5 (id.out) = 4295be239a14ad77ef3253103de976d2 +MD5 (ifconfig.out) = 2826744b3cd0e3c48771ce54e90dc39e +MD5 (iptables-filter-line-numbers.out) = b8649a444af2bddee903f168a41ce46f +MD5 (iptables-filter-nv.out) = 336e547bce260445882bf7e23b518a57 +MD5 (iptables-filter.out) = e6f269961b7dc89fdf9b9890b6276188 +MD5 (iptables-mangle.out) = 8c90c0e4b4d788eac17f3f46059eb925 +MD5 (iptables-nat.out) = 63c9ad6dfae4aab5627f0aa315b280ad +MD5 (iptables-raw.out) = 84d1e56220d1cd71816b34e4f55708fc +MD5 (jobs.out) = 6d39d7fe623da58d78d68263f7f36c7d +MD5 (last-w.out) = e52003b655197e16eb22b56631581315 +MD5 (last.out) = b6a8e0c710ffdff032363a60fbc6fe50 +MD5 (lastb.out) = d54fd268bbb2c0c8d01131fc4c375d6d +MD5 (ls-R-newlines.out) = 10155b2f641ba164492e43a2a0d1e9f6 +MD5 (ls-R.out) = d7122233dbad630ca41d43b887a25c25 +MD5 (ls-al.out) = 1e2205fe2a9efbbb098121f5f1701a16 +MD5 (ls-alR.out) = 29468973ce06788a31c1e7f896e7dc60 +MD5 (ls-alh.out) = a623550a81b18e4ff0491acd668d64ea +MD5 (ls-glob.out) = 1ca05ceb4ac0ea884824d97c2ac2f4ac +MD5 (ls-l-newlines.out) = afc4e7099c12af1fd7149e79b5d6e13d +MD5 (ls-lR-newlines.out) = 18053c80357f38b46ac44810c3240936 +MD5 (ls-newlines.out) = 725dc56e746fb8d50ef038ca90c99fbf +MD5 (ls.out) = baf35fa8f15d14cdfb9bb80d0d55bb99 +MD5 (lsblk-allcols.out) = 92d1f8f7590656a8e2fe0e42ee734c41 +MD5 (lsblk.out) = 911234ff25f9db205dbe0504c601e37e +MD5 (lsmod.out) = ebfe5f57aee09dcdb1f0b299fee596aa +MD5 (lsof-sudo.out) = a275bb6d9f2528bb4b66a525b8a6d774 +MD5 (lsof.out) = 6a72858a679e26efa5c66f54fe279295 +MD5 (md5sum.out) = 7ea6da1b6f6baab8d9d952eb33378956 +MD5 (mount.out) = 34159c041f57a7f2a86424cd2c49fed3 +MD5 (netstat-i.out) = bd982936895b6df38a7fdbe86df8bf5c +MD5 (netstat-l.out) = 8fbb9c077bdf66c17c112c8a11b1e733 +MD5 (netstat-p.out) = 9f2db696db8338cee0c56efc253e1f6a +MD5 (netstat-r.out) = ffcd2cc4ab8699f06f4705e7103b879f +MD5 (netstat-rne.out) = 3e119bbbd3f6dbb432d27dc29fec8f98 +MD5 (netstat-rnee.out) = 27f2be6ede761a53ae573de06fd3d0d0 +MD5 (netstat-sudo-aeep.out) = a8f7a37a3261bcaef6c6a3620e49464b +MD5 (netstat-sudo-lnp.out) = 4e46e684a905957b8e6d04b1a1c244da +MD5 (netstat.out) = 928d2f5d9f27fd6645930c4178cce819 +MD5 (ntpq-p.out) = f5f84643e4240025307caab50f8990a9 +MD5 (ntpq-pn.out) = 2b2fa305e490f388bd85684c0b26e2bf +MD5 (passwd.out) = 2c0199adf1b3e018c1945860f8372619 +MD5 (ping-hostname-O-D-p-s.out) = 5b660694bf79aea1d52a392ff1092448 +MD5 (ping-hostname-O-p.out) = ab4ff8264db941a0662b5b731ab46af0 +MD5 (ping-hostname-O.out) = 1d9af746b203413e0ffc211f3185a8e4 +MD5 (ping-ip-O-D.out) = 9ab7407b788aa94b95fe49dbc131b2cb +MD5 (ping-ip-O.out) = 969a0243a76a3bf407e3a24082af8068 +MD5 (ping-ip-dup.out) = 35204577e61b34a55df836f7b4920c7e +MD5 (ping6-hostname-O-D-p-s.out) = be18cfed73d79091dcc665e5887903db +MD5 (ping6-hostname-O-p.out) = bf28730f5973b3d37f9f42d80b6858b1 +MD5 (ping6-ip-O-D-p.out) = 2665133538e2d4a0828204522227a5e6 +MD5 (ping6-ip-O-p.out) = bc03b9e491ecb25155e44082a8254f19 +MD5 (ping6-ip-dup.out) = ff5e5d69174a3240e87432827dd5e25d +MD5 (pip-list.out) = 99809973a445fb2801a3bb14b4bc03bc +MD5 (pip-show.out) = 691ef00b38abbdbd2e8cc1ea856b9d83 +MD5 (ps-axu.out) = e913baab1861defe5c69cc4bb6475779 +MD5 (ps-ef.out) = ed826e38db572628ca5a2d70435a6302 +MD5 (route-6-n.out) = 7bc3917b8b7e8aabd1ea853dc03eb431 +MD5 (route-6.out) = f9691632cd72b4e956bba68d6d93a0fc +MD5 (route-vn.out) = 3e119bbbd3f6dbb432d27dc29fec8f98 +MD5 (route.out) = 439adfcce99306d3419ec0fd7760f383 +MD5 (shadow.out) = 9da686e5fb53fcb4c3934f7fc2859b5a +MD5 (shasum.out) = dcecd94ddf63d7fd70c2636fd723289b +MD5 (ss-sudo-a.out) = ee2ed1455bebac67298a72b83bdfb85e +MD5 (stat.out) = ea9e5cc3f2ec9971b5c43203e17801ac +MD5 (sysctl-a.out) = 9db459aaf7689f8c66911b57b05a5b9f +MD5 (systemctl-ls.out) = db3a53f9828d305ff294764ad6d3f860 +MD5 (systemctl-luf.out) = adf988243f7ff5a2f71a5868031e5ec3 +MD5 (systemctl.out) = 446fb73dbc66db1246d044386c4e57d6 +MD5 (timedatectl.out) = 47bd61915dab99979127fb3dc1b1e493 +MD5 (tracepath.out) = 269d7cf5b938004f251dc7824e601198 +MD5 (tracepath6.out) = 6569334c8e6b6b22018f22c6628f0797 +MD5 (traceroute.out) = 2bf8b3c7bc6e175ebb21fd0102f6b2b9 +MD5 (uname-a.out) = 38ed43650f1fa000d196b391aea1c96d +MD5 (uptime.out) = b27aa536d962989c2639b9f022bd365f +MD5 (w.out) = 1a93af5b819721a085166825024a615e +MD5 (who-a.out) = dceb435d3c30ad3fad4102cea4ed461a +MD5 (who.out) = 19e19c6f49753ff44e85f4a82539592d diff --git a/tests/fixtures/osx-10.14.6/shasum.out b/tests/fixtures/osx-10.14.6/shasum.out new file mode 100644 index 000000000..6d2d66cef --- /dev/null +++ b/tests/fixtures/osx-10.14.6/shasum.out @@ -0,0 +1,142 @@ +b6701d0bd547292d2a51541cefdb78589c4ebc65 airport-I.json +3749387a837ee7e47a14c172b7b4eb922d569201 airport-I.out +0baafe93a582feff71e80ccc6d392cbb35fbea11 airport-s.json +4ae92f7948a96e95316ac2da00c162daad18802b airport-s.out +a214bc7b92039d33b0a9ee1ee343df6b6d81c11f arp-a.json +713e3d0a664c8ae8bd9a87c91269c22fca558849 arp-a.out +c8ede52d8e96ab137d56e5d9ccbdf0739300039d arp-a2.json +a8cdbf7229c45386c09a842100011421ab74adda arp-a2.out +3eea0498b884eb626b3f36484ceb46035626607a df-h.json +bec48433f817a8ab28699d4b4410935fc054e7d7 df-h.out +0cc078c31215b815519928597108fc08d6974abf df.json +41ea13d77c82c840bf014c2d68e494bf5f090e86 df.out +3e70a7cba6aaa1a873e845a54336adf67fe66b1e dig-aaaa.json +22417524735d1281e202a7a803c4721d7a212e4d dig-aaaa.out +0c476125b50536e31521597da15ecf1007c01056 dig-axfr.json +66220fa199b9c59cf980bb5b3eefcbf7454cf4f7 dig-axfr.out +47c5bc3266cdc42e9f64007dca72d59a30e910d0 dig-x.json +9f49a5c47cd70a52fd59a801cc5a5ac7c0ab6b74 dig-x.out +41f3c14ec6bcaa040b3c139447c6c08ef2dc322f dig.json +2c2efae28e1a5bba3da1f5fe10d7a48451dcad61 dig.out +ca632dce5c358eb19189972a6ce3eb7bac410f1a du.json +4709f16a60b101dd624880abcb6917cb3b052da6 du.out +6641aa32d84f1036e72592fefa16819788761dd6 file.json +64aa7e0a87d8f337a1affa434b7bdcf973be5a04 file.out +c011e362d46b8bb3fff6670c3506ca103045f4cd file2.json +dfc3c3c4af63be1909e44443b3b90e10b687d6c8 file2.out +260404f3d2096264f5ca8570ca3295aa5e282878 group.json +39ebabcaf4296712c3e32edb6133bca98a2455e8 group.out +7f1718884b12c28035847719a19ea415e7215bb8 id.json +28a7474eed1b514fafb0d8b33ade8a1b7b261546 id.out +2ed6453465f3fdb41520599129741c8955e0e956 ifconfig.json +bb0bc5bb5d8891015373a6ff3d743ee9593de432 ifconfig.out +2ea05804d196a0bf9894d8106766b04d5bf89a11 ifconfig2.json +f46ecf7bb5be88af18d53415c31392d1968d2fc2 ifconfig2.out +3c2ec4597c76f026b4e635385a3f7e579b861bd2 last.json +f92c6ff31c0b520d41768a044c794670ce8d13cb last.out +54a0b33790ef7369fb901db4c45bfe5ef7e77edc ls-R-newlines.json +098c351f68519fd7ac37ac1721e64ad8ed4a3600 ls-R-newlines.out +22c3aabad0c0cbe32a2ed8bd4d1cef92a904f0ea ls-R.json +69861b855e1e7e6394da3645e853a3430e99e5b2 ls-R.out +8c1fc69e7a8e96d06566afa3a7759fcd17d77207 ls-al.json +4e6eb0ef6e29a436d15b3e380a6e34c57583e94f ls-al.out +67d5b302d734e71859160cb44b13b5cdfae03e34 ls-alR.json +5ee5666ccd067a72e0cff4d1b337c46858205ce2 ls-alR.out +31b53afda162e8ccf356916f2cc36dc73eb6b45b ls-alh.json +81e09c8a18b7e0a051147e697b83fdb5f88ab137 ls-alh.out +f9c06fe2c8a2a44987112d16d29cea359d67c4e4 ls-glob.json +6d38df7da56e2b898db200cbc68ffa2f9324b567 ls-glob.out +839158b81641f70e09fae84c5f11d4fa3d371922 ls-l-newlines.json +21999fb50ffff3d098ff5cb44de92002b8637611 ls-l-newlines.out +58e4a9d0deddd57483880b4f509f769fa1df6514 ls-lR-empty-folder.json +827125e173a978aaea11b6170dfbefb3dab30375 ls-lR-empty-folder.out +28b5390d64492453187a5c3e3548854bafa5a3dc ls-lR-newlines.json +5b17d8c3c27c90cce7fb2c42e79ac94d5f79fba4 ls-lR-newlines.out +5f1a2ab24626d2819bab4c5f1f974b4dcd32d18d ls-newlines.json +f103cb8013553c1c997d151449a519090c844c4d ls-newlines.out +8dbfd075967f928fcf773cdf740abc3442e1e7de ls.json +e378d603819b3ba7a4615151f3cbdd8c985c5278 ls.out +e6169a0ab655b81d17ca46460f4bf4628e3f15c7 md5.out +3427962301eb775c296a75532ece6f24197723df mount.json +6301b0589f75e4190e37ec071068a9a43a6ba6b9 mount.out +e32f5571cb2995d01e336076a84ded88f2dce782 mount2.json +9c90e82e74c553bf649b1a43047cd9c062006fa3 mount2.out +4c210803690e8eabbdfd00c1346014d7b99ab5e2 netstat-Abn.json +45b809ce7d4c68685ee9293c07640b1e5fb3420a netstat-Abn.out +1be1890e206000e8865c81a7cf1c5ac17cc5e9e1 netstat-An.json +1a7c5cee6339d8e22973a31542ae62f330fa4057 netstat-An.out +a9cce6324e62373b66066ab6a292b121ae3fb121 netstat-i.json +1d699a308356aee6179caa84a07940f32c262a33 netstat-i.out +4a851ca343d7d17ece41cb66e9c1f5d046281514 netstat-r.json +04b4ff8c424c836beb179f24402e09df6b91d8da netstat-r.out +b10b6ce7d98e61c4f819fc06aaa3ba4c11e6196e netstat-rnl.json +b354f8cdfea44bb84fc8b9f16e40621387b1e20b netstat-rnl.out +eeb92d12bea70acc01bbe015668f774dda779fac netstat.json +00cc660ce9de89889435978f4e82aac8d30352ba netstat.out +ad454cef94895c6f32538dcc57e5c35609543f0b passwd.json +98b96a259d79f457c619dfb4b5949f03f9ee0e91 passwd.out +affe7ac91927e00c05da4c4f0b985da7feb94ee7 ping-hostname-p.json +22f6da2c47dfafcdf2921bbd0dd664a59c118017 ping-hostname-p.out +37573a86ea3bc3a66fe5a401e0259e9ba86bd7e2 ping-hostname-s.json +3515f57ef15df3b015b1e589eb76298c6923eee3 ping-hostname-s.out +70cae13fff2b53913bc279bad20ae6502b93142c ping-hostname.json +805da101ba12f150e5164352cc61634fe08a6f04 ping-hostname.out +463ab3f969bac22b644c3e60c9b33db570c50ec1 ping-ip-dup.json +f051d883e339ce8bfbee8d14ddc68007aec2ce16 ping-ip-dup.out +6c433892a236a8b56c38c92ab65d958a81b25015 ping-ip-p.json +fbec6b8034ef32a48dcd392c8d8d7a8150720cee ping-ip-p.out +a8e7418abf65967c554f6006a6d18d1103936b56 ping-ip-s.json +d688174811c7e7df05135bfb7d53a2ce91878632 ping-ip-s.out +a8bad79ae89852a0d6f42f78c0d3b651e825f62f ping-ip.json +30e35e7a4b16c9e0332e4cf5ae7d4a6e90e2ad63 ping-ip.out +aa762025cefbe4f9a481ba622ade333ad3d3f946 ping6-hostname-p.json +534382c4698f18187ded6259576f08da0a6f338f ping6-hostname-p.out +6600a05b117ddcfc80ee3554176857a78b18325a ping6-hostname-s.json +f86a97e16952be0e70b7c7fde247d2793230ecdc ping6-hostname-s.out +9b2c9765859a05d8ae779764284db45d9dea742c ping6-hostname.json +1782a580d6d92d38a64e02fca30b936c1bacc05d ping6-hostname.out +838ef123a0000e59271d4703c7ac6c4a7d3eab7e ping6-ip-dup.json +0d3af3ab2a5c5f886842abc0bfe06288307604b3 ping6-ip-dup.out +9911d8c4d08f3ba111c6b24dbbbecab701e4a371 ping6-ip-p.json +b176952e7b3fbc0f94c9b6aa261e7a239938621f ping6-ip-p.out +0fa62d9840efc9867c7c74458474c4daa6725e0e ping6-ip-s.json +bed5d50ae2be215b612187f109046916a7071bdf ping6-ip-s.out +d229293a2a0fd0e7c04d65202a58de207a85db93 ping6-ip.json +b96290f3f61068eef9c79e52155560a9f6eebb24 ping6-ip.out +3a095f602ade8ab11443ce8321288dc8a52f4eb6 pip-list.json +684f9f178d8a4a9183bdfa91139b65fff7a8bd02 pip-list.out +2775dfd4a51a3b7a6eb41effa9299e72377ac573 pip-show.json +c9159fd0cd5af49fd81a6181b38161072a0a8536 pip-show.out +b68b29c17b6877bb014a8b99d528ed15476c9ff1 ps-axu.json +c09f2435054539d3f891e803babfcebbc2e3d2c5 ps-axu.out +2a7bae5f336e662ef58fb1213d0f20c593f8e5ce ps-ef.json +a13032d2a724f4918a3c4941c4babaf55f2c7a40 ps-ef.out +a95208df396194dac9b1196f3bbe989e174fc3fb stat.json +301016ffc0cbb6a0ebb4a31987aae2208068af45 stat.out +d791375d84f3c209bf71f637e76d46d1fe4459c7 sysctl-a.json +61827f5423ee2a3891f38b23baf671676869d930 sysctl-a.out +0096b180a1674f935df6e7314db0f3aac3d15758 traceroute-asn.json +14983d7528df1dc1004b254991e49cba30cf9861 traceroute-asn.out +5cfde477f5e966db9887c4ac6700e94ec3f5e214 traceroute-mult-addresses.json +b05bfa6c8371c68eb5d761de6b7a7933c3dba78b traceroute-mult-addresses.out +92b288e194981920428fbb910717a3ff17605fd0 traceroute-no-header.json +fbb81722ae676195c0f44f0f8c41bd860fb33b52 traceroute-no-header.out +17b5bdc7456d2cda893eba40e5568d6e4835c2ce traceroute-q.json +cb777f386ff2f81c6516b560a4ddea149235f573 traceroute-q.out +f62ee48530285cb1cecd5ef0dc4e8cc16b278676 traceroute.json +d080112c55e7fbd6578720fe290db6dea2d8df46 traceroute.out +94e80f496b128bf459cf59ac07d5645be70e5b8f traceroute6-mult-addresses.json +67677c5474a466a6c1ae86557077326eed70db71 traceroute6-mult-addresses.out +94e80f496b128bf459cf59ac07d5645be70e5b8f traceroute6.json +526c631415d055333b4f29adca186bfe7f498dca traceroute6.out +9ac73b33611d1cee071cdb224178c4ea4c164804 uname-a.json +ac286f0f6e2bb695f693674babdae22203765a79 uname-a.out +0fc09dc308ca8159ed485d2c5aad6139eab3d44b uname.out +43f78bcbeb78e30f0df5ae0e988605627a453c72 uptime.json +bfbfc9814f48e430aef9579bb6bfd4873b257a17 uptime.out +2ecd2bd1a1c243852181d00fdd26bdd471221f16 w.json +1d5f7d4db7d413717f661e95c239312b94045ebc w.out +31d74136f77fff6ba685e43d17097b045642bbec who-a.json +2e6094a345b9f3205decacba3d7f1fcf8471dd82 who-a.out +0b6eddc1d363f49c46c963b97dc0387e9e7a23b7 who.json +996aa62bdea95a8c4561f4208db3fd7719eb695f who.out From 8157dcfdb1868548b7c8ca692e6be25f80bb2c2c Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Tue, 29 Dec 2020 12:25:20 -0800 Subject: [PATCH 02/24] fix for files with spaces in the name --- jc/parsers/hashsum.py | 47 +++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/jc/parsers/hashsum.py b/jc/parsers/hashsum.py index 6c9791a47..c23fe77a3 100644 --- a/jc/parsers/hashsum.py +++ b/jc/parsers/hashsum.py @@ -2,7 +2,7 @@ Usage (cli): - $ md5sum | jc --hashsum + $ md5sum file.txt | jc --hashsum or @@ -19,8 +19,34 @@ Examples: - $ md5sum file.txt | jc --hashsum -p - [] + $ md5sum * | jc --hashsum -p + [ + { + "filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm", + "hash": "65fc958c1add637ec23c4b137aecf3d3" + }, + { + "filename": "digout", + "hash": "5b9312ee5aff080927753c63a347707d" + }, + { + "filename": "dmidecode.out", + "hash": "716fd11c2ac00db109281f7110b8fb9d" + }, + { + "filename": "file with spaces in the name", + "hash": "d41d8cd98f00b204e9800998ecf8427e" + }, + { + "filename": "id-centos.out", + "hash": "4295be239a14ad77ef3253103de976d2" + }, + { + "filename": "ifcfg.json", + "hash": "01fda0d9ba9a75618b072e64ff512b43" + }, + ... + ] """ import jc.utils @@ -54,14 +80,13 @@ def process(proc_data): [ { - "md5sum": string, - "bar": boolean, - "baz": integer + "filename": string, + "hash": string, } ] """ - # rebuild output for added semantic information + # no further processing for this parser return proc_data @@ -89,14 +114,14 @@ def parse(data, raw=False, quiet=False): for line in filter(None, data.splitlines()): # check for legacy md5 command output if line.startswith('MD5 ('): - file_hash = line.split('=')[1].strip() - file_name = line.split('=')[0].strip() + file_hash = line.split('=', maxsplit=1)[1].strip() + file_name = line.split('=', maxsplit=1)[0].strip() file_name = file_name[5:] file_name = file_name[:-1] # standard md5sum and shasum command output else: - file_hash = line.split()[0] - file_name = line.split()[1] + file_hash = line.split(maxsplit=1)[0] + file_name = line.split(maxsplit=1)[1] item = { 'filename': file_name, From 44a740605705bd0ecfde2a6bcc7a826e1010dcf0 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Tue, 29 Dec 2020 12:51:43 -0800 Subject: [PATCH 03/24] add hashsum tests --- tests/fixtures/centos-7.7/md5sum.json | 1 + tests/fixtures/centos-7.7/sha256sum.json | 1 + tests/fixtures/centos-7.7/sha384sum.json | 1 + tests/fixtures/osx-10.14.6/md5.json | 1 + tests/fixtures/osx-10.14.6/shasum.json | 1 + tests/test_hashsum.py | 82 ++++++++++++++++++++++++ 6 files changed, 87 insertions(+) create mode 100644 tests/fixtures/centos-7.7/md5sum.json create mode 100644 tests/fixtures/centos-7.7/sha256sum.json create mode 100644 tests/fixtures/centos-7.7/sha384sum.json create mode 100644 tests/fixtures/osx-10.14.6/md5.json create mode 100644 tests/fixtures/osx-10.14.6/shasum.json create mode 100644 tests/test_hashsum.py diff --git a/tests/fixtures/centos-7.7/md5sum.json b/tests/fixtures/centos-7.7/md5sum.json new file mode 100644 index 000000000..1ab2ca9d9 --- /dev/null +++ b/tests/fixtures/centos-7.7/md5sum.json @@ -0,0 +1 @@ +[{"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm", "hash": "65fc958c1add637ec23c4b137aecf3d3"}, {"filename": "digout", "hash": "5b9312ee5aff080927753c63a347707d"}, {"filename": "dmidecode.out", "hash": "716fd11c2ac00db109281f7110b8fb9d"}, {"filename": "file with spaces in the name", "hash": "d41d8cd98f00b204e9800998ecf8427e"}, {"filename": "id-centos.out", "hash": "4295be239a14ad77ef3253103de976d2"}, {"filename": "ifcfg.json", "hash": "01fda0d9ba9a75618b072e64ff512b43"}, {"filename": "ifconfig.out", "hash": "e3bff970404527b132dca58031c7286f"}, {"filename": "jc", "hash": "b8b604dc8213d9a6515f2c04bdccfb3b"}, {"filename": "jc-1.10.5-linux.sha256", "hash": "14236ca18714d2b6282758e9b7b46000"}, {"filename": "jc-1.10.5-linux.tar.gz", "hash": "a13b2843c1e8029a98503bc07613862c"}, {"filename": "jc-1.10.5.rpm", "hash": "d0e05de2651857155f8673dc113272ae"}, {"filename": "jc-1.11.1-linux.sha256", "hash": "53e4b33fa99c53c28972db666de9b7b3"}, {"filename": "jc-1.11.1-linux.tar.gz", "hash": "ea4145789224b142361016412cd613b7"}, {"filename": "jc-1.11.1.sha256", "hash": "c6c5fd21ef572dd6d2629c44ad566425"}, {"filename": "jc-1.11.1.tar.gz", "hash": "d838680555f84aff7f286dd440b2490b"}, {"filename": "jc-1.11.2-linux.sha256", "hash": "e7d5c22044848539c2cbd9f5b562de9a"}, {"filename": "jc-1.11.2-linux.tar.gz", "hash": "e6d842ead8cfc9a58df9dce7814ee657"}, {"filename": "jc-1.11.8-linux.sha256", "hash": "24a5005717ab949fd7608aaa77bfeade"}, {"filename": "jc-1.11.8-linux.tar.gz", "hash": "6a84320c7551c51051a748c873d91194"}, {"filename": "jc-1.13.1-linux.sha256", "hash": "54431e32a1ffa7a90f520a6d8ae966fc"}, {"filename": "jc-1.13.1-linux.tar.gz", "hash": "c7a084d9de6bf1193ea0601a2239fc2b"}, {"filename": "jc-1.13.2-linux.sha256", "hash": "1adf518be9a071131ab105155fee176a"}, {"filename": "jc-1.13.2-linux.tar.gz", "hash": "4d8dd74578bc7817de0834e2349c4466"}, {"filename": "jc-1.13.4-linux.sha256", "hash": "3b63bfaff06d9c825aa0a1e0d062a10e"}, {"filename": "jc-1.13.4-linux.tar.gz", "hash": "a5d7feae690e2c3d6bc4acef4205b308"}, {"filename": "jello-1.2.8-linux.sha256", "hash": "90d4fe29d8860adb46f14c99bd27306f"}, {"filename": "jello-1.2.8-linux.tar.gz", "hash": "ea4eadde3abe740d23feb38225e8fe46"}, {"filename": "jello-1.2.9-linux.sha256", "hash": "c690e9126ed296535046e68bfa02de94"}, {"filename": "jello-1.2.9-linux.tar.gz", "hash": "28d6899def6cb63e69d6bb8f53365ecd"}, {"filename": "journaljson", "hash": "5fed1973e223d1f1e45fccec089cb285"}, {"filename": "jp", "hash": "e49f9acb33479f59b7be1f94e8daa3db"}, {"filename": "jp_1.1.12_linux_x86_64.zip", "hash": "ef49750c3f69ae22b8c456e38e4ea39c"}, {"filename": "jq_twitter.json", "hash": "b86c4c8487e3c0bb656d068886c413b7"}, {"filename": "jtbl-1.1.6-linux.sha256", "hash": "d1427e00cbe4e0d1b5b239993ca474b5"}, {"filename": "jtbl-1.1.6-linux.tar.gz", "hash": "87d36c9c35c5ce23f691634d3faad06e"}, {"filename": "kbls.out", "hash": "b3d0c62d77c4f2861cb1dd7464faaa24"}, {"filename": "lastb.out", "hash": "7907a2a62c9f3e1a558ad24ff93fac2c"}, {"filename": "lsblk-cols", "hash": "d9920641b832e86c52e1ef380f777f63"}, {"filename": "ping-ip-O-D.out", "hash": "9ab7407b788aa94b95fe49dbc131b2cb"}, {"filename": "ping-ip-O.out", "hash": "969a0243a76a3bf407e3a24082af8068"}, {"filename": "psfile.txt", "hash": "e1e61d18b3e96359940a22c10f30ad34"}, {"filename": "resizeterm.sh", "hash": "9aa6b53e55b3134219c061441d5c0b3f"}, {"filename": "route-6-n.out", "hash": "e1e1084c23889b46a055d0f8101c0947"}, {"filename": "route-6.out", "hash": "4e75a36fcbf5b1f74c42849c641eb7d4"}, {"filename": "routeout", "hash": "fbb00b1c066988b8d4ce285309fc2a55"}, {"filename": "shafile.txt", "hash": "a54b97e7ffb498130a5807c492fd06bd"}, {"filename": "ss-aeep.out", "hash": "4aa7a33ccd4d863f2dc34570bc9a4761"}, {"filename": "ssout", "hash": "9e61faf4a86f484745e9361a6c33249b"}, {"filename": "systemctl.out", "hash": "eea802ae7bcbb6b63678b5ec68df6212"}, {"filename": "top.out", "hash": "8fc90c98a0b0455ba359199e98a3951a"}, {"filename": "tracepath6.out", "hash": "cdbfa0898a3c089a24ecdab4b62e0241"}, {"filename": "tracepath-cnn.out", "hash": "c5a2a5d40fcf6617d3ca1fae4766f70c"}, {"filename": "tr.out", "hash": "dedcbcfcf486d1620c7495c7c9700a02"}, {"filename": "who-aH.out", "hash": "6a90a054f9df3abdfe936c03e53b71d4"}, {"filename": "who.out", "hash": "d5c25156c301c14125aaa5d1e8f5adbb"}, {"filename": "whotext", "hash": "cbe28a0722637d2ea2c07378eba2206e"}] diff --git a/tests/fixtures/centos-7.7/sha256sum.json b/tests/fixtures/centos-7.7/sha256sum.json new file mode 100644 index 000000000..488d3422b --- /dev/null +++ b/tests/fixtures/centos-7.7/sha256sum.json @@ -0,0 +1 @@ +[{"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm", "hash": "1955249927f4d64b17188766c346ecb8db77010efd9e44f875b41debe8255b44"}, {"filename": "digout", "hash": "ce1b491e2ef2a20964b52dc852b411b0fdeaae8f5b5d30efed1f44657c01777b"}, {"filename": "dmidecode.out", "hash": "59f22892a2c115a41e1f0b26c64150ea8d3b00f1ea25f1909a0b67e5f6b1dcb6"}, {"filename": "file with spaces in the name", "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}, {"filename": "id-centos.out", "hash": "0757f114c4383437d1b013ebf335360ff24475253ea54d2708a0f28ceddbc7a8"}, {"filename": "ifcfg.json", "hash": "7afa0e7d4404ff0f45e51176430261eab140ed1940743f298323646a27ce3005"}, {"filename": "ifconfig.out", "hash": "a06f5e6c47eabfb1b7e32cee847d120d25f8c7393345546001405b792f762173"}, {"filename": "jc", "hash": "2a2faee2eea4ce0a6d10069cd95932bbc5ae4b70c6dc913502edbfe39a3f759f"}, {"filename": "jc-1.10.5-linux.sha256", "hash": "1545a9426548e5fd74f32ad7db964c513b933e2bf6608abc08ba562908fa5c19"}, {"filename": "jc-1.10.5-linux.tar.gz", "hash": "89d4d3b5f978fdf8ad379501c011723486ae09923d778d68ae381b74b3eb0255"}, {"filename": "jc-1.10.5.rpm", "hash": "e46c5a7921629157c42416d2f47ea30ab815be016a7502f6e4b0f56788c15ba2"}, {"filename": "jc-1.11.1-linux.sha256", "hash": "18587497e5b8155d4fb063a0712e968f49770f9f2c3166e5ac6dacbaf24dbfc6"}, {"filename": "jc-1.11.1-linux.tar.gz", "hash": "70c0c66b9f687eb8b214984238578fba1424f8e5dbf90fe6eab4a5e0db55c40d"}, {"filename": "jc-1.11.1.sha256", "hash": "4f0069a8501a7f9b6e52187ce1e5ec3606ab0be94eeec887a813cae29c3d4c44"}, {"filename": "jc-1.11.1.tar.gz", "hash": "4847c84a14e76365b81278120261450565344d499b20472f55bb501a3da87350"}, {"filename": "jc-1.11.2-linux.sha256", "hash": "11c00413590b4f84d6b816d00e9de146f3033de1a800584b50679bc819e6a727"}, {"filename": "jc-1.11.2-linux.tar.gz", "hash": "bc4a507c807972bff6c736c6932875556d0534ae4ff95530120e75c0d61ddc85"}, {"filename": "jc-1.11.8-linux.sha256", "hash": "649b292cec88e0792a81113288782a536a7a068652675b971bd114ddd110efa2"}, {"filename": "jc-1.11.8-linux.tar.gz", "hash": "11b9b8d775d2c9c912f26c851f4e1d8b7ed1274148856e644713f9c48f9a3d04"}, {"filename": "jc-1.13.1-linux.sha256", "hash": "47f56c6b164cd7cc5875c6a8f29d5fe34ebb6288352a8c6526621563803e2dcb"}, {"filename": "jc-1.13.1-linux.tar.gz", "hash": "6bd22a6cd7fd25d002f167fa9e1af46abc581ac3da8aacbcfec31a403fd2021d"}, {"filename": "jc-1.13.2-linux.sha256", "hash": "b170212b843b6de279937f9601345f955f28ccf41fcfd94d802fc3cc7611c358"}, {"filename": "jc-1.13.2-linux.tar.gz", "hash": "3e1a4bb0af20f90e040b68eab2a8fe84fa4818099eae5c834a95a5042019007d"}, {"filename": "jc-1.13.4-linux.sha256", "hash": "9c1168b67782627617f806c4e7282a2a9fe133cbbf592baa0ec96dec46e6f27e"}, {"filename": "jc-1.13.4-linux.tar.gz", "hash": "e5419e799b71127636f7c630396c531c358c5f94660a73b3bf03b51ee0982b83"}, {"filename": "jello-1.2.8-linux.sha256", "hash": "3c2084cebfeb26aa237c893c1543371a0c29aa356114d05c091b5c2e9b188054"}, {"filename": "jello-1.2.8-linux.tar.gz", "hash": "65afd200472dcf20d8f629f2f20ee2e2bddaabd60cebb751e7cc9ed814f458ce"}, {"filename": "jello-1.2.9-linux.sha256", "hash": "9aac7a7bbdcb5f64b75cc2a5f17d206510ce064d93b58dee13fa5236ea5ad28e"}, {"filename": "jello-1.2.9-linux.tar.gz", "hash": "a95e7d67721430e00e6a342e6aac9fb6343069d6197b0b3c057262e6bf53c4ca"}, {"filename": "journaljson", "hash": "fc49676c9cd6282009389f91758ec50bc1ee2110ccd8ec5aa70bb27c2d6a6532"}, {"filename": "jp", "hash": "cd381415eb8283c41aba775bf18b8557c969a1502024f366d39fd89f72671f95"}, {"filename": "jp_1.1.12_linux_x86_64.zip", "hash": "4edf3eb53ed6e039cb07727cd14c4a6f4d6707fbd04d5cb0e3618fa3b791b329"}, {"filename": "jq_twitter.json", "hash": "3205543a4e6a28b40c86c4bf8509fb767242883e3ed0713a619d5432e308ae16"}, {"filename": "jtbl-1.1.6-linux.sha256", "hash": "dcc894867b1db84699df8a79d6a1d414151d444cec7feed42e8e136bf844d08c"}, {"filename": "jtbl-1.1.6-linux.tar.gz", "hash": "d18d1bb545c534e4cabc9754881fec08a1a3adb96f3c4578517ad191bd49604b"}, {"filename": "kbls.out", "hash": "54bd2863b30de34da9733e7a46edd2485c32ecd74cf2ed7a4af1e59902dd99bd"}, {"filename": "lastb.out", "hash": "cff67b694bd444870dbc499267a455a0a5fd4809e283a644126579930aee614a"}, {"filename": "lsblk-cols", "hash": "46cf694a46f04293b3e5faf0dd1fa00d53e9f04a590136aa0df96611d9af3bdb"}, {"filename": "ping-ip-O-D.out", "hash": "3d27980f6cff1b2ebea4c7e27f00d9d4239022ffc976e146eada539867e89a66"}, {"filename": "ping-ip-O.out", "hash": "3cbed448e88079c7a4cbf801146e877c844b68ecd35b5181bf85f5efef62864b"}, {"filename": "psfile.txt", "hash": "98cd30e314cce9f9fe96f6fd4935358ef336da46e001781ab4f09970c02cc8f9"}, {"filename": "resizeterm.sh", "hash": "dc0224031da7b5cecf2a2f17f2d3478e14de1ea14a12fb074972f5fa3ecac751"}, {"filename": "route-6-n.out", "hash": "c60aecaa7f75e7675d1e9fb6dac4ff12d111bdab81e1cc92e3f8f5ba257bf31e"}, {"filename": "route-6.out", "hash": "d9aee0bbfab4b35e2c09aab45f9859ba74cd4384f30a3a728696d29e6b8c6be0"}, {"filename": "routeout", "hash": "4e72611aea8d9a1a65acbcc516e7ac255fc7d94a4f2915b0746193ccb00d7fd9"}, {"filename": "ss-aeep.out", "hash": "9793d970259c55437667bae568d913a7e4a2c0894ac758214e8478847405dc06"}, {"filename": "ssout", "hash": "5a3b23c271fe17c4fb34bb96c20233d1eb64e1a3c5f07d8818cd86cc53f97a54"}, {"filename": "systemctl.out", "hash": "5ebf02f674876f72fe2f4282fa81af22f4b799e1999122bb18ed4d03c8f6eb60"}, {"filename": "top.out", "hash": "a66c17407fe22279bf76d35080ada3918cd96c65f7bc4160ce4267c13a9743d2"}, {"filename": "tracepath6.out", "hash": "45cfd9c83a151e21efa57b7d7b08691810b6ed4cfd55cb91671a7a6c1cd02487"}, {"filename": "tracepath-cnn.out", "hash": "8e9fdb6774a59eed03a81430bbbe4ea44e3df544e92265d774112090b00f051d"}, {"filename": "tr.out", "hash": "891c97e4c4f32263c1c99c52f50c6d4e8e3fbab94bdf2d6f71f7a44fa4e00239"}, {"filename": "who-aH.out", "hash": "a8494cbbc24713274d96c522c40b44d8528be25e8beb35096f34efdf95679771"}, {"filename": "who.out", "hash": "1956b4a9ebf50db3734976d4f2cab0fb929aca2a81043bf37f2b219c4c4c9a1f"}, {"filename": "whotext", "hash": "64f0a22247fcb0b3aad4be8300a0da942cd09b90e5fea2eab00fae1529e781d1"}] diff --git a/tests/fixtures/centos-7.7/sha384sum.json b/tests/fixtures/centos-7.7/sha384sum.json new file mode 100644 index 000000000..265b57a43 --- /dev/null +++ b/tests/fixtures/centos-7.7/sha384sum.json @@ -0,0 +1 @@ +[{"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm", "hash": "13dfec928ddd0b8ca477868a2aa8c56b6cf85fe8745f952671e0b0fe52315c4f8500b94ebabfd572cc6f942875c4f17f"}, {"filename": "digout", "hash": "75f6c510781b37878f4168a3224b64f49fe6320289fa004579928d58fefb5ceaf91b5af6d431713e2b43dae1b2aefb4a"}, {"filename": "dmidecode.out", "hash": "31ca9016e7cdfeba9b8ddef08e34efcf7a45369e890ac4bd57e5336617ebead1f911d8fcc91a8bdb1a86c3512f024a1f"}, {"filename": "file with spaces in the name", "hash": "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"}, {"filename": "id-centos.out", "hash": "10efecdd95d23b6a29ae311dd906b24a5c90e2ccd59872b77bdcaa7f55d32d9a95e145b9e1a1208708e9b7cadbe9edab"}, {"filename": "ifcfg.json", "hash": "012fdcea79d9d6a59dcd474f2d9535b2ac9d3a2740709b7de6f54674976537e1361da8f46af4cf465840663267f0f55e"}, {"filename": "ifconfig.out", "hash": "480e4ba8cfd4fdd25113f518e1b5fb875b398c23b02959bec87ea0cb47e5b6fcfc1d8bc80c208777101c54fc5903cb98"}, {"filename": "jc", "hash": "485c03f413b3beb95efc2bda08b16804904ccac985eadecb75d52dd91bba2c2601145d51d5ae26568319bf54d0d688ca"}, {"filename": "jc-1.10.5-linux.sha256", "hash": "e732bea551ada4e3254fc339aeaf424859bfc02718e985ad66fee9fed41dcc61cc87f07d648dbf69d32f72eee268ffdb"}, {"filename": "jc-1.10.5-linux.tar.gz", "hash": "2d7400f179eb7c2a43eaa0879c074ed46acd867aafd1947ffd7e9916d32fef55d48c93ac34c75d5931ac84f2b39b4101"}, {"filename": "jc-1.10.5.rpm", "hash": "5a9762aa33c4dfcf9fdd7fa8c94574f489117497bedced5527e4881c16712a90e2fca9da9a5254ef7dbe294d0a7cd736"}, {"filename": "jc-1.11.1-linux.sha256", "hash": "b16c7a5c51f15bbab9d30270f24f2a95cec840dc24e30fc52806cc110b55a2440c9597f69115f1db7bb9bc3d4fefbbf2"}, {"filename": "jc-1.11.1-linux.tar.gz", "hash": "4ef3741864807f19da58e2c74a0ff2a95f2cc92030f315b9cca5d8a1592f64493bc91ad8a567a4c01e4fd5068964ff9c"}, {"filename": "jc-1.11.1.sha256", "hash": "04bb4b8b79c4dfb6b978ce467b9451a71d3b1e3c5c42d16eab4b918308ffc9ceb7730cab077764705f8e5cc7d4a2fa3e"}, {"filename": "jc-1.11.1.tar.gz", "hash": "7b507374c22cb5f169980453d9e2a661505bb20260f079d3e0cd0c4b751ec75f3d3390b8f8d7290b6d748e9057af7377"}, {"filename": "jc-1.11.2-linux.sha256", "hash": "1020219aa19a10478b870c9195602c1f22766aed751d05272ea8a6a1dd04c0f8bc030b8906eb6dbbb0194fbd63a5c204"}, {"filename": "jc-1.11.2-linux.tar.gz", "hash": "40207fa8a89b7d9dbbbbf76d155e12f2f8664f929c88367eac6257b0f617343d08b27e8daea1598ac77e27d47d3f9e28"}, {"filename": "jc-1.11.8-linux.sha256", "hash": "2b5bf8c4e623f02f8e75ba352206e36f5c5e049d8b8dc4f33e3fe93465947c0a28af2a4505cd55ae6f8f328dd7db978f"}, {"filename": "jc-1.11.8-linux.tar.gz", "hash": "76bf73980528612ce2229e4fa0ae6111092c31e1a5593efd3870aba40e1a2c8651ef9cb3e9fbb607a1cfab246f489327"}, {"filename": "jc-1.13.1-linux.sha256", "hash": "3d6bc8c0e43d5d46c786e5a6ca1fe21001997a3eae0aee3b04faec8f592ee4bd40bc84511cec23b1d8bd74569499d3cb"}, {"filename": "jc-1.13.1-linux.tar.gz", "hash": "adc8bea97698073f9c382788a7f60f906019255e23f98b4997ebae0146351f7ae365d12cf60b359c6c94ee338524a729"}, {"filename": "jc-1.13.2-linux.sha256", "hash": "60b43d3431dd2a4d214b66b1752449a8c43ec01b3ace18661dd5485d4d3bae98fd83ea4c01c2cff5f9038ac7cec4f7b4"}, {"filename": "jc-1.13.2-linux.tar.gz", "hash": "8a44aa9777fa63320ffc16b75da5cfa5c45ca8d6a47f49d06b719e251c7296aef23b471c3ba55d12bb530fedaf962303"}, {"filename": "jc-1.13.4-linux.sha256", "hash": "03991acac3c3ae520604c949e8e3dbc62ab13a9d031b29a983b7ff28853adff1fe206f14937035f4219c7f5e56dc2571"}, {"filename": "jc-1.13.4-linux.tar.gz", "hash": "60f2939c9dcb700e3ef7b258e460e49d3ec650c36a4bab107ac6eb55c7f587b242fcb50d81b0fd1739df6261b26674c0"}, {"filename": "jello-1.2.8-linux.sha256", "hash": "367a0c7423ea4541372b6e04ecd453b9d39346b05739debbfdf2e7e037db469bfc7b16b25be3a252b1927284023201c9"}, {"filename": "jello-1.2.8-linux.tar.gz", "hash": "d44cd208c480d0cb212483225e16fe85944dbd608d67ad9e40ee5868948a3822f64087567e4da096ae0004cb60055f15"}, {"filename": "jello-1.2.9-linux.sha256", "hash": "008370792aa150cdcb54eb13810e9acce56ae1ebfe2d63cc75529e3caf86f5f9573157dca932d448a43c7f3e05c242b3"}, {"filename": "jello-1.2.9-linux.tar.gz", "hash": "4433710be95f6a2bddf213fbd6d0c85a763c6043b09d00a863f6903d09d00c6167277bd32ae77c8fc943d7753f682a0b"}, {"filename": "journaljson", "hash": "655ef2c57cf0bccc47853bc11e20b3ebf4c3fb6a65c63d2389983425e95081ab1f2e70a557932037846b35c5f3db7b2a"}, {"filename": "jp", "hash": "a7723d2c9aad90303866d1bed77cca43a7f88bdd6956a23d6b24767c1abadbd26d3a5d01d39af5305f0f0be49c596313"}, {"filename": "jp_1.1.12_linux_x86_64.zip", "hash": "3410d5208919ab9b336fdedcb06f647666eb5be9c2cb887256aa67406f971b845985ba6c3c9f7152f3ded6b6f4c683d3"}, {"filename": "jq_twitter.json", "hash": "1c9a0249597bdf89590091c41a21020c4805adb89e9c40a85359c99a2faac2cb4b9c3c80c4535064e3a263c285a773f6"}, {"filename": "jtbl-1.1.6-linux.sha256", "hash": "351c7b0459e35fd87e9ce2957d58a73e5c55d72ddf2429f37a989bd69d9c9ad5c7e8a9885f989e3e56ee1d50a9627a55"}, {"filename": "jtbl-1.1.6-linux.tar.gz", "hash": "b6053a4bdf2bcc87c6ee2dc6d1c5572c1a78b1060d8a7f21dd6bca950cdf1518515df16b1f83dfecea2f498f1be23fac"}, {"filename": "kbls.out", "hash": "6f149d8f1a8c41a480b21f815537beabd97107358038c406b88f285c6637504c7d70f0fe4f3609ea55be35cc6267fb45"}, {"filename": "lastb.out", "hash": "343bb57833a3629596d7fbfb0a7a56a5b775a5bb660773071f8c68ab9c8c84ceb3bdaf9ef8067fedc655627ba4d61a8b"}, {"filename": "lsblk-cols", "hash": "de0c500038bdeb1f57aa3789f74c630862cf3dbb83e9a8140d071959e048d8c144f190a9039975fe1d28c97982d80675"}, {"filename": "ping-ip-O-D.out", "hash": "8debc85c75c169ded39bc8e91ce752c791d63df52f7aa8c7d110a755f764e41f2cbb4ef89650652971e7e76576662982"}, {"filename": "ping-ip-O.out", "hash": "b93bf926e1e202a13cf5d122be10ffc69f15843f7f419f4b8e631d5ad0d4efd4123e5d9fc64b220ee906a5731c169d84"}, {"filename": "psfile.txt", "hash": "61f62147b30c6027548e04154c79548667853afdd930223183c96d13c484bda9251150e81ab8da86fcd15be8eb533aa8"}, {"filename": "resizeterm.sh", "hash": "82fa64a5e3fd3c54a9f7c32c7407b2134bbc3826b66d66a95c7f673a5c6b8c9190cfdfba6c0dde858399cd680cf4ddaa"}, {"filename": "route-6-n.out", "hash": "1da45fcd09bb7fe5d4805fc4a550dfa893c99c968568ca28c3c075f201579ff862f160bb80bcdda0b2276f35ebe0300f"}, {"filename": "route-6.out", "hash": "5ae84602fda703c954ae735d99a5b9b8ba31ae4967c2e647f91ea4199da1bd3a7467346272cdc217eecdf157802d4e45"}, {"filename": "routeout", "hash": "dfc31420a5bc92730403711c71cc8e7939792c6c43d9cdead33673e6a37615a37d109c844643dc0308f84187d6ce51ff"}, {"filename": "shafile.txt", "hash": "0d16335ada920c8003d571a33087ebc67e2183c069231ff949bb2f0f90df0bad99903a5db7aa5d21954de476a77b1ff9"}, {"filename": "ss-aeep.out", "hash": "dceaccf3fa9161ca1f658f14dfb2b005f0737b8bc128d459ed60850964182e7a311446019ed93d00341f300aa2c4dc33"}, {"filename": "ssout", "hash": "9d72cdff3306fb0c14fd270e5dac3a07cd01163a529d57d6d36b761e9d4bfda458f73ddf55c2e352cd382e8d8d1cd7b5"}, {"filename": "systemctl.out", "hash": "7a33126d2954e2b295da2672219b1a4e6a30775c9c5da56832b1e9c89c9827846394bef5d22960e3b24e1dfd721061ad"}, {"filename": "top.out", "hash": "90ce1a3b0ec04b9c96d50abe52956ef66327324dc9295cac734d69386ce2a280bc95baadd87b9f175f1272066b90804d"}, {"filename": "tracepath6.out", "hash": "0435b36b1ca56d7af51d42c73cc12c5fca6e559047c264e0945426958143aa6380d2e7ed22ced18cf4efdbfe454b23dd"}, {"filename": "tracepath-cnn.out", "hash": "ab22a6cd069cc3e92da92aa09c807e75aa4fb98c495ae51a09b7231e2299773af32a901fadccd4d1dfbea6bfdfaafdfb"}, {"filename": "tr.out", "hash": "ad02ffb0876c5a7407034d128b5bc3a158e9cea4ba060b99062d2d2c12f2c1130826e8196b879f271254a46d69e9e450"}, {"filename": "who-aH.out", "hash": "2c3b90566c37f9a900497ff58824943ad029c13a7db4b3e04d453cd7163c21e2da330a7e8b45084da68755d7aa7771e6"}, {"filename": "who.out", "hash": "873f8c55de4f8e24f1a355fde9da07bba0b8cd74271c194a101f7478e7b5464bf4e8f708da48d9439af0be8c298a94eb"}, {"filename": "whotext", "hash": "230ddb573e3b9c83389fcb358603d944bb20ed3603cdd45727bcda6f1e366cb6715676ec4bc19c6db8e427e45ca696b6"}] diff --git a/tests/fixtures/osx-10.14.6/md5.json b/tests/fixtures/osx-10.14.6/md5.json new file mode 100644 index 000000000..5b607b725 --- /dev/null +++ b/tests/fixtures/osx-10.14.6/md5.json @@ -0,0 +1 @@ +[{"filename": "arp-a.out", "hash": "cd645f685a1e57ebf3bc4fd44a7f87b8"}, {"filename": "arp-v.out", "hash": "f4a00c29e88f61b90df90fb845560008"}, {"filename": "arp.out", "hash": "d6581a3e0cab3addca50055467478f62"}, {"filename": "blkid-ip-multi.out", "hash": "3350258648ce551b8c2bd34474626ddf"}, {"filename": "blkid-ip-udev-multi.out", "hash": "ea53b01490770a7c7ae3dd949c4cc331"}, {"filename": "blkid-ip-udev.out", "hash": "886b05fcfde5d3260597f33ff06133c5"}, {"filename": "blkid-sda2.out", "hash": "ce61777185a52166672aab2b47456f76"}, {"filename": "blkid.out", "hash": "f96852cc8becd6ab7ef896157b75f83f"}, {"filename": "crontab-u.out", "hash": "1971d74d4503c38c8cba9a20950c7142"}, {"filename": "crontab.out", "hash": "79d08ddb75d959e66a77a880711a589c"}, {"filename": "df-h.out", "hash": "fe0aca4e47216d2a6023afb83dbcacc1"}, {"filename": "df.out", "hash": "b03b56e8c8aa7ffcc2c7263aa452b9b8"}, {"filename": "dig-aaaa.out", "hash": "65cb08b0527f1aaa5fd9af528e01fa93"}, {"filename": "dig-axfr.out", "hash": "e14018715ac457a9c8221acc635423c0"}, {"filename": "dig-x.out", "hash": "f899dca2cdd00cf6857f076d2c146544"}, {"filename": "dig.out", "hash": "87c94ba4aedf74b58f7ad1dd1be39fd6"}, {"filename": "dmidecode.out", "hash": "716fd11c2ac00db109281f7110b8fb9d"}, {"filename": "du.out", "hash": "5e6effd8e33d5603112e11b70154b594"}, {"filename": "env.out", "hash": "f6649e65066f4f58ae322d590f60b21c"}, {"filename": "file.out", "hash": "b31670a7e4374d3733efe061efd990b6"}, {"filename": "free-h.out", "hash": "791202071bba2f4ec186465c1eb72cb2"}, {"filename": "free.out", "hash": "f60e300aeeec5e14f787fc64286ef881"}, {"filename": "fstab.out", "hash": "172d0b92d95b0add305e1633cd89d5e7"}, {"filename": "group.out", "hash": "7f9d72d4fbe5bb0d3dd03350362b7668"}, {"filename": "gshadow.out", "hash": "7f3fbc5f73010bbb3e0c119cf99f4767"}, {"filename": "history.out", "hash": "0dfd64d0491e5d4c5d31e6276da2ff2e"}, {"filename": "hosts.out", "hash": "09fc278fadbac8d2bbf48176eaaf036e"}, {"filename": "id.out", "hash": "4295be239a14ad77ef3253103de976d2"}, {"filename": "ifconfig.out", "hash": "2826744b3cd0e3c48771ce54e90dc39e"}, {"filename": "iptables-filter-line-numbers.out", "hash": "b8649a444af2bddee903f168a41ce46f"}, {"filename": "iptables-filter-nv.out", "hash": "336e547bce260445882bf7e23b518a57"}, {"filename": "iptables-filter.out", "hash": "e6f269961b7dc89fdf9b9890b6276188"}, {"filename": "iptables-mangle.out", "hash": "8c90c0e4b4d788eac17f3f46059eb925"}, {"filename": "iptables-nat.out", "hash": "63c9ad6dfae4aab5627f0aa315b280ad"}, {"filename": "iptables-raw.out", "hash": "84d1e56220d1cd71816b34e4f55708fc"}, {"filename": "jobs.out", "hash": "6d39d7fe623da58d78d68263f7f36c7d"}, {"filename": "last-w.out", "hash": "e52003b655197e16eb22b56631581315"}, {"filename": "last.out", "hash": "b6a8e0c710ffdff032363a60fbc6fe50"}, {"filename": "lastb.out", "hash": "d54fd268bbb2c0c8d01131fc4c375d6d"}, {"filename": "ls-R-newlines.out", "hash": "10155b2f641ba164492e43a2a0d1e9f6"}, {"filename": "ls-R.out", "hash": "d7122233dbad630ca41d43b887a25c25"}, {"filename": "ls-al.out", "hash": "1e2205fe2a9efbbb098121f5f1701a16"}, {"filename": "ls-alR.out", "hash": "29468973ce06788a31c1e7f896e7dc60"}, {"filename": "ls-alh.out", "hash": "a623550a81b18e4ff0491acd668d64ea"}, {"filename": "ls-glob.out", "hash": "1ca05ceb4ac0ea884824d97c2ac2f4ac"}, {"filename": "ls-l-newlines.out", "hash": "afc4e7099c12af1fd7149e79b5d6e13d"}, {"filename": "ls-lR-newlines.out", "hash": "18053c80357f38b46ac44810c3240936"}, {"filename": "ls-newlines.out", "hash": "725dc56e746fb8d50ef038ca90c99fbf"}, {"filename": "ls.out", "hash": "baf35fa8f15d14cdfb9bb80d0d55bb99"}, {"filename": "lsblk-allcols.out", "hash": "92d1f8f7590656a8e2fe0e42ee734c41"}, {"filename": "lsblk.out", "hash": "911234ff25f9db205dbe0504c601e37e"}, {"filename": "lsmod.out", "hash": "ebfe5f57aee09dcdb1f0b299fee596aa"}, {"filename": "lsof-sudo.out", "hash": "a275bb6d9f2528bb4b66a525b8a6d774"}, {"filename": "lsof.out", "hash": "6a72858a679e26efa5c66f54fe279295"}, {"filename": "md5sum.out", "hash": "7ea6da1b6f6baab8d9d952eb33378956"}, {"filename": "mount.out", "hash": "34159c041f57a7f2a86424cd2c49fed3"}, {"filename": "netstat-i.out", "hash": "bd982936895b6df38a7fdbe86df8bf5c"}, {"filename": "netstat-l.out", "hash": "8fbb9c077bdf66c17c112c8a11b1e733"}, {"filename": "netstat-p.out", "hash": "9f2db696db8338cee0c56efc253e1f6a"}, {"filename": "netstat-r.out", "hash": "ffcd2cc4ab8699f06f4705e7103b879f"}, {"filename": "netstat-rne.out", "hash": "3e119bbbd3f6dbb432d27dc29fec8f98"}, {"filename": "netstat-rnee.out", "hash": "27f2be6ede761a53ae573de06fd3d0d0"}, {"filename": "netstat-sudo-aeep.out", "hash": "a8f7a37a3261bcaef6c6a3620e49464b"}, {"filename": "netstat-sudo-lnp.out", "hash": "4e46e684a905957b8e6d04b1a1c244da"}, {"filename": "netstat.out", "hash": "928d2f5d9f27fd6645930c4178cce819"}, {"filename": "ntpq-p.out", "hash": "f5f84643e4240025307caab50f8990a9"}, {"filename": "ntpq-pn.out", "hash": "2b2fa305e490f388bd85684c0b26e2bf"}, {"filename": "passwd.out", "hash": "2c0199adf1b3e018c1945860f8372619"}, {"filename": "ping-hostname-O-D-p-s.out", "hash": "5b660694bf79aea1d52a392ff1092448"}, {"filename": "ping-hostname-O-p.out", "hash": "ab4ff8264db941a0662b5b731ab46af0"}, {"filename": "ping-hostname-O.out", "hash": "1d9af746b203413e0ffc211f3185a8e4"}, {"filename": "ping-ip-O-D.out", "hash": "9ab7407b788aa94b95fe49dbc131b2cb"}, {"filename": "ping-ip-O.out", "hash": "969a0243a76a3bf407e3a24082af8068"}, {"filename": "ping-ip-dup.out", "hash": "35204577e61b34a55df836f7b4920c7e"}, {"filename": "ping6-hostname-O-D-p-s.out", "hash": "be18cfed73d79091dcc665e5887903db"}, {"filename": "ping6-hostname-O-p.out", "hash": "bf28730f5973b3d37f9f42d80b6858b1"}, {"filename": "ping6-ip-O-D-p.out", "hash": "2665133538e2d4a0828204522227a5e6"}, {"filename": "ping6-ip-O-p.out", "hash": "bc03b9e491ecb25155e44082a8254f19"}, {"filename": "ping6-ip-dup.out", "hash": "ff5e5d69174a3240e87432827dd5e25d"}, {"filename": "pip-list.out", "hash": "99809973a445fb2801a3bb14b4bc03bc"}, {"filename": "pip-show.out", "hash": "691ef00b38abbdbd2e8cc1ea856b9d83"}, {"filename": "ps-axu.out", "hash": "e913baab1861defe5c69cc4bb6475779"}, {"filename": "ps-ef.out", "hash": "ed826e38db572628ca5a2d70435a6302"}, {"filename": "route-6-n.out", "hash": "7bc3917b8b7e8aabd1ea853dc03eb431"}, {"filename": "route-6.out", "hash": "f9691632cd72b4e956bba68d6d93a0fc"}, {"filename": "route-vn.out", "hash": "3e119bbbd3f6dbb432d27dc29fec8f98"}, {"filename": "route.out", "hash": "439adfcce99306d3419ec0fd7760f383"}, {"filename": "shadow.out", "hash": "9da686e5fb53fcb4c3934f7fc2859b5a"}, {"filename": "shasum.out", "hash": "dcecd94ddf63d7fd70c2636fd723289b"}, {"filename": "ss-sudo-a.out", "hash": "ee2ed1455bebac67298a72b83bdfb85e"}, {"filename": "stat.out", "hash": "ea9e5cc3f2ec9971b5c43203e17801ac"}, {"filename": "sysctl-a.out", "hash": "9db459aaf7689f8c66911b57b05a5b9f"}, {"filename": "systemctl-ls.out", "hash": "db3a53f9828d305ff294764ad6d3f860"}, {"filename": "systemctl-luf.out", "hash": "adf988243f7ff5a2f71a5868031e5ec3"}, {"filename": "systemctl.out", "hash": "446fb73dbc66db1246d044386c4e57d6"}, {"filename": "timedatectl.out", "hash": "47bd61915dab99979127fb3dc1b1e493"}, {"filename": "tracepath.out", "hash": "269d7cf5b938004f251dc7824e601198"}, {"filename": "tracepath6.out", "hash": "6569334c8e6b6b22018f22c6628f0797"}, {"filename": "traceroute.out", "hash": "2bf8b3c7bc6e175ebb21fd0102f6b2b9"}, {"filename": "uname-a.out", "hash": "38ed43650f1fa000d196b391aea1c96d"}, {"filename": "uptime.out", "hash": "b27aa536d962989c2639b9f022bd365f"}, {"filename": "w.out", "hash": "1a93af5b819721a085166825024a615e"}, {"filename": "who-a.out", "hash": "dceb435d3c30ad3fad4102cea4ed461a"}, {"filename": "who.out", "hash": "19e19c6f49753ff44e85f4a82539592d"}] diff --git a/tests/fixtures/osx-10.14.6/shasum.json b/tests/fixtures/osx-10.14.6/shasum.json new file mode 100644 index 000000000..a1e62d5a2 --- /dev/null +++ b/tests/fixtures/osx-10.14.6/shasum.json @@ -0,0 +1 @@ +[{"filename": "airport-I.json", "hash": "b6701d0bd547292d2a51541cefdb78589c4ebc65"}, {"filename": "airport-I.out", "hash": "3749387a837ee7e47a14c172b7b4eb922d569201"}, {"filename": "airport-s.json", "hash": "0baafe93a582feff71e80ccc6d392cbb35fbea11"}, {"filename": "airport-s.out", "hash": "4ae92f7948a96e95316ac2da00c162daad18802b"}, {"filename": "arp-a.json", "hash": "a214bc7b92039d33b0a9ee1ee343df6b6d81c11f"}, {"filename": "arp-a.out", "hash": "713e3d0a664c8ae8bd9a87c91269c22fca558849"}, {"filename": "arp-a2.json", "hash": "c8ede52d8e96ab137d56e5d9ccbdf0739300039d"}, {"filename": "arp-a2.out", "hash": "a8cdbf7229c45386c09a842100011421ab74adda"}, {"filename": "df-h.json", "hash": "3eea0498b884eb626b3f36484ceb46035626607a"}, {"filename": "df-h.out", "hash": "bec48433f817a8ab28699d4b4410935fc054e7d7"}, {"filename": "df.json", "hash": "0cc078c31215b815519928597108fc08d6974abf"}, {"filename": "df.out", "hash": "41ea13d77c82c840bf014c2d68e494bf5f090e86"}, {"filename": "dig-aaaa.json", "hash": "3e70a7cba6aaa1a873e845a54336adf67fe66b1e"}, {"filename": "dig-aaaa.out", "hash": "22417524735d1281e202a7a803c4721d7a212e4d"}, {"filename": "dig-axfr.json", "hash": "0c476125b50536e31521597da15ecf1007c01056"}, {"filename": "dig-axfr.out", "hash": "66220fa199b9c59cf980bb5b3eefcbf7454cf4f7"}, {"filename": "dig-x.json", "hash": "47c5bc3266cdc42e9f64007dca72d59a30e910d0"}, {"filename": "dig-x.out", "hash": "9f49a5c47cd70a52fd59a801cc5a5ac7c0ab6b74"}, {"filename": "dig.json", "hash": "41f3c14ec6bcaa040b3c139447c6c08ef2dc322f"}, {"filename": "dig.out", "hash": "2c2efae28e1a5bba3da1f5fe10d7a48451dcad61"}, {"filename": "du.json", "hash": "ca632dce5c358eb19189972a6ce3eb7bac410f1a"}, {"filename": "du.out", "hash": "4709f16a60b101dd624880abcb6917cb3b052da6"}, {"filename": "file.json", "hash": "6641aa32d84f1036e72592fefa16819788761dd6"}, {"filename": "file.out", "hash": "64aa7e0a87d8f337a1affa434b7bdcf973be5a04"}, {"filename": "file2.json", "hash": "c011e362d46b8bb3fff6670c3506ca103045f4cd"}, {"filename": "file2.out", "hash": "dfc3c3c4af63be1909e44443b3b90e10b687d6c8"}, {"filename": "group.json", "hash": "260404f3d2096264f5ca8570ca3295aa5e282878"}, {"filename": "group.out", "hash": "39ebabcaf4296712c3e32edb6133bca98a2455e8"}, {"filename": "id.json", "hash": "7f1718884b12c28035847719a19ea415e7215bb8"}, {"filename": "id.out", "hash": "28a7474eed1b514fafb0d8b33ade8a1b7b261546"}, {"filename": "ifconfig.json", "hash": "2ed6453465f3fdb41520599129741c8955e0e956"}, {"filename": "ifconfig.out", "hash": "bb0bc5bb5d8891015373a6ff3d743ee9593de432"}, {"filename": "ifconfig2.json", "hash": "2ea05804d196a0bf9894d8106766b04d5bf89a11"}, {"filename": "ifconfig2.out", "hash": "f46ecf7bb5be88af18d53415c31392d1968d2fc2"}, {"filename": "last.json", "hash": "3c2ec4597c76f026b4e635385a3f7e579b861bd2"}, {"filename": "last.out", "hash": "f92c6ff31c0b520d41768a044c794670ce8d13cb"}, {"filename": "ls-R-newlines.json", "hash": "54a0b33790ef7369fb901db4c45bfe5ef7e77edc"}, {"filename": "ls-R-newlines.out", "hash": "098c351f68519fd7ac37ac1721e64ad8ed4a3600"}, {"filename": "ls-R.json", "hash": "22c3aabad0c0cbe32a2ed8bd4d1cef92a904f0ea"}, {"filename": "ls-R.out", "hash": "69861b855e1e7e6394da3645e853a3430e99e5b2"}, {"filename": "ls-al.json", "hash": "8c1fc69e7a8e96d06566afa3a7759fcd17d77207"}, {"filename": "ls-al.out", "hash": "4e6eb0ef6e29a436d15b3e380a6e34c57583e94f"}, {"filename": "ls-alR.json", "hash": "67d5b302d734e71859160cb44b13b5cdfae03e34"}, {"filename": "ls-alR.out", "hash": "5ee5666ccd067a72e0cff4d1b337c46858205ce2"}, {"filename": "ls-alh.json", "hash": "31b53afda162e8ccf356916f2cc36dc73eb6b45b"}, {"filename": "ls-alh.out", "hash": "81e09c8a18b7e0a051147e697b83fdb5f88ab137"}, {"filename": "ls-glob.json", "hash": "f9c06fe2c8a2a44987112d16d29cea359d67c4e4"}, {"filename": "ls-glob.out", "hash": "6d38df7da56e2b898db200cbc68ffa2f9324b567"}, {"filename": "ls-l-newlines.json", "hash": "839158b81641f70e09fae84c5f11d4fa3d371922"}, {"filename": "ls-l-newlines.out", "hash": "21999fb50ffff3d098ff5cb44de92002b8637611"}, {"filename": "ls-lR-empty-folder.json", "hash": "58e4a9d0deddd57483880b4f509f769fa1df6514"}, {"filename": "ls-lR-empty-folder.out", "hash": "827125e173a978aaea11b6170dfbefb3dab30375"}, {"filename": "ls-lR-newlines.json", "hash": "28b5390d64492453187a5c3e3548854bafa5a3dc"}, {"filename": "ls-lR-newlines.out", "hash": "5b17d8c3c27c90cce7fb2c42e79ac94d5f79fba4"}, {"filename": "ls-newlines.json", "hash": "5f1a2ab24626d2819bab4c5f1f974b4dcd32d18d"}, {"filename": "ls-newlines.out", "hash": "f103cb8013553c1c997d151449a519090c844c4d"}, {"filename": "ls.json", "hash": "8dbfd075967f928fcf773cdf740abc3442e1e7de"}, {"filename": "ls.out", "hash": "e378d603819b3ba7a4615151f3cbdd8c985c5278"}, {"filename": "md5.out", "hash": "e6169a0ab655b81d17ca46460f4bf4628e3f15c7"}, {"filename": "mount.json", "hash": "3427962301eb775c296a75532ece6f24197723df"}, {"filename": "mount.out", "hash": "6301b0589f75e4190e37ec071068a9a43a6ba6b9"}, {"filename": "mount2.json", "hash": "e32f5571cb2995d01e336076a84ded88f2dce782"}, {"filename": "mount2.out", "hash": "9c90e82e74c553bf649b1a43047cd9c062006fa3"}, {"filename": "netstat-Abn.json", "hash": "4c210803690e8eabbdfd00c1346014d7b99ab5e2"}, {"filename": "netstat-Abn.out", "hash": "45b809ce7d4c68685ee9293c07640b1e5fb3420a"}, {"filename": "netstat-An.json", "hash": "1be1890e206000e8865c81a7cf1c5ac17cc5e9e1"}, {"filename": "netstat-An.out", "hash": "1a7c5cee6339d8e22973a31542ae62f330fa4057"}, {"filename": "netstat-i.json", "hash": "a9cce6324e62373b66066ab6a292b121ae3fb121"}, {"filename": "netstat-i.out", "hash": "1d699a308356aee6179caa84a07940f32c262a33"}, {"filename": "netstat-r.json", "hash": "4a851ca343d7d17ece41cb66e9c1f5d046281514"}, {"filename": "netstat-r.out", "hash": "04b4ff8c424c836beb179f24402e09df6b91d8da"}, {"filename": "netstat-rnl.json", "hash": "b10b6ce7d98e61c4f819fc06aaa3ba4c11e6196e"}, {"filename": "netstat-rnl.out", "hash": "b354f8cdfea44bb84fc8b9f16e40621387b1e20b"}, {"filename": "netstat.json", "hash": "eeb92d12bea70acc01bbe015668f774dda779fac"}, {"filename": "netstat.out", "hash": "00cc660ce9de89889435978f4e82aac8d30352ba"}, {"filename": "passwd.json", "hash": "ad454cef94895c6f32538dcc57e5c35609543f0b"}, {"filename": "passwd.out", "hash": "98b96a259d79f457c619dfb4b5949f03f9ee0e91"}, {"filename": "ping-hostname-p.json", "hash": "affe7ac91927e00c05da4c4f0b985da7feb94ee7"}, {"filename": "ping-hostname-p.out", "hash": "22f6da2c47dfafcdf2921bbd0dd664a59c118017"}, {"filename": "ping-hostname-s.json", "hash": "37573a86ea3bc3a66fe5a401e0259e9ba86bd7e2"}, {"filename": "ping-hostname-s.out", "hash": "3515f57ef15df3b015b1e589eb76298c6923eee3"}, {"filename": "ping-hostname.json", "hash": "70cae13fff2b53913bc279bad20ae6502b93142c"}, {"filename": "ping-hostname.out", "hash": "805da101ba12f150e5164352cc61634fe08a6f04"}, {"filename": "ping-ip-dup.json", "hash": "463ab3f969bac22b644c3e60c9b33db570c50ec1"}, {"filename": "ping-ip-dup.out", "hash": "f051d883e339ce8bfbee8d14ddc68007aec2ce16"}, {"filename": "ping-ip-p.json", "hash": "6c433892a236a8b56c38c92ab65d958a81b25015"}, {"filename": "ping-ip-p.out", "hash": "fbec6b8034ef32a48dcd392c8d8d7a8150720cee"}, {"filename": "ping-ip-s.json", "hash": "a8e7418abf65967c554f6006a6d18d1103936b56"}, {"filename": "ping-ip-s.out", "hash": "d688174811c7e7df05135bfb7d53a2ce91878632"}, {"filename": "ping-ip.json", "hash": "a8bad79ae89852a0d6f42f78c0d3b651e825f62f"}, {"filename": "ping-ip.out", "hash": "30e35e7a4b16c9e0332e4cf5ae7d4a6e90e2ad63"}, {"filename": "ping6-hostname-p.json", "hash": "aa762025cefbe4f9a481ba622ade333ad3d3f946"}, {"filename": "ping6-hostname-p.out", "hash": "534382c4698f18187ded6259576f08da0a6f338f"}, {"filename": "ping6-hostname-s.json", "hash": "6600a05b117ddcfc80ee3554176857a78b18325a"}, {"filename": "ping6-hostname-s.out", "hash": "f86a97e16952be0e70b7c7fde247d2793230ecdc"}, {"filename": "ping6-hostname.json", "hash": "9b2c9765859a05d8ae779764284db45d9dea742c"}, {"filename": "ping6-hostname.out", "hash": "1782a580d6d92d38a64e02fca30b936c1bacc05d"}, {"filename": "ping6-ip-dup.json", "hash": "838ef123a0000e59271d4703c7ac6c4a7d3eab7e"}, {"filename": "ping6-ip-dup.out", "hash": "0d3af3ab2a5c5f886842abc0bfe06288307604b3"}, {"filename": "ping6-ip-p.json", "hash": "9911d8c4d08f3ba111c6b24dbbbecab701e4a371"}, {"filename": "ping6-ip-p.out", "hash": "b176952e7b3fbc0f94c9b6aa261e7a239938621f"}, {"filename": "ping6-ip-s.json", "hash": "0fa62d9840efc9867c7c74458474c4daa6725e0e"}, {"filename": "ping6-ip-s.out", "hash": "bed5d50ae2be215b612187f109046916a7071bdf"}, {"filename": "ping6-ip.json", "hash": "d229293a2a0fd0e7c04d65202a58de207a85db93"}, {"filename": "ping6-ip.out", "hash": "b96290f3f61068eef9c79e52155560a9f6eebb24"}, {"filename": "pip-list.json", "hash": "3a095f602ade8ab11443ce8321288dc8a52f4eb6"}, {"filename": "pip-list.out", "hash": "684f9f178d8a4a9183bdfa91139b65fff7a8bd02"}, {"filename": "pip-show.json", "hash": "2775dfd4a51a3b7a6eb41effa9299e72377ac573"}, {"filename": "pip-show.out", "hash": "c9159fd0cd5af49fd81a6181b38161072a0a8536"}, {"filename": "ps-axu.json", "hash": "b68b29c17b6877bb014a8b99d528ed15476c9ff1"}, {"filename": "ps-axu.out", "hash": "c09f2435054539d3f891e803babfcebbc2e3d2c5"}, {"filename": "ps-ef.json", "hash": "2a7bae5f336e662ef58fb1213d0f20c593f8e5ce"}, {"filename": "ps-ef.out", "hash": "a13032d2a724f4918a3c4941c4babaf55f2c7a40"}, {"filename": "stat.json", "hash": "a95208df396194dac9b1196f3bbe989e174fc3fb"}, {"filename": "stat.out", "hash": "301016ffc0cbb6a0ebb4a31987aae2208068af45"}, {"filename": "sysctl-a.json", "hash": "d791375d84f3c209bf71f637e76d46d1fe4459c7"}, {"filename": "sysctl-a.out", "hash": "61827f5423ee2a3891f38b23baf671676869d930"}, {"filename": "traceroute-asn.json", "hash": "0096b180a1674f935df6e7314db0f3aac3d15758"}, {"filename": "traceroute-asn.out", "hash": "14983d7528df1dc1004b254991e49cba30cf9861"}, {"filename": "traceroute-mult-addresses.json", "hash": "5cfde477f5e966db9887c4ac6700e94ec3f5e214"}, {"filename": "traceroute-mult-addresses.out", "hash": "b05bfa6c8371c68eb5d761de6b7a7933c3dba78b"}, {"filename": "traceroute-no-header.json", "hash": "92b288e194981920428fbb910717a3ff17605fd0"}, {"filename": "traceroute-no-header.out", "hash": "fbb81722ae676195c0f44f0f8c41bd860fb33b52"}, {"filename": "traceroute-q.json", "hash": "17b5bdc7456d2cda893eba40e5568d6e4835c2ce"}, {"filename": "traceroute-q.out", "hash": "cb777f386ff2f81c6516b560a4ddea149235f573"}, {"filename": "traceroute.json", "hash": "f62ee48530285cb1cecd5ef0dc4e8cc16b278676"}, {"filename": "traceroute.out", "hash": "d080112c55e7fbd6578720fe290db6dea2d8df46"}, {"filename": "traceroute6-mult-addresses.json", "hash": "94e80f496b128bf459cf59ac07d5645be70e5b8f"}, {"filename": "traceroute6-mult-addresses.out", "hash": "67677c5474a466a6c1ae86557077326eed70db71"}, {"filename": "traceroute6.json", "hash": "94e80f496b128bf459cf59ac07d5645be70e5b8f"}, {"filename": "traceroute6.out", "hash": "526c631415d055333b4f29adca186bfe7f498dca"}, {"filename": "uname-a.json", "hash": "9ac73b33611d1cee071cdb224178c4ea4c164804"}, {"filename": "uname-a.out", "hash": "ac286f0f6e2bb695f693674babdae22203765a79"}, {"filename": "uname.out", "hash": "0fc09dc308ca8159ed485d2c5aad6139eab3d44b"}, {"filename": "uptime.json", "hash": "43f78bcbeb78e30f0df5ae0e988605627a453c72"}, {"filename": "uptime.out", "hash": "bfbfc9814f48e430aef9579bb6bfd4873b257a17"}, {"filename": "w.json", "hash": "2ecd2bd1a1c243852181d00fdd26bdd471221f16"}, {"filename": "w.out", "hash": "1d5f7d4db7d413717f661e95c239312b94045ebc"}, {"filename": "who-a.json", "hash": "31d74136f77fff6ba685e43d17097b045642bbec"}, {"filename": "who-a.out", "hash": "2e6094a345b9f3205decacba3d7f1fcf8471dd82"}, {"filename": "who.json", "hash": "0b6eddc1d363f49c46c963b97dc0387e9e7a23b7"}, {"filename": "who.out", "hash": "996aa62bdea95a8c4561f4208db3fd7719eb695f"}] diff --git a/tests/test_hashsum.py b/tests/test_hashsum.py new file mode 100644 index 000000000..2e8663dd1 --- /dev/null +++ b/tests/test_hashsum.py @@ -0,0 +1,82 @@ +import os +import unittest +import json +import jc.parsers.hashsum + +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + + +class MyTests(unittest.TestCase): + + def setUp(self): + # input + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/md5sum.out'), 'r', encoding='utf-8') as f: + self.centos_7_7_md5sum = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/sha256sum.out'), 'r', encoding='utf-8') as f: + self.centos_7_7_sha256sum = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/sha384sum.out'), 'r', encoding='utf-8') as f: + self.centos_7_7_sha384sum = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/md5.out'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_md5 = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/shasum.out'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_shasum = f.read() + + # output + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/md5sum.json'), 'r', encoding='utf-8') as f: + self.centos_7_7_md5sum_json = json.loads(f.read()) + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/sha256sum.json'), 'r', encoding='utf-8') as f: + self.centos_7_7_sha256sum_json = json.loads(f.read()) + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/sha384sum.json'), 'r', encoding='utf-8') as f: + self.centos_7_7_sha384sum_json = json.loads(f.read()) + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/md5.json'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_md5_json = json.loads(f.read()) + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/shasum.json'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_shasum_json = json.loads(f.read()) + + def test_hashsum_nodata(self): + """ + Test 'hashsum' with no data + """ + self.assertEqual(jc.parsers.hashsum.parse('', quiet=True), []) + + def test_md5sum_centos_7_7(self): + """ + Test 'md5sum' on Centos 7.7 + """ + self.assertEqual(jc.parsers.hashsum.parse(self.centos_7_7_md5sum, quiet=True), self.centos_7_7_md5sum_json) + + def test_sha256sum_centos_7_7(self): + """ + Test 'sha256sum' on Centos 7.7 + """ + self.assertEqual(jc.parsers.hashsum.parse(self.centos_7_7_sha256sum, quiet=True), self.centos_7_7_sha256sum_json) + + def test_sha384sum_centos_7_7(self): + """ + Test 'sha384sum' on Centos 7.7 + """ + self.assertEqual(jc.parsers.hashsum.parse(self.centos_7_7_sha384sum, quiet=True), self.centos_7_7_sha384sum_json) + + def test_md5_osx_10_14_6(self): + """ + Test 'md5' on OSX 10.14.6 + """ + self.assertEqual(jc.parsers.hashsum.parse(self.osx_10_14_6_md5, quiet=True), self.osx_10_14_6_md5_json) + + def test_shasum_osx_10_14_6(self): + """ + Test 'shasum' on OSX 10.14.6 + """ + self.assertEqual(jc.parsers.hashsum.parse(self.osx_10_14_6_shasum, quiet=True), self.osx_10_14_6_shasum_json) + + +if __name__ == '__main__': + unittest.main() From 3b7d54c720dfc93637328cf06eb10a85447c8793 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Tue, 29 Dec 2020 12:55:30 -0800 Subject: [PATCH 04/24] add python 3.9 --- .github/workflows/pythonapp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 88455d2ad..42e8f3bdb 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] - python-version: [3.6, 3.7, 3.8] + python-version: [3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 From 1c880b9e24ca53cd592cec1dbc52301308290fb4 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Tue, 29 Dec 2020 12:58:04 -0800 Subject: [PATCH 05/24] force git tests --- tests/test_hashsum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_hashsum.py b/tests/test_hashsum.py index 2e8663dd1..c58cbfba2 100644 --- a/tests/test_hashsum.py +++ b/tests/test_hashsum.py @@ -43,7 +43,7 @@ def setUp(self): def test_hashsum_nodata(self): """ - Test 'hashsum' with no data + Test 'hashsum' parser with no data """ self.assertEqual(jc.parsers.hashsum.parse('', quiet=True), []) From d1567d1f622902053f3df58645b4e39532e0c30a Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Tue, 29 Dec 2020 13:05:04 -0800 Subject: [PATCH 06/24] add hashsum documentation --- CHANGELOG | 4 ++ docgen.sh | 1 + docs/parsers/hashsum.md | 99 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 docs/parsers/hashsum.md diff --git a/CHANGELOG b/CHANGELOG index c2018ee33..f15326ba9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ jc changelog +20201229 v1.14.0 +- Add hashsum parser tested on linux, macos +- Add python 3.9 to github automation tests + 20200805 v1.13.4 - Update crontab and crontab-u parsers to tighten up variable detection - Update ping parser to tighten linux/bsd detection diff --git a/docgen.sh b/docgen.sh index 9f98c1d9d..4dc8a6246 100755 --- a/docgen.sh +++ b/docgen.sh @@ -23,6 +23,7 @@ pydocmd simple jc.parsers.free+ > ../docs/parsers/free.md pydocmd simple jc.parsers.fstab+ > ../docs/parsers/fstab.md pydocmd simple jc.parsers.group+ > ../docs/parsers/group.md pydocmd simple jc.parsers.gshadow+ > ../docs/parsers/gshadow.md +pydocmd simple jc.parsers.hashsum+ > ../docs/parsers/hashsum.md pydocmd simple jc.parsers.history+ > ../docs/parsers/history.md pydocmd simple jc.parsers.hosts+ > ../docs/parsers/hosts.md pydocmd simple jc.parsers.id+ > ../docs/parsers/id.md diff --git a/docs/parsers/hashsum.md b/docs/parsers/hashsum.md new file mode 100644 index 000000000..11cdba300 --- /dev/null +++ b/docs/parsers/hashsum.md @@ -0,0 +1,99 @@ + +# jc.parsers.hashsum +jc - JSON CLI output utility `hash sum` command output parser + +Usage (cli): + + $ md5sum file.txt | jc --hashsum + + or + + $ jc md5sum file.txt + +Usage (module): + + import jc.parsers.hashsum + result = jc.parsers.hashsum.parse(md5sum_command_output) + +Compatibility: + + 'linux', 'darwin', 'cygwin', 'aix', 'freebsd' + +Examples: + + $ md5sum * | jc --hashsum -p + [ + { + "filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm", + "hash": "65fc958c1add637ec23c4b137aecf3d3" + }, + { + "filename": "digout", + "hash": "5b9312ee5aff080927753c63a347707d" + }, + { + "filename": "dmidecode.out", + "hash": "716fd11c2ac00db109281f7110b8fb9d" + }, + { + "filename": "file with spaces in the name", + "hash": "d41d8cd98f00b204e9800998ecf8427e" + }, + { + "filename": "id-centos.out", + "hash": "4295be239a14ad77ef3253103de976d2" + }, + { + "filename": "ifcfg.json", + "hash": "01fda0d9ba9a75618b072e64ff512b43" + }, + ... + ] + + +## info +```python +info() +``` + + +## process +```python +process(proc_data) +``` + +Final processing to conform to the schema. + +Parameters: + + proc_data: (dictionary) raw structured data to process + +Returns: + + List of dictionaries. Structured data with the following schema: + + [ + { + "filename": string, + "hash": string, + } + ] + + +## parse +```python +parse(data, raw=False, quiet=False) +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + +Returns: + + List of dictionaries. Raw or processed structured data. + From 9fbbc30906b597e6afaf2030015a7a694d85f79e Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Tue, 29 Dec 2020 13:09:03 -0800 Subject: [PATCH 07/24] add supported commands to docs --- docs/parsers/hashsum.md | 10 ++++++++++ jc/parsers/hashsum.py | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/docs/parsers/hashsum.md b/docs/parsers/hashsum.md index 11cdba300..5d0d66e72 100644 --- a/docs/parsers/hashsum.md +++ b/docs/parsers/hashsum.md @@ -2,6 +2,16 @@ # jc.parsers.hashsum jc - JSON CLI output utility `hash sum` command output parser +This parser works with the following hash calculation programs: +- `md5` +- `md5sum` +- `shasum` +- `sha1sum` +- `sha224sum` +- `sha256sum` +- `sha384sum` +- `sha512sum` + Usage (cli): $ md5sum file.txt | jc --hashsum diff --git a/jc/parsers/hashsum.py b/jc/parsers/hashsum.py index c23fe77a3..c89dc0ac9 100644 --- a/jc/parsers/hashsum.py +++ b/jc/parsers/hashsum.py @@ -1,5 +1,15 @@ """jc - JSON CLI output utility `hash sum` command output parser +This parser works with the following hash calculation programs: +- `md5` +- `md5sum` +- `shasum` +- `sha1sum` +- `sha224sum` +- `sha256sum` +- `sha384sum` +- `sha512sum` + Usage (cli): $ md5sum file.txt | jc --hashsum From 62432f3c484e74acb2b2dfd15d448b3f1b5d53c4 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 30 Dec 2020 09:59:54 -0800 Subject: [PATCH 08/24] update hashsum description --- jc/parsers/hashsum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jc/parsers/hashsum.py b/jc/parsers/hashsum.py index c89dc0ac9..f0f3f8d76 100644 --- a/jc/parsers/hashsum.py +++ b/jc/parsers/hashsum.py @@ -63,7 +63,7 @@ class info(): version = '1.0' - description = 'hashsum command and file parser' + description = 'hashsum command and file parser (md5sum, shasum, etc.)' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' details = 'Parses MD5 and SHA hash program output' From 0431798178740b03cdefececc6df958e5adf62fc Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 30 Dec 2020 11:02:02 -0800 Subject: [PATCH 09/24] add cksum parser --- CHANGELOG | 1 + docgen.sh | 1 + docs/parsers/cksum.md | 95 +++++++++++++++++++++++++++++ docs/parsers/hashsum.md | 2 +- jc/cli.py | 3 +- jc/parsers/cksum.py | 128 ++++++++++++++++++++++++++++++++++++++++ jc/parsers/hashsum.py | 2 +- 7 files changed, 229 insertions(+), 3 deletions(-) create mode 100644 docs/parsers/cksum.md create mode 100644 jc/parsers/cksum.py diff --git a/CHANGELOG b/CHANGELOG index f15326ba9..0a7f3ad00 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ jc changelog 20201229 v1.14.0 - Add hashsum parser tested on linux, macos +- Add cksum parser tested on linux, macos - Add python 3.9 to github automation tests 20200805 v1.13.4 diff --git a/docgen.sh b/docgen.sh index 4dc8a6246..99f27e189 100755 --- a/docgen.sh +++ b/docgen.sh @@ -9,6 +9,7 @@ pydocmd simple jc.parsers.airport+ > ../docs/parsers/airport.md pydocmd simple jc.parsers.airport_s+ > ../docs/parsers/airport_s.md pydocmd simple jc.parsers.arp+ > ../docs/parsers/arp.md pydocmd simple jc.parsers.blkid+ > ../docs/parsers/blkid.md +pydocmd simple jc.parsers.cksum+ > ../docs/parsers/cksum.md pydocmd simple jc.parsers.crontab+ > ../docs/parsers/crontab.md pydocmd simple jc.parsers.crontab_u+ > ../docs/parsers/crontab_u.md pydocmd simple jc.parsers.csv+ > ../docs/parsers/csv.md diff --git a/docs/parsers/cksum.md b/docs/parsers/cksum.md new file mode 100644 index 000000000..42c525efb --- /dev/null +++ b/docs/parsers/cksum.md @@ -0,0 +1,95 @@ + +# jc.parsers.cksum +jc - JSON CLI output utility `cksum` command output parser + +This parser works with the following checksum calculation utilities: +- `sum` +- `cksum` + +Usage (cli): + + $ cksum file.txt | jc --cksum + + or + + $ jc cksum file.txt + +Usage (module): + + import jc.parsers.cksum + result = jc.parsers.cksum.parse(cksum_command_output) + +Compatibility: + + 'linux', 'darwin', 'cygwin', 'aix', 'freebsd' + +Examples: + + $ cksum * | jc --cksum -p + [ + { + "filename": "__init__.py", + "checksum": 4294967295, + "blocks": 0 + }, + { + "filename": "airport.py", + "checksum": 2208551092, + "blocks": 3745 + }, + { + "filename": "airport_s.py", + "checksum": 1113817598, + "blocks": 4572 + }, + ... + ] + + +## info +```python +info() +``` + + +## process +```python +process(proc_data) +``` + +Final processing to conform to the schema. + +Parameters: + + proc_data: (dictionary) raw structured data to process + +Returns: + + List of dictionaries. Structured data with the following schema: + + [ + { + "filename": string, + "checksum": integer, + "blocks": integer + } + ] + + +## parse +```python +parse(data, raw=False, quiet=False) +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + +Returns: + + List of dictionaries. Raw or processed structured data. + diff --git a/docs/parsers/hashsum.md b/docs/parsers/hashsum.md index 5d0d66e72..4c8c24945 100644 --- a/docs/parsers/hashsum.md +++ b/docs/parsers/hashsum.md @@ -2,7 +2,7 @@ # jc.parsers.hashsum jc - JSON CLI output utility `hash sum` command output parser -This parser works with the following hash calculation programs: +This parser works with the following hash calculation utilities: - `md5` - `md5sum` - `shasum` diff --git a/jc/cli.py b/jc/cli.py index c396226d3..8b09fb734 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -21,7 +21,7 @@ class info(): - version = '1.13.4' + version = '1.14.0' description = 'JSON CLI output utility' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -34,6 +34,7 @@ class info(): 'airport-s', 'arp', 'blkid', + 'cksum', 'crontab', 'crontab-u', 'csv', diff --git a/jc/parsers/cksum.py b/jc/parsers/cksum.py new file mode 100644 index 000000000..1b3123627 --- /dev/null +++ b/jc/parsers/cksum.py @@ -0,0 +1,128 @@ +"""jc - JSON CLI output utility `cksum` command output parser + +This parser works with the following checksum calculation utilities: +- `sum` +- `cksum` + +Usage (cli): + + $ cksum file.txt | jc --cksum + + or + + $ jc cksum file.txt + +Usage (module): + + import jc.parsers.cksum + result = jc.parsers.cksum.parse(cksum_command_output) + +Compatibility: + + 'linux', 'darwin', 'cygwin', 'aix', 'freebsd' + +Examples: + + $ cksum * | jc --cksum -p + [ + { + "filename": "__init__.py", + "checksum": 4294967295, + "blocks": 0 + }, + { + "filename": "airport.py", + "checksum": 2208551092, + "blocks": 3745 + }, + { + "filename": "airport_s.py", + "checksum": 1113817598, + "blocks": 4572 + }, + ... + ] +""" +import jc.utils + + +class info(): + version = '1.0' + description = 'cksum command and file parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + details = 'Parses cksum and sum program output' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + magic_commands = ['cksum', 'sum'] + + +__version__ = info.version + + +def process(proc_data): + """ + Final processing to conform to the schema. + + Parameters: + + proc_data: (dictionary) raw structured data to process + + Returns: + + List of dictionaries. Structured data with the following schema: + + [ + { + "filename": string, + "checksum": integer, + "blocks": integer + } + ] + """ + + for entry in proc_data: + int_list = ['checksum', 'blocks'] + for key in int_list: + if key in entry: + try: + entry[key] = int(entry[key]) + except (ValueError): + entry[key] = None + return proc_data + + +def parse(data, raw=False, quiet=False): + """ + Main text parsing function + + Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + + Returns: + + List of dictionaries. Raw or processed structured data. + """ + if not quiet: + jc.utils.compatibility(__name__, info.compatible) + + raw_output = [] + + if jc.utils.has_data(data): + + for line in filter(None, data.splitlines()): + item = { + 'filename': line.split(maxsplit=2)[2], + 'checksum': line.split(maxsplit=2)[0], + 'blocks': line.split(maxsplit=2)[1] + } + raw_output.append(item) + + if raw: + return raw_output + else: + return process(raw_output) diff --git a/jc/parsers/hashsum.py b/jc/parsers/hashsum.py index f0f3f8d76..f3e5722c1 100644 --- a/jc/parsers/hashsum.py +++ b/jc/parsers/hashsum.py @@ -1,6 +1,6 @@ """jc - JSON CLI output utility `hash sum` command output parser -This parser works with the following hash calculation programs: +This parser works with the following hash calculation utilities: - `md5` - `md5sum` - `shasum` From 6da9510e46e84ec1cb93384825184d2996cf0e08 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 30 Dec 2020 11:22:17 -0800 Subject: [PATCH 10/24] add cksum tests --- tests/fixtures/centos-7.7/cksum.json | 1 + tests/fixtures/centos-7.7/cksum.out | 59 +++++++++++ tests/fixtures/centos-7.7/sum.json | 1 + tests/fixtures/centos-7.7/sum.out | 58 ++++++++++ tests/fixtures/osx-10.14.6/cksum.json | 1 + tests/fixtures/osx-10.14.6/cksum.out | 145 +++++++++++++++++++++++++ tests/fixtures/osx-10.14.6/sum.json | 1 + tests/fixtures/osx-10.14.6/sum.out | 146 ++++++++++++++++++++++++++ tests/test_cksum.py | 70 ++++++++++++ 9 files changed, 482 insertions(+) create mode 100644 tests/fixtures/centos-7.7/cksum.json create mode 100644 tests/fixtures/centos-7.7/cksum.out create mode 100644 tests/fixtures/centos-7.7/sum.json create mode 100644 tests/fixtures/centos-7.7/sum.out create mode 100644 tests/fixtures/osx-10.14.6/cksum.json create mode 100644 tests/fixtures/osx-10.14.6/cksum.out create mode 100644 tests/fixtures/osx-10.14.6/sum.json create mode 100644 tests/fixtures/osx-10.14.6/sum.out create mode 100644 tests/test_cksum.py diff --git a/tests/fixtures/centos-7.7/cksum.json b/tests/fixtures/centos-7.7/cksum.json new file mode 100644 index 000000000..c595af260 --- /dev/null +++ b/tests/fixtures/centos-7.7/cksum.json @@ -0,0 +1 @@ +[{"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm", "checksum": 3194693727, "blocks": 24150660}, {"filename": "digout", "checksum": 1851496064, "blocks": 1196}, {"filename": "dmidecode.out", "checksum": 3221261569, "blocks": 277288}, {"filename": "ethtool.out", "checksum": 4227574970, "blocks": 748}, {"filename": "file with spaces in the name", "checksum": 4294967295, "blocks": 0}, {"filename": "id-centos.out", "checksum": 22642479, "blocks": 129}, {"filename": "ifcfg.json", "checksum": 2870739759, "blocks": 1600}, {"filename": "ifconfig.out", "checksum": 2514469297, "blocks": 1278}, {"filename": "jc", "checksum": 1519020121, "blocks": 58764280}, {"filename": "jc-1.10.5-linux.sha256", "checksum": 1419642770, "blocks": 69}, {"filename": "jc-1.10.5-linux.tar.gz", "checksum": 4103750556, "blocks": 21978413}, {"filename": "jc-1.10.5.rpm", "checksum": 901847831, "blocks": 21716708}, {"filename": "jc-1.11.1-linux.sha256", "checksum": 2941909126, "blocks": 69}, {"filename": "jc-1.11.1-linux.tar.gz", "checksum": 2257585750, "blocks": 20226936}, {"filename": "jc-1.11.1.sha256", "checksum": 1000678195, "blocks": 69}, {"filename": "jc-1.11.1.tar.gz", "checksum": 2080460101, "blocks": 20225785}, {"filename": "jc-1.11.2-linux.sha256", "checksum": 1504349309, "blocks": 69}, {"filename": "jc-1.11.2-linux.tar.gz", "checksum": 1847458112, "blocks": 20231427}, {"filename": "jc-1.11.8-linux.sha256", "checksum": 1107685588, "blocks": 69}, {"filename": "jc-1.11.8-linux.tar.gz", "checksum": 3146155218, "blocks": 20241790}, {"filename": "jc-1.13.1-linux.sha256", "checksum": 2813075513, "blocks": 69}, {"filename": "jc-1.13.1-linux.tar.gz", "checksum": 1234240055, "blocks": 20268540}, {"filename": "jc-1.13.2-linux.sha256", "checksum": 806999822, "blocks": 69}, {"filename": "jc-1.13.2-linux.tar.gz", "checksum": 3132593132, "blocks": 20263630}, {"filename": "jc-1.13.4-linux.sha256", "checksum": 4099431772, "blocks": 69}, {"filename": "jc-1.13.4-linux.tar.gz", "checksum": 585256943, "blocks": 20264188}, {"filename": "jello-1.2.8-linux.sha256", "checksum": 3376281076, "blocks": 72}, {"filename": "jello-1.2.8-linux.tar.gz", "checksum": 3017693313, "blocks": 19899656}, {"filename": "jello-1.2.9-linux.sha256", "checksum": 2752469143, "blocks": 72}, {"filename": "jello-1.2.9-linux.tar.gz", "checksum": 464841230, "blocks": 19901109}, {"filename": "journaljson", "checksum": 220197660, "blocks": 6014042}, {"filename": "jp", "checksum": 1892840001, "blocks": 3426382}, {"filename": "jp_1.1.12_linux_x86_64.zip", "checksum": 1931622609, "blocks": 1174326}, {"filename": "jq_twitter.json", "checksum": 48933934, "blocks": 738160}, {"filename": "jtbl-1.1.6-linux.sha256", "checksum": 3187469112, "blocks": 71}, {"filename": "jtbl-1.1.6-linux.tar.gz", "checksum": 3178056589, "blocks": 18224334}, {"filename": "kbls.out", "checksum": 20037015, "blocks": 4152}, {"filename": "lastb.out", "checksum": 578204035, "blocks": 269}, {"filename": "lsblk-cols", "checksum": 977417403, "blocks": 1559}, {"filename": "ping-ip-O-D.out", "checksum": 1309174893, "blocks": 1751}, {"filename": "ping-ip-O.out", "checksum": 3674431351, "blocks": 1351}, {"filename": "psfile.txt", "checksum": 38743147, "blocks": 7786}, {"filename": "resizeterm.sh", "checksum": 1313583846, "blocks": 355}, {"filename": "route-6-n.out", "checksum": 1511061346, "blocks": 1802}, {"filename": "route-6.out", "checksum": 1574928177, "blocks": 1814}, {"filename": "routeout", "checksum": 1277932868, "blocks": 690}, {"filename": "sha384sum.out", "checksum": 3868747289, "blocks": 6434}, {"filename": "shafile.txt", "checksum": 1039827125, "blocks": 2850}, {"filename": "ss-aeep.out", "checksum": 2355562581, "blocks": 26724}, {"filename": "ssout", "checksum": 1754458832, "blocks": 20190}, {"filename": "sum.out", "checksum": 4143011907, "blocks": 1668}, {"filename": "systemctl.out", "checksum": 3736720956, "blocks": 38746}, {"filename": "top.out", "checksum": 2738959094, "blocks": 5314}, {"filename": "tracepath6.out", "checksum": 3198330928, "blocks": 252}, {"filename": "tracepath-cnn.out", "checksum": 1367648069, "blocks": 939}, {"filename": "tr.out", "checksum": 2683788995, "blocks": 1137}, {"filename": "who-aH.out", "checksum": 3295769480, "blocks": 355}, {"filename": "who.out", "checksum": 969319749, "blocks": 93}, {"filename": "whotext", "checksum": 543168390, "blocks": 281}] diff --git a/tests/fixtures/centos-7.7/cksum.out b/tests/fixtures/centos-7.7/cksum.out new file mode 100644 index 000000000..1220fa92b --- /dev/null +++ b/tests/fixtures/centos-7.7/cksum.out @@ -0,0 +1,59 @@ +3194693727 24150660 devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm +1851496064 1196 digout +3221261569 277288 dmidecode.out +4227574970 748 ethtool.out +4294967295 0 file with spaces in the name +22642479 129 id-centos.out +2870739759 1600 ifcfg.json +2514469297 1278 ifconfig.out +1519020121 58764280 jc +1419642770 69 jc-1.10.5-linux.sha256 +4103750556 21978413 jc-1.10.5-linux.tar.gz +901847831 21716708 jc-1.10.5.rpm +2941909126 69 jc-1.11.1-linux.sha256 +2257585750 20226936 jc-1.11.1-linux.tar.gz +1000678195 69 jc-1.11.1.sha256 +2080460101 20225785 jc-1.11.1.tar.gz +1504349309 69 jc-1.11.2-linux.sha256 +1847458112 20231427 jc-1.11.2-linux.tar.gz +1107685588 69 jc-1.11.8-linux.sha256 +3146155218 20241790 jc-1.11.8-linux.tar.gz +2813075513 69 jc-1.13.1-linux.sha256 +1234240055 20268540 jc-1.13.1-linux.tar.gz +806999822 69 jc-1.13.2-linux.sha256 +3132593132 20263630 jc-1.13.2-linux.tar.gz +4099431772 69 jc-1.13.4-linux.sha256 +585256943 20264188 jc-1.13.4-linux.tar.gz +3376281076 72 jello-1.2.8-linux.sha256 +3017693313 19899656 jello-1.2.8-linux.tar.gz +2752469143 72 jello-1.2.9-linux.sha256 +464841230 19901109 jello-1.2.9-linux.tar.gz +220197660 6014042 journaljson +1892840001 3426382 jp +1931622609 1174326 jp_1.1.12_linux_x86_64.zip +48933934 738160 jq_twitter.json +3187469112 71 jtbl-1.1.6-linux.sha256 +3178056589 18224334 jtbl-1.1.6-linux.tar.gz +20037015 4152 kbls.out +578204035 269 lastb.out +977417403 1559 lsblk-cols +1309174893 1751 ping-ip-O-D.out +3674431351 1351 ping-ip-O.out +38743147 7786 psfile.txt +1313583846 355 resizeterm.sh +1511061346 1802 route-6-n.out +1574928177 1814 route-6.out +1277932868 690 routeout +3868747289 6434 sha384sum.out +1039827125 2850 shafile.txt +2355562581 26724 ss-aeep.out +1754458832 20190 ssout +4143011907 1668 sum.out +3736720956 38746 systemctl.out +2738959094 5314 top.out +3198330928 252 tracepath6.out +1367648069 939 tracepath-cnn.out +2683788995 1137 tr.out +3295769480 355 who-aH.out +969319749 93 who.out +543168390 281 whotext diff --git a/tests/fixtures/centos-7.7/sum.json b/tests/fixtures/centos-7.7/sum.json new file mode 100644 index 000000000..1d42237ea --- /dev/null +++ b/tests/fixtures/centos-7.7/sum.json @@ -0,0 +1 @@ +[{"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm", "checksum": 7391, "blocks": 23585}, {"filename": "digout", "checksum": 64318, "blocks": 2}, {"filename": "dmidecode.out", "checksum": 35461, "blocks": 271}, {"filename": "ethtool.out", "checksum": 13394, "blocks": 1}, {"filename": "file with spaces in the name", "checksum": 0, "blocks": 0}, {"filename": "id-centos.out", "checksum": 57353, "blocks": 1}, {"filename": "ifcfg.json", "checksum": 15991, "blocks": 2}, {"filename": "ifconfig.out", "checksum": 16654, "blocks": 2}, {"filename": "jc", "checksum": 12379, "blocks": 57387}, {"filename": "jc-1.10.5-linux.sha256", "checksum": 33170, "blocks": 1}, {"filename": "jc-1.10.5-linux.tar.gz", "checksum": 38975, "blocks": 21464}, {"filename": "jc-1.10.5.rpm", "checksum": 36555, "blocks": 21208}, {"filename": "jc-1.11.1-linux.sha256", "checksum": 5771, "blocks": 1}, {"filename": "jc-1.11.1-linux.tar.gz", "checksum": 33621, "blocks": 19753}, {"filename": "jc-1.11.1.sha256", "checksum": 63721, "blocks": 1}, {"filename": "jc-1.11.1.tar.gz", "checksum": 25235, "blocks": 19752}, {"filename": "jc-1.11.2-linux.sha256", "checksum": 3427, "blocks": 1}, {"filename": "jc-1.11.2-linux.tar.gz", "checksum": 64653, "blocks": 19758}, {"filename": "jc-1.11.8-linux.sha256", "checksum": 61535, "blocks": 1}, {"filename": "jc-1.11.8-linux.tar.gz", "checksum": 11356, "blocks": 19768}, {"filename": "jc-1.13.1-linux.sha256", "checksum": 413, "blocks": 1}, {"filename": "jc-1.13.1-linux.tar.gz", "checksum": 5236, "blocks": 19794}, {"filename": "jc-1.13.2-linux.sha256", "checksum": 30467, "blocks": 1}, {"filename": "jc-1.13.2-linux.tar.gz", "checksum": 6369, "blocks": 19789}, {"filename": "jc-1.13.4-linux.sha256", "checksum": 3858, "blocks": 1}, {"filename": "jc-1.13.4-linux.tar.gz", "checksum": 48299, "blocks": 19790}, {"filename": "jello-1.2.8-linux.sha256", "checksum": 9721, "blocks": 1}, {"filename": "jello-1.2.8-linux.tar.gz", "checksum": 22933, "blocks": 19434}, {"filename": "jello-1.2.9-linux.sha256", "checksum": 22600, "blocks": 1}, {"filename": "jello-1.2.9-linux.tar.gz", "checksum": 42077, "blocks": 19435}, {"filename": "journaljson", "checksum": 13482, "blocks": 5874}, {"filename": "jp", "checksum": 32520, "blocks": 3347}, {"filename": "jp_1.1.12_linux_x86_64.zip", "checksum": 10701, "blocks": 1147}, {"filename": "jq_twitter.json", "checksum": 44828, "blocks": 721}, {"filename": "jtbl-1.1.6-linux.sha256", "checksum": 41413, "blocks": 1}, {"filename": "jtbl-1.1.6-linux.tar.gz", "checksum": 3616, "blocks": 17798}, {"filename": "kbls.out", "checksum": 54702, "blocks": 5}, {"filename": "lastb.out", "checksum": 14781, "blocks": 1}, {"filename": "lsblk-cols", "checksum": 12059, "blocks": 2}, {"filename": "ping-ip-O-D.out", "checksum": 18274, "blocks": 2}, {"filename": "ping-ip-O.out", "checksum": 7583, "blocks": 2}, {"filename": "psfile.txt", "checksum": 25564, "blocks": 8}, {"filename": "resizeterm.sh", "checksum": 14654, "blocks": 1}, {"filename": "route-6-n.out", "checksum": 332, "blocks": 2}, {"filename": "route-6.out", "checksum": 18331, "blocks": 2}, {"filename": "routeout", "checksum": 54044, "blocks": 1}, {"filename": "sha384sum.out", "checksum": 27372, "blocks": 7}, {"filename": "shafile.txt", "checksum": 29060, "blocks": 3}, {"filename": "ss-aeep.out", "checksum": 17438, "blocks": 27}, {"filename": "ssout", "checksum": 13282, "blocks": 20}, {"filename": "systemctl.out", "checksum": 14760, "blocks": 38}, {"filename": "top.out", "checksum": 12654, "blocks": 6}, {"filename": "tracepath6.out", "checksum": 1877, "blocks": 1}, {"filename": "tracepath-cnn.out", "checksum": 57607, "blocks": 1}, {"filename": "tr.out", "checksum": 33493, "blocks": 2}, {"filename": "who-aH.out", "checksum": 11896, "blocks": 1}, {"filename": "who.out", "checksum": 56023, "blocks": 1}, {"filename": "whotext", "checksum": 20360, "blocks": 1}] diff --git a/tests/fixtures/centos-7.7/sum.out b/tests/fixtures/centos-7.7/sum.out new file mode 100644 index 000000000..1502ff915 --- /dev/null +++ b/tests/fixtures/centos-7.7/sum.out @@ -0,0 +1,58 @@ +07391 23585 devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm +64318 2 digout +35461 271 dmidecode.out +13394 1 ethtool.out +00000 0 file with spaces in the name +57353 1 id-centos.out +15991 2 ifcfg.json +16654 2 ifconfig.out +12379 57387 jc +33170 1 jc-1.10.5-linux.sha256 +38975 21464 jc-1.10.5-linux.tar.gz +36555 21208 jc-1.10.5.rpm +05771 1 jc-1.11.1-linux.sha256 +33621 19753 jc-1.11.1-linux.tar.gz +63721 1 jc-1.11.1.sha256 +25235 19752 jc-1.11.1.tar.gz +03427 1 jc-1.11.2-linux.sha256 +64653 19758 jc-1.11.2-linux.tar.gz +61535 1 jc-1.11.8-linux.sha256 +11356 19768 jc-1.11.8-linux.tar.gz +00413 1 jc-1.13.1-linux.sha256 +05236 19794 jc-1.13.1-linux.tar.gz +30467 1 jc-1.13.2-linux.sha256 +06369 19789 jc-1.13.2-linux.tar.gz +03858 1 jc-1.13.4-linux.sha256 +48299 19790 jc-1.13.4-linux.tar.gz +09721 1 jello-1.2.8-linux.sha256 +22933 19434 jello-1.2.8-linux.tar.gz +22600 1 jello-1.2.9-linux.sha256 +42077 19435 jello-1.2.9-linux.tar.gz +13482 5874 journaljson +32520 3347 jp +10701 1147 jp_1.1.12_linux_x86_64.zip +44828 721 jq_twitter.json +41413 1 jtbl-1.1.6-linux.sha256 +03616 17798 jtbl-1.1.6-linux.tar.gz +54702 5 kbls.out +14781 1 lastb.out +12059 2 lsblk-cols +18274 2 ping-ip-O-D.out +07583 2 ping-ip-O.out +25564 8 psfile.txt +14654 1 resizeterm.sh +00332 2 route-6-n.out +18331 2 route-6.out +54044 1 routeout +27372 7 sha384sum.out +29060 3 shafile.txt +17438 27 ss-aeep.out +13282 20 ssout +14760 38 systemctl.out +12654 6 top.out +01877 1 tracepath6.out +57607 1 tracepath-cnn.out +33493 2 tr.out +11896 1 who-aH.out +56023 1 who.out +20360 1 whotext diff --git a/tests/fixtures/osx-10.14.6/cksum.json b/tests/fixtures/osx-10.14.6/cksum.json new file mode 100644 index 000000000..9fa776e10 --- /dev/null +++ b/tests/fixtures/osx-10.14.6/cksum.json @@ -0,0 +1 @@ +[{"filename": "airport-I.json", "checksum": 460623577, "blocks": 307}, {"filename": "airport-I.out", "checksum": 3884095294, "blocks": 348}, {"filename": "airport-s.json", "checksum": 3823080718, "blocks": 2152}, {"filename": "airport-s.out", "checksum": 1241296374, "blocks": 1423}, {"filename": "arp-a.json", "checksum": 3662476788, "blocks": 2140}, {"filename": "arp-a.out", "checksum": 394323902, "blocks": 968}, {"filename": "arp-a2.json", "checksum": 2211666137, "blocks": 2979}, {"filename": "arp-a2.out", "checksum": 3627494309, "blocks": 1597}, {"filename": "df-h.json", "checksum": 502389395, "blocks": 1686}, {"filename": "df-h.out", "checksum": 400417014, "blocks": 1276}, {"filename": "df.json", "checksum": 4180452583, "blocks": 1764}, {"filename": "df.out", "checksum": 3870323211, "blocks": 1384}, {"filename": "dig-aaaa.json", "checksum": 1350546134, "blocks": 438}, {"filename": "dig-aaaa.out", "checksum": 3856026265, "blocks": 536}, {"filename": "dig-axfr.json", "checksum": 3740315618, "blocks": 5984}, {"filename": "dig-axfr.out", "checksum": 749991410, "blocks": 3511}, {"filename": "dig-x.json", "checksum": 1318143536, "blocks": 442}, {"filename": "dig-x.out", "checksum": 1399488100, "blocks": 529}, {"filename": "dig.json", "checksum": 968550755, "blocks": 1266}, {"filename": "dig.out", "checksum": 1509929607, "blocks": 1182}, {"filename": "du.json", "checksum": 514470835, "blocks": 295780}, {"filename": "du.out", "checksum": 222115381, "blocks": 221925}, {"filename": "file.json", "checksum": 66574512, "blocks": 3589}, {"filename": "file.out", "checksum": 3410084023, "blocks": 2890}, {"filename": "file2.json", "checksum": 3024780012, "blocks": 4715}, {"filename": "file2.out", "checksum": 2271991347, "blocks": 4780}, {"filename": "group.json", "checksum": 2286919983, "blocks": 9646}, {"filename": "group.out", "checksum": 3791479878, "blocks": 2823}, {"filename": "id.json", "checksum": 2497587728, "blocks": 759}, {"filename": "id.out", "checksum": 4055820469, "blocks": 386}, {"filename": "ifconfig.json", "checksum": 1256465312, "blocks": 10823}, {"filename": "ifconfig.out", "checksum": 2946141711, "blocks": 3779}, {"filename": "ifconfig2.json", "checksum": 2248805689, "blocks": 11375}, {"filename": "ifconfig2.out", "checksum": 2826930050, "blocks": 3979}, {"filename": "last.json", "checksum": 1234289001, "blocks": 45274}, {"filename": "last.out", "checksum": 3878741492, "blocks": 25827}, {"filename": "ls-R-newlines.json", "checksum": 2242924774, "blocks": 852}, {"filename": "ls-R-newlines.out", "checksum": 2580385439, "blocks": 278}, {"filename": "ls-R.json", "checksum": 1166655102, "blocks": 469418}, {"filename": "ls-R.out", "checksum": 4218902119, "blocks": 133787}, {"filename": "ls-al.json", "checksum": 872532263, "blocks": 4653}, {"filename": "ls-al.out", "checksum": 1990624448, "blocks": 2111}, {"filename": "ls-alR.json", "checksum": 533361577, "blocks": 959674}, {"filename": "ls-alR.out", "checksum": 1752728607, "blocks": 364578}, {"filename": "ls-alh.json", "checksum": 2907773845, "blocks": 4684}, {"filename": "ls-alh.out", "checksum": 518393231, "blocks": 2111}, {"filename": "ls-glob.json", "checksum": 2219502793, "blocks": 91544}, {"filename": "ls-glob.out", "checksum": 1750032845, "blocks": 19369}, {"filename": "ls-l-newlines.json", "checksum": 197387780, "blocks": 1162}, {"filename": "ls-l-newlines.out", "checksum": 1407749418, "blocks": 583}, {"filename": "ls-lR-empty-folder.json", "checksum": 3137165058, "blocks": 355547}, {"filename": "ls-lR-empty-folder.out", "checksum": 1563455321, "blocks": 128740}, {"filename": "ls-lR-newlines.json", "checksum": 595722164, "blocks": 1450}, {"filename": "ls-lR-newlines.out", "checksum": 1965541686, "blocks": 656}, {"filename": "ls-newlines.json", "checksum": 3798624201, "blocks": 498}, {"filename": "ls-newlines.out", "checksum": 519911259, "blocks": 260}, {"filename": "ls.json", "checksum": 3112030615, "blocks": 585}, {"filename": "ls.out", "checksum": 1810995639, "blocks": 193}, {"filename": "md5.json", "checksum": 902730595, "blocks": 7764}, {"filename": "md5.out", "checksum": 4230488015, "blocks": 5683}, {"filename": "mount.json", "checksum": 1401281069, "blocks": 672}, {"filename": "mount.out", "checksum": 2768344217, "blocks": 349}, {"filename": "mount2.json", "checksum": 605824441, "blocks": 841}, {"filename": "mount2.out", "checksum": 3636857655, "blocks": 464}, {"filename": "netstat-Abn.json", "checksum": 483687891, "blocks": 151042}, {"filename": "netstat-Abn.out", "checksum": 2899854826, "blocks": 76835}, {"filename": "netstat-An.json", "checksum": 1556983, "blocks": 142438}, {"filename": "netstat-An.out", "checksum": 4286408161, "blocks": 71005}, {"filename": "netstat-i.json", "checksum": 2751687123, "blocks": 7246}, {"filename": "netstat-i.out", "checksum": 2993948661, "blocks": 3354}, {"filename": "netstat-r.json", "checksum": 3675238823, "blocks": 16929}, {"filename": "netstat-r.out", "checksum": 1685265265, "blocks": 6178}, {"filename": "netstat-rnl.json", "checksum": 4218947449, "blocks": 21015}, {"filename": "netstat-rnl.out", "checksum": 1696885775, "blocks": 10055}, {"filename": "netstat.json", "checksum": 2629842889, "blocks": 141195}, {"filename": "netstat.out", "checksum": 2526059995, "blocks": 70387}, {"filename": "passwd.json", "checksum": 339467726, "blocks": 14855}, {"filename": "passwd.out", "checksum": 871931958, "blocks": 6804}, {"filename": "ping-hostname-p.json", "checksum": 4064107262, "blocks": 714}, {"filename": "ping-hostname-p.out", "checksum": 414078650, "blocks": 400}, {"filename": "ping-hostname-s.json", "checksum": 3098475978, "blocks": 714}, {"filename": "ping-hostname-s.out", "checksum": 3273862883, "blocks": 389}, {"filename": "ping-hostname.json", "checksum": 3643045541, "blocks": 706}, {"filename": "ping-hostname.out", "checksum": 2961178857, "blocks": 381}, {"filename": "ping-ip-dup.json", "checksum": 1965089944, "blocks": 2251}, {"filename": "ping-ip-dup.out", "checksum": 926326060, "blocks": 1156}, {"filename": "ping-ip-p.json", "checksum": 3383292259, "blocks": 691}, {"filename": "ping-ip-p.out", "checksum": 4030042554, "blocks": 381}, {"filename": "ping-ip-s.json", "checksum": 339690015, "blocks": 699}, {"filename": "ping-ip-s.out", "checksum": 813997878, "blocks": 375}, {"filename": "ping-ip.json", "checksum": 3307987337, "blocks": 689}, {"filename": "ping-ip.out", "checksum": 3560181069, "blocks": 367}, {"filename": "ping6-hostname-p.json", "checksum": 2969280967, "blocks": 786}, {"filename": "ping6-hostname-p.out", "checksum": 773946458, "blocks": 460}, {"filename": "ping6-hostname-s.json", "checksum": 3681725921, "blocks": 788}, {"filename": "ping6-hostname-s.out", "checksum": 1846670269, "blocks": 449}, {"filename": "ping6-hostname.json", "checksum": 2925748820, "blocks": 784}, {"filename": "ping6-hostname.out", "checksum": 1846085995, "blocks": 446}, {"filename": "ping6-ip-dup.json", "checksum": 2213270797, "blocks": 9447}, {"filename": "ping6-ip-dup.out", "checksum": 2488952539, "blocks": 5225}, {"filename": "ping6-ip-p.json", "checksum": 2942459290, "blocks": 683}, {"filename": "ping6-ip-p.out", "checksum": 3995090292, "blocks": 355}, {"filename": "ping6-ip-s.json", "checksum": 1775639128, "blocks": 688}, {"filename": "ping6-ip-s.out", "checksum": 3951402708, "blocks": 352}, {"filename": "ping6-ip.json", "checksum": 1191437562, "blocks": 681}, {"filename": "ping6-ip.out", "checksum": 4079831039, "blocks": 341}, {"filename": "pip-list.json", "checksum": 149164085, "blocks": 224}, {"filename": "pip-list.out", "checksum": 1574360463, "blocks": 168}, {"filename": "pip-show.json", "checksum": 2037155692, "blocks": 1067}, {"filename": "pip-show.out", "checksum": 456333099, "blocks": 910}, {"filename": "ps-axu.json", "checksum": 317517160, "blocks": 99173}, {"filename": "ps-axu.out", "checksum": 1884966502, "blocks": 60107}, {"filename": "ps-ef.json", "checksum": 1247200492, "blocks": 71162}, {"filename": "ps-ef.out", "checksum": 575731254, "blocks": 48758}, {"filename": "shasum.json", "checksum": 3593483594, "blocks": 11817}, {"filename": "shasum.out", "checksum": 359954755, "blocks": 7982}, {"filename": "stat.json", "checksum": 4238888192, "blocks": 35152}, {"filename": "stat.out", "checksum": 1516293752, "blocks": 15599}, {"filename": "sysctl-a.json", "checksum": 3548337072, "blocks": 46473}, {"filename": "sysctl-a.out", "checksum": 3365777883, "blocks": 42505}, {"filename": "traceroute-asn.json", "checksum": 2602794741, "blocks": 1123}, {"filename": "traceroute-asn.out", "checksum": 1064946112, "blocks": 323}, {"filename": "traceroute-mult-addresses.json", "checksum": 138609038, "blocks": 807}, {"filename": "traceroute-mult-addresses.out", "checksum": 2270547956, "blocks": 305}, {"filename": "traceroute-no-header.json", "checksum": 1099425196, "blocks": 793}, {"filename": "traceroute-no-header.out", "checksum": 3762488639, "blocks": 166}, {"filename": "traceroute-q.json", "checksum": 3109879112, "blocks": 1240}, {"filename": "traceroute-q.out", "checksum": 2116677646, "blocks": 272}, {"filename": "traceroute.json", "checksum": 281326074, "blocks": 2419}, {"filename": "traceroute.out", "checksum": 2303838391, "blocks": 579}, {"filename": "traceroute6-mult-addresses.json", "checksum": 385060355, "blocks": 859}, {"filename": "traceroute6-mult-addresses.out", "checksum": 1294841124, "blocks": 401}, {"filename": "traceroute6.json", "checksum": 385060355, "blocks": 859}, {"filename": "traceroute6.out", "checksum": 680069720, "blocks": 304}, {"filename": "uname-a.json", "checksum": 4051060005, "blocks": 221}, {"filename": "uname-a.out", "checksum": 3290829942, "blocks": 131}, {"filename": "uname.out", "checksum": 272784635, "blocks": 7}, {"filename": "uptime.json", "checksum": 1952629296, "blocks": 110}, {"filename": "uptime.out", "checksum": 174899653, "blocks": 65}, {"filename": "w.json", "checksum": 3374858506, "blocks": 836}, {"filename": "w.out", "checksum": 2080091923, "blocks": 570}, {"filename": "who-a.json", "checksum": 235087184, "blocks": 659}, {"filename": "who-a.out", "checksum": 859367914, "blocks": 419}, {"filename": "who.json", "checksum": 2573389091, "blocks": 251}, {"filename": "who.out", "checksum": 2013191876, "blocks": 128}] diff --git a/tests/fixtures/osx-10.14.6/cksum.out b/tests/fixtures/osx-10.14.6/cksum.out new file mode 100644 index 000000000..7127cc982 --- /dev/null +++ b/tests/fixtures/osx-10.14.6/cksum.out @@ -0,0 +1,145 @@ +460623577 307 airport-I.json +3884095294 348 airport-I.out +3823080718 2152 airport-s.json +1241296374 1423 airport-s.out +3662476788 2140 arp-a.json +394323902 968 arp-a.out +2211666137 2979 arp-a2.json +3627494309 1597 arp-a2.out +502389395 1686 df-h.json +400417014 1276 df-h.out +4180452583 1764 df.json +3870323211 1384 df.out +1350546134 438 dig-aaaa.json +3856026265 536 dig-aaaa.out +3740315618 5984 dig-axfr.json +749991410 3511 dig-axfr.out +1318143536 442 dig-x.json +1399488100 529 dig-x.out +968550755 1266 dig.json +1509929607 1182 dig.out +514470835 295780 du.json +222115381 221925 du.out +66574512 3589 file.json +3410084023 2890 file.out +3024780012 4715 file2.json +2271991347 4780 file2.out +2286919983 9646 group.json +3791479878 2823 group.out +2497587728 759 id.json +4055820469 386 id.out +1256465312 10823 ifconfig.json +2946141711 3779 ifconfig.out +2248805689 11375 ifconfig2.json +2826930050 3979 ifconfig2.out +1234289001 45274 last.json +3878741492 25827 last.out +2242924774 852 ls-R-newlines.json +2580385439 278 ls-R-newlines.out +1166655102 469418 ls-R.json +4218902119 133787 ls-R.out +872532263 4653 ls-al.json +1990624448 2111 ls-al.out +533361577 959674 ls-alR.json +1752728607 364578 ls-alR.out +2907773845 4684 ls-alh.json +518393231 2111 ls-alh.out +2219502793 91544 ls-glob.json +1750032845 19369 ls-glob.out +197387780 1162 ls-l-newlines.json +1407749418 583 ls-l-newlines.out +3137165058 355547 ls-lR-empty-folder.json +1563455321 128740 ls-lR-empty-folder.out +595722164 1450 ls-lR-newlines.json +1965541686 656 ls-lR-newlines.out +3798624201 498 ls-newlines.json +519911259 260 ls-newlines.out +3112030615 585 ls.json +1810995639 193 ls.out +902730595 7764 md5.json +4230488015 5683 md5.out +1401281069 672 mount.json +2768344217 349 mount.out +605824441 841 mount2.json +3636857655 464 mount2.out +483687891 151042 netstat-Abn.json +2899854826 76835 netstat-Abn.out +1556983 142438 netstat-An.json +4286408161 71005 netstat-An.out +2751687123 7246 netstat-i.json +2993948661 3354 netstat-i.out +3675238823 16929 netstat-r.json +1685265265 6178 netstat-r.out +4218947449 21015 netstat-rnl.json +1696885775 10055 netstat-rnl.out +2629842889 141195 netstat.json +2526059995 70387 netstat.out +339467726 14855 passwd.json +871931958 6804 passwd.out +4064107262 714 ping-hostname-p.json +414078650 400 ping-hostname-p.out +3098475978 714 ping-hostname-s.json +3273862883 389 ping-hostname-s.out +3643045541 706 ping-hostname.json +2961178857 381 ping-hostname.out +1965089944 2251 ping-ip-dup.json +926326060 1156 ping-ip-dup.out +3383292259 691 ping-ip-p.json +4030042554 381 ping-ip-p.out +339690015 699 ping-ip-s.json +813997878 375 ping-ip-s.out +3307987337 689 ping-ip.json +3560181069 367 ping-ip.out +2969280967 786 ping6-hostname-p.json +773946458 460 ping6-hostname-p.out +3681725921 788 ping6-hostname-s.json +1846670269 449 ping6-hostname-s.out +2925748820 784 ping6-hostname.json +1846085995 446 ping6-hostname.out +2213270797 9447 ping6-ip-dup.json +2488952539 5225 ping6-ip-dup.out +2942459290 683 ping6-ip-p.json +3995090292 355 ping6-ip-p.out +1775639128 688 ping6-ip-s.json +3951402708 352 ping6-ip-s.out +1191437562 681 ping6-ip.json +4079831039 341 ping6-ip.out +149164085 224 pip-list.json +1574360463 168 pip-list.out +2037155692 1067 pip-show.json +456333099 910 pip-show.out +317517160 99173 ps-axu.json +1884966502 60107 ps-axu.out +1247200492 71162 ps-ef.json +575731254 48758 ps-ef.out +3593483594 11817 shasum.json +359954755 7982 shasum.out +4238888192 35152 stat.json +1516293752 15599 stat.out +3548337072 46473 sysctl-a.json +3365777883 42505 sysctl-a.out +2602794741 1123 traceroute-asn.json +1064946112 323 traceroute-asn.out +138609038 807 traceroute-mult-addresses.json +2270547956 305 traceroute-mult-addresses.out +1099425196 793 traceroute-no-header.json +3762488639 166 traceroute-no-header.out +3109879112 1240 traceroute-q.json +2116677646 272 traceroute-q.out +281326074 2419 traceroute.json +2303838391 579 traceroute.out +385060355 859 traceroute6-mult-addresses.json +1294841124 401 traceroute6-mult-addresses.out +385060355 859 traceroute6.json +680069720 304 traceroute6.out +4051060005 221 uname-a.json +3290829942 131 uname-a.out +272784635 7 uname.out +1952629296 110 uptime.json +174899653 65 uptime.out +3374858506 836 w.json +2080091923 570 w.out +235087184 659 who-a.json +859367914 419 who-a.out +2573389091 251 who.json +2013191876 128 who.out diff --git a/tests/fixtures/osx-10.14.6/sum.json b/tests/fixtures/osx-10.14.6/sum.json new file mode 100644 index 000000000..8a063a060 --- /dev/null +++ b/tests/fixtures/osx-10.14.6/sum.json @@ -0,0 +1 @@ +[{"filename": "airport-I.json", "checksum": 38391, "blocks": 1}, {"filename": "airport-I.out", "checksum": 10927, "blocks": 1}, {"filename": "airport-s.json", "checksum": 19081, "blocks": 3}, {"filename": "airport-s.out", "checksum": 63504, "blocks": 2}, {"filename": "arp-a.json", "checksum": 60887, "blocks": 3}, {"filename": "arp-a.out", "checksum": 18964, "blocks": 1}, {"filename": "arp-a2.json", "checksum": 63795, "blocks": 3}, {"filename": "arp-a2.out", "checksum": 46674, "blocks": 2}, {"filename": "cksum.out", "checksum": 49539, "blocks": 5}, {"filename": "df-h.json", "checksum": 64766, "blocks": 2}, {"filename": "df-h.out", "checksum": 415, "blocks": 2}, {"filename": "df.json", "checksum": 37365, "blocks": 2}, {"filename": "df.out", "checksum": 12639, "blocks": 2}, {"filename": "dig-aaaa.json", "checksum": 8111, "blocks": 1}, {"filename": "dig-aaaa.out", "checksum": 50417, "blocks": 1}, {"filename": "dig-axfr.json", "checksum": 43183, "blocks": 6}, {"filename": "dig-axfr.out", "checksum": 28178, "blocks": 4}, {"filename": "dig-x.json", "checksum": 2727, "blocks": 1}, {"filename": "dig-x.out", "checksum": 11169, "blocks": 1}, {"filename": "dig.json", "checksum": 40945, "blocks": 2}, {"filename": "dig.out", "checksum": 61726, "blocks": 2}, {"filename": "du.json", "checksum": 38720, "blocks": 289}, {"filename": "du.out", "checksum": 16890, "blocks": 217}, {"filename": "file.json", "checksum": 37280, "blocks": 4}, {"filename": "file.out", "checksum": 9660, "blocks": 3}, {"filename": "file2.json", "checksum": 29539, "blocks": 5}, {"filename": "file2.out", "checksum": 33868, "blocks": 5}, {"filename": "group.json", "checksum": 50477, "blocks": 10}, {"filename": "group.out", "checksum": 55547, "blocks": 3}, {"filename": "id.json", "checksum": 21649, "blocks": 1}, {"filename": "id.out", "checksum": 26181, "blocks": 1}, {"filename": "ifconfig.json", "checksum": 17770, "blocks": 11}, {"filename": "ifconfig.out", "checksum": 10956, "blocks": 4}, {"filename": "ifconfig2.json", "checksum": 35645, "blocks": 12}, {"filename": "ifconfig2.out", "checksum": 38293, "blocks": 4}, {"filename": "last.json", "checksum": 36756, "blocks": 45}, {"filename": "last.out", "checksum": 23587, "blocks": 26}, {"filename": "ls-R-newlines.json", "checksum": 30013, "blocks": 1}, {"filename": "ls-R-newlines.out", "checksum": 42103, "blocks": 1}, {"filename": "ls-R.json", "checksum": 37108, "blocks": 459}, {"filename": "ls-R.out", "checksum": 63758, "blocks": 131}, {"filename": "ls-al.json", "checksum": 56923, "blocks": 5}, {"filename": "ls-al.out", "checksum": 15531, "blocks": 3}, {"filename": "ls-alR.json", "checksum": 1382, "blocks": 938}, {"filename": "ls-alR.out", "checksum": 4461, "blocks": 357}, {"filename": "ls-alh.json", "checksum": 57950, "blocks": 5}, {"filename": "ls-alh.out", "checksum": 6947, "blocks": 3}, {"filename": "ls-glob.json", "checksum": 31393, "blocks": 90}, {"filename": "ls-glob.out", "checksum": 1019, "blocks": 19}, {"filename": "ls-l-newlines.json", "checksum": 57505, "blocks": 2}, {"filename": "ls-l-newlines.out", "checksum": 41948, "blocks": 1}, {"filename": "ls-lR-empty-folder.json", "checksum": 11529, "blocks": 348}, {"filename": "ls-lR-empty-folder.out", "checksum": 58132, "blocks": 126}, {"filename": "ls-lR-newlines.json", "checksum": 6935, "blocks": 2}, {"filename": "ls-lR-newlines.out", "checksum": 41356, "blocks": 1}, {"filename": "ls-newlines.json", "checksum": 9894, "blocks": 1}, {"filename": "ls-newlines.out", "checksum": 57269, "blocks": 1}, {"filename": "ls.json", "checksum": 17338, "blocks": 1}, {"filename": "ls.out", "checksum": 52477, "blocks": 1}, {"filename": "md5.json", "checksum": 36019, "blocks": 8}, {"filename": "md5.out", "checksum": 42534, "blocks": 6}, {"filename": "mount.json", "checksum": 37000, "blocks": 1}, {"filename": "mount.out", "checksum": 16534, "blocks": 1}, {"filename": "mount2.json", "checksum": 45746, "blocks": 1}, {"filename": "mount2.out", "checksum": 55291, "blocks": 1}, {"filename": "netstat-Abn.json", "checksum": 34181, "blocks": 148}, {"filename": "netstat-Abn.out", "checksum": 5732, "blocks": 76}, {"filename": "netstat-An.json", "checksum": 27697, "blocks": 140}, {"filename": "netstat-An.out", "checksum": 26933, "blocks": 70}, {"filename": "netstat-i.json", "checksum": 13656, "blocks": 8}, {"filename": "netstat-i.out", "checksum": 7961, "blocks": 4}, {"filename": "netstat-r.json", "checksum": 11407, "blocks": 17}, {"filename": "netstat-r.out", "checksum": 18759, "blocks": 7}, {"filename": "netstat-rnl.json", "checksum": 63267, "blocks": 21}, {"filename": "netstat-rnl.out", "checksum": 62814, "blocks": 10}, {"filename": "netstat.json", "checksum": 41515, "blocks": 138}, {"filename": "netstat.out", "checksum": 32647, "blocks": 69}, {"filename": "passwd.json", "checksum": 39641, "blocks": 15}, {"filename": "passwd.out", "checksum": 19130, "blocks": 7}, {"filename": "ping-hostname-p.json", "checksum": 113, "blocks": 1}, {"filename": "ping-hostname-p.out", "checksum": 6247, "blocks": 1}, {"filename": "ping-hostname-s.json", "checksum": 12827, "blocks": 1}, {"filename": "ping-hostname-s.out", "checksum": 23515, "blocks": 1}, {"filename": "ping-hostname.json", "checksum": 21637, "blocks": 1}, {"filename": "ping-hostname.out", "checksum": 18604, "blocks": 1}, {"filename": "ping-ip-dup.json", "checksum": 26389, "blocks": 3}, {"filename": "ping-ip-dup.out", "checksum": 19769, "blocks": 2}, {"filename": "ping-ip-p.json", "checksum": 24589, "blocks": 1}, {"filename": "ping-ip-p.out", "checksum": 46644, "blocks": 1}, {"filename": "ping-ip-s.json", "checksum": 33523, "blocks": 1}, {"filename": "ping-ip-s.out", "checksum": 25608, "blocks": 1}, {"filename": "ping-ip.json", "checksum": 8854, "blocks": 1}, {"filename": "ping-ip.out", "checksum": 62691, "blocks": 1}, {"filename": "ping6-hostname-p.json", "checksum": 49568, "blocks": 1}, {"filename": "ping6-hostname-p.out", "checksum": 53253, "blocks": 1}, {"filename": "ping6-hostname-s.json", "checksum": 25633, "blocks": 1}, {"filename": "ping6-hostname-s.out", "checksum": 33091, "blocks": 1}, {"filename": "ping6-hostname.json", "checksum": 7678, "blocks": 1}, {"filename": "ping6-hostname.out", "checksum": 57086, "blocks": 1}, {"filename": "ping6-ip-dup.json", "checksum": 22863, "blocks": 10}, {"filename": "ping6-ip-dup.out", "checksum": 43494, "blocks": 6}, {"filename": "ping6-ip-p.json", "checksum": 39183, "blocks": 1}, {"filename": "ping6-ip-p.out", "checksum": 34802, "blocks": 1}, {"filename": "ping6-ip-s.json", "checksum": 40367, "blocks": 1}, {"filename": "ping6-ip-s.out", "checksum": 51554, "blocks": 1}, {"filename": "ping6-ip.json", "checksum": 57462, "blocks": 1}, {"filename": "ping6-ip.out", "checksum": 36941, "blocks": 1}, {"filename": "pip-list.json", "checksum": 29175, "blocks": 1}, {"filename": "pip-list.out", "checksum": 20474, "blocks": 1}, {"filename": "pip-show.json", "checksum": 37722, "blocks": 2}, {"filename": "pip-show.out", "checksum": 18260, "blocks": 1}, {"filename": "ps-axu.json", "checksum": 24887, "blocks": 97}, {"filename": "ps-axu.out", "checksum": 43405, "blocks": 59}, {"filename": "ps-ef.json", "checksum": 62822, "blocks": 70}, {"filename": "ps-ef.out", "checksum": 46842, "blocks": 48}, {"filename": "shasum.json", "checksum": 29690, "blocks": 12}, {"filename": "shasum.out", "checksum": 31405, "blocks": 8}, {"filename": "stat.json", "checksum": 30773, "blocks": 35}, {"filename": "stat.out", "checksum": 27996, "blocks": 16}, {"filename": "sysctl-a.json", "checksum": 54364, "blocks": 46}, {"filename": "sysctl-a.out", "checksum": 56073, "blocks": 42}, {"filename": "traceroute-asn.json", "checksum": 60232, "blocks": 2}, {"filename": "traceroute-asn.out", "checksum": 60268, "blocks": 1}, {"filename": "traceroute-mult-addresses.json", "checksum": 7554, "blocks": 1}, {"filename": "traceroute-mult-addresses.out", "checksum": 19479, "blocks": 1}, {"filename": "traceroute-no-header.json", "checksum": 14875, "blocks": 1}, {"filename": "traceroute-no-header.out", "checksum": 62949, "blocks": 1}, {"filename": "traceroute-q.json", "checksum": 12931, "blocks": 2}, {"filename": "traceroute-q.out", "checksum": 52433, "blocks": 1}, {"filename": "traceroute.json", "checksum": 45516, "blocks": 3}, {"filename": "traceroute.out", "checksum": 2209, "blocks": 1}, {"filename": "traceroute6-mult-addresses.json", "checksum": 12134, "blocks": 1}, {"filename": "traceroute6-mult-addresses.out", "checksum": 52070, "blocks": 1}, {"filename": "traceroute6.json", "checksum": 12134, "blocks": 1}, {"filename": "traceroute6.out", "checksum": 0, "blocks": 1}, {"filename": "uname-a.json", "checksum": 33535, "blocks": 1}, {"filename": "uname-a.out", "checksum": 39634, "blocks": 1}, {"filename": "uname.out", "checksum": 22645, "blocks": 1}, {"filename": "uptime.json", "checksum": 59092, "blocks": 1}, {"filename": "uptime.out", "checksum": 45958, "blocks": 1}, {"filename": "w.json", "checksum": 8647, "blocks": 1}, {"filename": "w.out", "checksum": 16304, "blocks": 1}, {"filename": "who-a.json", "checksum": 61006, "blocks": 1}, {"filename": "who-a.out", "checksum": 8784, "blocks": 1}, {"filename": "who.json", "checksum": 6467, "blocks": 1}, {"filename": "who.out", "checksum": 27498, "blocks": 1}] diff --git a/tests/fixtures/osx-10.14.6/sum.out b/tests/fixtures/osx-10.14.6/sum.out new file mode 100644 index 000000000..1ef97080c --- /dev/null +++ b/tests/fixtures/osx-10.14.6/sum.out @@ -0,0 +1,146 @@ +38391 1 airport-I.json +10927 1 airport-I.out +19081 3 airport-s.json +63504 2 airport-s.out +60887 3 arp-a.json +18964 1 arp-a.out +63795 3 arp-a2.json +46674 2 arp-a2.out +49539 5 cksum.out +64766 2 df-h.json +415 2 df-h.out +37365 2 df.json +12639 2 df.out +8111 1 dig-aaaa.json +50417 1 dig-aaaa.out +43183 6 dig-axfr.json +28178 4 dig-axfr.out +2727 1 dig-x.json +11169 1 dig-x.out +40945 2 dig.json +61726 2 dig.out +38720 289 du.json +16890 217 du.out +37280 4 file.json +9660 3 file.out +29539 5 file2.json +33868 5 file2.out +50477 10 group.json +55547 3 group.out +21649 1 id.json +26181 1 id.out +17770 11 ifconfig.json +10956 4 ifconfig.out +35645 12 ifconfig2.json +38293 4 ifconfig2.out +36756 45 last.json +23587 26 last.out +30013 1 ls-R-newlines.json +42103 1 ls-R-newlines.out +37108 459 ls-R.json +63758 131 ls-R.out +56923 5 ls-al.json +15531 3 ls-al.out +1382 938 ls-alR.json +4461 357 ls-alR.out +57950 5 ls-alh.json +6947 3 ls-alh.out +31393 90 ls-glob.json +1019 19 ls-glob.out +57505 2 ls-l-newlines.json +41948 1 ls-l-newlines.out +11529 348 ls-lR-empty-folder.json +58132 126 ls-lR-empty-folder.out +6935 2 ls-lR-newlines.json +41356 1 ls-lR-newlines.out +9894 1 ls-newlines.json +57269 1 ls-newlines.out +17338 1 ls.json +52477 1 ls.out +36019 8 md5.json +42534 6 md5.out +37000 1 mount.json +16534 1 mount.out +45746 1 mount2.json +55291 1 mount2.out +34181 148 netstat-Abn.json +5732 76 netstat-Abn.out +27697 140 netstat-An.json +26933 70 netstat-An.out +13656 8 netstat-i.json +7961 4 netstat-i.out +11407 17 netstat-r.json +18759 7 netstat-r.out +63267 21 netstat-rnl.json +62814 10 netstat-rnl.out +41515 138 netstat.json +32647 69 netstat.out +39641 15 passwd.json +19130 7 passwd.out +113 1 ping-hostname-p.json +6247 1 ping-hostname-p.out +12827 1 ping-hostname-s.json +23515 1 ping-hostname-s.out +21637 1 ping-hostname.json +18604 1 ping-hostname.out +26389 3 ping-ip-dup.json +19769 2 ping-ip-dup.out +24589 1 ping-ip-p.json +46644 1 ping-ip-p.out +33523 1 ping-ip-s.json +25608 1 ping-ip-s.out +8854 1 ping-ip.json +62691 1 ping-ip.out +49568 1 ping6-hostname-p.json +53253 1 ping6-hostname-p.out +25633 1 ping6-hostname-s.json +33091 1 ping6-hostname-s.out +7678 1 ping6-hostname.json +57086 1 ping6-hostname.out +22863 10 ping6-ip-dup.json +43494 6 ping6-ip-dup.out +39183 1 ping6-ip-p.json +34802 1 ping6-ip-p.out +40367 1 ping6-ip-s.json +51554 1 ping6-ip-s.out +57462 1 ping6-ip.json +36941 1 ping6-ip.out +29175 1 pip-list.json +20474 1 pip-list.out +37722 2 pip-show.json +18260 1 pip-show.out +24887 97 ps-axu.json +43405 59 ps-axu.out +62822 70 ps-ef.json +46842 48 ps-ef.out +29690 12 shasum.json +31405 8 shasum.out +30773 35 stat.json +27996 16 stat.out +54364 46 sysctl-a.json +56073 42 sysctl-a.out +60232 2 traceroute-asn.json +60268 1 traceroute-asn.out +7554 1 traceroute-mult-addresses.json +19479 1 traceroute-mult-addresses.out +14875 1 traceroute-no-header.json +62949 1 traceroute-no-header.out +12931 2 traceroute-q.json +52433 1 traceroute-q.out +45516 3 traceroute.json +2209 1 traceroute.out +12134 1 traceroute6-mult-addresses.json +52070 1 traceroute6-mult-addresses.out +12134 1 traceroute6.json +0 1 traceroute6.out +33535 1 uname-a.json +39634 1 uname-a.out +22645 1 uname.out +59092 1 uptime.json +45958 1 uptime.out +8647 1 w.json +16304 1 w.out +61006 1 who-a.json +8784 1 who-a.out +6467 1 who.json +27498 1 who.out diff --git a/tests/test_cksum.py b/tests/test_cksum.py new file mode 100644 index 000000000..d52f8f52b --- /dev/null +++ b/tests/test_cksum.py @@ -0,0 +1,70 @@ +import os +import unittest +import json +import jc.parsers.cksum + +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + + +class MyTests(unittest.TestCase): + + def setUp(self): + # input + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/cksum.out'), 'r', encoding='utf-8') as f: + self.centos_7_7_cksum = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/sum.out'), 'r', encoding='utf-8') as f: + self.centos_7_7_sum = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/cksum.out'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_cksum = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/sum.out'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_sum = f.read() + + # output + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/cksum.json'), 'r', encoding='utf-8') as f: + self.centos_7_7_cksum_json = json.loads(f.read()) + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/sum.json'), 'r', encoding='utf-8') as f: + self.centos_7_7_sum_json = json.loads(f.read()) + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/cksum.json'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_cksum_json = json.loads(f.read()) + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/sum.json'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_sum_json = json.loads(f.read()) + + def test_cksum_nodata(self): + """ + Test 'cksum' parser with no data + """ + self.assertEqual(jc.parsers.cksum.parse('', quiet=True), []) + + def test_cksum_centos_7_7(self): + """ + Test 'cksum' on Centos 7.7 + """ + self.assertEqual(jc.parsers.cksum.parse(self.centos_7_7_cksum, quiet=True), self.centos_7_7_cksum_json) + + def test_sum_centos_7_7(self): + """ + Test 'sum' on Centos 7.7 + """ + self.assertEqual(jc.parsers.cksum.parse(self.centos_7_7_sum, quiet=True), self.centos_7_7_sum_json) + + def test_cksum_osx_10_14_6(self): + """ + Test 'cksum' on OSX 10.14.6 + """ + self.assertEqual(jc.parsers.cksum.parse(self.osx_10_14_6_cksum, quiet=True), self.osx_10_14_6_cksum_json) + + def test_sum_osx_10_14_6(self): + """ + Test 'sum' on OSX 10.14.6 + """ + self.assertEqual(jc.parsers.cksum.parse(self.osx_10_14_6_sum, quiet=True), self.osx_10_14_6_sum_json) + + +if __name__ == '__main__': + unittest.main() From a9be42e3031ab0d697cff67a9e384caa2265a3ad Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 30 Dec 2020 11:28:42 -0800 Subject: [PATCH 11/24] specify parser warnings for quiet option --- jc/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jc/cli.py b/jc/cli.py index 8b09fb734..8781da2f6 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -298,7 +298,7 @@ def helptext(message): -d debug - show traceback (-dd for verbose traceback) -m monochrome output -p pretty print output - -q quiet - suppress warnings + -q quiet - suppress parser warnings -r raw JSON output Example: From fdedab2a0cf5af15df5803d87302397dd6d71741 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 30 Dec 2020 11:33:29 -0800 Subject: [PATCH 12/24] description updates --- jc/parsers/cksum.py | 2 +- jc/parsers/hashsum.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jc/parsers/cksum.py b/jc/parsers/cksum.py index 1b3123627..04d9303f9 100644 --- a/jc/parsers/cksum.py +++ b/jc/parsers/cksum.py @@ -48,7 +48,7 @@ class info(): version = '1.0' - description = 'cksum command and file parser' + description = 'cksum command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' details = 'Parses cksum and sum program output' diff --git a/jc/parsers/hashsum.py b/jc/parsers/hashsum.py index f3e5722c1..9f7b86124 100644 --- a/jc/parsers/hashsum.py +++ b/jc/parsers/hashsum.py @@ -63,7 +63,7 @@ class info(): version = '1.0' - description = 'hashsum command and file parser (md5sum, shasum, etc.)' + description = 'hashsum command parser (md5sum, shasum, etc.)' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' details = 'Parses MD5 and SHA hash program output' From 55f360e267fdfcfef0c124ed6b88535cc181a8b0 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 30 Dec 2020 12:58:52 -0800 Subject: [PATCH 13/24] add hash command parser --- CHANGELOG | 1 + EXAMPLES.md | 71 ++++++++++++++++++++++++++++ docgen.sh | 1 + docs/parsers/hash.md | 78 +++++++++++++++++++++++++++++++ jc/cli.py | 1 + jc/parsers/hash.py | 108 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 260 insertions(+) create mode 100644 docs/parsers/hash.md create mode 100644 jc/parsers/hash.py diff --git a/CHANGELOG b/CHANGELOG index 0a7f3ad00..9db03f65f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ jc changelog 20201229 v1.14.0 - Add hashsum parser tested on linux, macos +- Add hash parser tested on linux, macos - Add cksum parser tested on linux, macos - Add python 3.9 to github automation tests diff --git a/EXAMPLES.md b/EXAMPLES.md index 69b7c5093..73c53a299 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -175,6 +175,29 @@ blkid -o udev -ip /dev/sda2 | jc --blkid -p # or: jc -p blkid -o udev } ] ``` +### cksum +```bash +cksum * | jc --cksum -p # or: jc -p cksum * +``` +```json +[ + { + "filename": "__init__.py", + "checksum": 4294967295, + "blocks": 0 + }, + { + "filename": "airport.py", + "checksum": 2208551092, + "blocks": 3745 + }, + { + "filename": "airport_s.py", + "checksum": 1113817598, + "blocks": 4572 + } +] +``` ### crontab ```bash cat /etc/crontab | jc --crontab -p # or: jc -p crontab -l @@ -843,6 +866,54 @@ cat /etc/gshadow | jc --gshadow -p } ] ``` +### hash +```bash +hash | jc --hash -p +``` +```json +[ + { + "hits": 2, + "command": "/bin/cat" + }, + { + "hits": 1, + "command": "/bin/ls" + } +] +``` +### hashsum +```bash +md5sum * | jc --hashsum -p # or: jc -p md5sum * +``` +```json +[ + { + "filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm", + "hash": "65fc958c1add637ec23c4b137aecf3d3" + }, + { + "filename": "digout", + "hash": "5b9312ee5aff080927753c63a347707d" + }, + { + "filename": "dmidecode.out", + "hash": "716fd11c2ac00db109281f7110b8fb9d" + }, + { + "filename": "file with spaces in the name", + "hash": "d41d8cd98f00b204e9800998ecf8427e" + }, + { + "filename": "id-centos.out", + "hash": "4295be239a14ad77ef3253103de976d2" + }, + { + "filename": "ifcfg.json", + "hash": "01fda0d9ba9a75618b072e64ff512b43" + } +] +``` ### history ```bash history | jc --history -p diff --git a/docgen.sh b/docgen.sh index 99f27e189..7d053fc19 100755 --- a/docgen.sh +++ b/docgen.sh @@ -24,6 +24,7 @@ pydocmd simple jc.parsers.free+ > ../docs/parsers/free.md pydocmd simple jc.parsers.fstab+ > ../docs/parsers/fstab.md pydocmd simple jc.parsers.group+ > ../docs/parsers/group.md pydocmd simple jc.parsers.gshadow+ > ../docs/parsers/gshadow.md +pydocmd simple jc.parsers.hash+ > ../docs/parsers/hash.md pydocmd simple jc.parsers.hashsum+ > ../docs/parsers/hashsum.md pydocmd simple jc.parsers.history+ > ../docs/parsers/history.md pydocmd simple jc.parsers.hosts+ > ../docs/parsers/hosts.md diff --git a/docs/parsers/hash.md b/docs/parsers/hash.md new file mode 100644 index 000000000..0179a34f8 --- /dev/null +++ b/docs/parsers/hash.md @@ -0,0 +1,78 @@ + +# jc.parsers.hash +jc - JSON CLI output utility `hash` command output parser + +Usage (cli): + + $ hash | jc --hash + +Usage (module): + + import jc.parsers.hash + result = jc.parsers.hash.parse(hash_command_output) + +Compatibility: + + 'linux', 'darwin', 'cygwin', 'aix', 'freebsd' + +Examples: + + $ hash | jc --hash -p + [ + { + "hits": 2, + "command": "/bin/cat" + }, + { + "hits": 1, + "command": "/bin/ls" + } + ] + + +## info +```python +info() +``` + + +## process +```python +process(proc_data) +``` + +Final processing to conform to the schema. + +Parameters: + + proc_data: (dictionary) raw structured data to process + +Returns: + + List of dictionaries. Structured data with the following schema: + + [ + { + "command": string, + "hits": integer + } + ] + + +## parse +```python +parse(data, raw=False, quiet=False) +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + +Returns: + + List of dictionaries. Raw or processed structured data. + diff --git a/jc/cli.py b/jc/cli.py index 8781da2f6..1feac4f42 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -49,6 +49,7 @@ class info(): 'fstab', 'group', 'gshadow', + 'hash', 'hashsum', 'history', 'hosts', diff --git a/jc/parsers/hash.py b/jc/parsers/hash.py new file mode 100644 index 000000000..9ef08d015 --- /dev/null +++ b/jc/parsers/hash.py @@ -0,0 +1,108 @@ +"""jc - JSON CLI output utility `hash` command output parser + +Usage (cli): + + $ hash | jc --hash + +Usage (module): + + import jc.parsers.hash + result = jc.parsers.hash.parse(hash_command_output) + +Compatibility: + + 'linux', 'darwin', 'cygwin', 'aix', 'freebsd' + +Examples: + + $ hash | jc --hash -p + [ + { + "hits": 2, + "command": "/bin/cat" + }, + { + "hits": 1, + "command": "/bin/ls" + } + ] +""" +import jc.utils +import jc.parsers.universal + + +class info(): + version = '1.0' + description = 'hash command parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + + +__version__ = info.version + + +def process(proc_data): + """ + Final processing to conform to the schema. + + Parameters: + + proc_data: (dictionary) raw structured data to process + + Returns: + + List of dictionaries. Structured data with the following schema: + + [ + { + "command": string, + "hits": integer + } + ] + """ + for entry in proc_data: + # change to int + int_list = ['hits'] + for key in int_list: + if key in entry: + try: + key_int = int(entry[key]) + entry[key] = key_int + except (ValueError): + entry[key] = None + + return proc_data + + +def parse(data, raw=False, quiet=False): + """ + Main text parsing function + + Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + + Returns: + + List of dictionaries. Raw or processed structured data. + """ + if not quiet: + jc.utils.compatibility(__name__, info.compatible) + + cleandata = data.splitlines() + raw_output = [] + + if jc.utils.has_data(data): + + cleandata[0] = cleandata[0].lower() + raw_output = jc.parsers.universal.simple_table_parse(cleandata) + + if raw: + return raw_output + else: + return process(raw_output) From d4ae5543f2d5f28a0db5b8e2e19993c21c5d960c Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 30 Dec 2020 13:11:13 -0800 Subject: [PATCH 14/24] add hash tests --- tests/fixtures/centos-7.7/hash.json | 1 + tests/fixtures/centos-7.7/hash.out | 4 ++++ tests/test_hash.py | 34 +++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 tests/fixtures/centos-7.7/hash.json create mode 100644 tests/fixtures/centos-7.7/hash.out create mode 100644 tests/test_hash.py diff --git a/tests/fixtures/centos-7.7/hash.json b/tests/fixtures/centos-7.7/hash.json new file mode 100644 index 000000000..3427281c6 --- /dev/null +++ b/tests/fixtures/centos-7.7/hash.json @@ -0,0 +1 @@ +[{"hits": 3, "command": "/usr/bin/sum"}, {"hits": 2, "command": "/usr/bin/cat"}, {"hits": 2, "command": "/usr/bin/cksum"}] diff --git a/tests/fixtures/centos-7.7/hash.out b/tests/fixtures/centos-7.7/hash.out new file mode 100644 index 000000000..985822639 --- /dev/null +++ b/tests/fixtures/centos-7.7/hash.out @@ -0,0 +1,4 @@ +hits command + 3 /usr/bin/sum + 2 /usr/bin/cat + 2 /usr/bin/cksum diff --git a/tests/test_hash.py b/tests/test_hash.py new file mode 100644 index 000000000..f370fc15a --- /dev/null +++ b/tests/test_hash.py @@ -0,0 +1,34 @@ +import os +import unittest +import json +import jc.parsers.hash + +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + + +class MyTests(unittest.TestCase): + + def setUp(self): + # input + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/hash.out'), 'r', encoding='utf-8') as f: + self.centos_7_7_hash = f.read() + + # output + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/hash.json'), 'r', encoding='utf-8') as f: + self.centos_7_7_hash_json = json.loads(f.read()) + + def test_hash_nodata(self): + """ + Test 'hash' parser with no data + """ + self.assertEqual(jc.parsers.hash.parse('', quiet=True), []) + + def test_hash_centos_7_7(self): + """ + Test 'hash' on Centos 7.7 + """ + self.assertEqual(jc.parsers.hash.parse(self.centos_7_7_hash, quiet=True), self.centos_7_7_hash_json) + + +if __name__ == '__main__': + unittest.main() From 276160125e01553c75eaad68530177bcf4f9004d Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 30 Dec 2020 14:04:49 -0800 Subject: [PATCH 15/24] add new commands to README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 29472f0ed..b026d727e 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio - `--airport-s` enables the `airport -s` command parser (OSX) - `--arp` enables the `arp` command parser - `--blkid` enables the `blkid` command parser +- `--cksum` enables the `cksum` and `sum` command parser - `--crontab` enables the `crontab` command and file parser - `--crontab-u` enables the `crontab` file parser with user support - `--csv` enables the `CSV` file parser @@ -136,6 +137,8 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio - `--fstab` enables the `/etc/fstab` file parser - `--group` enables the `/etc/group` file parser - `--gshadow` enables the `/etc/gshadow` file parser +- `--hash` enables the `hash` command parser +- `--hashsum` enables the `hashsum` command parser (`md5sum`, `shasum`, etc.) - `--history` enables the `history` command parser - `--hosts` enables the `/etc/hosts` file parser - `--id` enables the `id` command parser From 5e6bfa681aff03fbd683f81a9f4daa56b49d1344 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 31 Dec 2020 13:18:53 -0800 Subject: [PATCH 16/24] add vdir info --- README.md | 2 +- docs/parsers/ls.md | 4 ++-- jc/parsers/ls.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b026d727e..900430b22 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio - `--jobs` enables the `jobs` command parser - `--kv` enables the `Key/Value` file parser - `--last` enables the `last` and `lastb` command parser -- `--ls` enables the `ls` command parser +- `--ls` enables the `ls` and `vdir` command parser - `--lsblk` enables the `lsblk` command parser - `--lsmod` enables the `lsmod` command parser - `--lsof` enables the `lsof` command parser diff --git a/docs/parsers/ls.md b/docs/parsers/ls.md index c46ee00cf..6c7b480c4 100644 --- a/docs/parsers/ls.md +++ b/docs/parsers/ls.md @@ -1,13 +1,13 @@ # jc.parsers.ls -jc - JSON CLI output utility `ls` command output parser +jc - JSON CLI output utility `ls` and `vdir` command output parser Options supported: - `lbaR` - `--time-style=full-iso` - `-h`: File sizes will be available in text form with `-r` but larger file sizes with human readable suffixes will be converted to `Null` in the default view since the parser attempts to convert this field to an integer. -Note: The `-l` or `-b` option of `ls` should be used to correctly parse filenames that include newline characters. Since `ls` does not encode newlines in filenames when outputting to a pipe it will cause `jc` to see multiple files instead of a single file if `-l` or `-b` is not used. +Note: The `-l` or `-b` option of `ls` should be used to correctly parse filenames that include newline characters. Since `ls` does not encode newlines in filenames when outputting to a pipe it will cause `jc` to see multiple files instead of a single file if `-l` or `-b` is not used. Alternatively, `vdir` can be used, which is the same as running `ls -lb`. Usage (cli): diff --git a/jc/parsers/ls.py b/jc/parsers/ls.py index f7a6e38d6..91a40b7c4 100644 --- a/jc/parsers/ls.py +++ b/jc/parsers/ls.py @@ -1,11 +1,11 @@ -"""jc - JSON CLI output utility `ls` command output parser +"""jc - JSON CLI output utility `ls` and `vdir` command output parser Options supported: - `lbaR` - `--time-style=full-iso` - `-h`: File sizes will be available in text form with `-r` but larger file sizes with human readable suffixes will be converted to `Null` in the default view since the parser attempts to convert this field to an integer. -Note: The `-l` or `-b` option of `ls` should be used to correctly parse filenames that include newline characters. Since `ls` does not encode newlines in filenames when outputting to a pipe it will cause `jc` to see multiple files instead of a single file if `-l` or `-b` is not used. +Note: The `-l` or `-b` option of `ls` should be used to correctly parse filenames that include newline characters. Since `ls` does not encode newlines in filenames when outputting to a pipe it will cause `jc` to see multiple files instead of a single file if `-l` or `-b` is not used. Alternatively, `vdir` can be used, which is the same as running `ls -lb`. Usage (cli): @@ -160,7 +160,7 @@ class info(): # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] - magic_commands = ['ls'] + magic_commands = ['ls', 'vdir'] __version__ = info.version From e4bac3a493705b09e301ddc90dd1b0cee7467c3f Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 31 Dec 2020 14:10:37 -0800 Subject: [PATCH 17/24] add wc parser --- CHANGELOG | 1 + EXAMPLES.md | 26 +++++ README.md | 1 + jc/cli.py | 1 + jc/parsers/wc.py | 130 +++++++++++++++++++++++++ tests/fixtures/centos-7.7/wc.json | 1 + tests/fixtures/centos-7.7/wc.out | 67 +++++++++++++ tests/fixtures/osx-10.14.6/wc.json | 1 + tests/fixtures/osx-10.14.6/wc.out | 150 +++++++++++++++++++++++++++++ 9 files changed, 378 insertions(+) create mode 100644 jc/parsers/wc.py create mode 100644 tests/fixtures/centos-7.7/wc.json create mode 100644 tests/fixtures/centos-7.7/wc.out create mode 100644 tests/fixtures/osx-10.14.6/wc.json create mode 100644 tests/fixtures/osx-10.14.6/wc.out diff --git a/CHANGELOG b/CHANGELOG index 9db03f65f..28ef0cebc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ jc changelog - Add hashsum parser tested on linux, macos - Add hash parser tested on linux, macos - Add cksum parser tested on linux, macos +- Add wc parser tested on linux, macos - Add python 3.9 to github automation tests 20200805 v1.13.4 diff --git a/EXAMPLES.md b/EXAMPLES.md index 73c53a299..346607963 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -2540,6 +2540,32 @@ w | jc --w -p # or: jc -p w } ] ``` +### wc +```bash +wc * | jc --wc -p # or: jc -p wc * +``` +```json +[ + { + "filename": "airport-I.json", + "lines": 1, + "words": 30, + "characters": 307 + }, + { + "filename": "airport-I.out", + "lines": 15, + "words": 33, + "characters": 348 + }, + { + "filename": "airport-s.json", + "lines": 1, + "words": 202, + "characters": 2152 + } + ] +``` ### who ```bash who | jc --who -p # or: jc -p who diff --git a/README.md b/README.md index 900430b22..7aea5adf6 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio - `--uname` enables the `uname -a` command parser - `--uptime` enables the `uptime` command parser - `--w` enables the `w` command parser +- `--wc` enables the `wc` command parser - `--who` enables the `who` command parser - `--xml` enables the `XML` file parser - `--yaml` enables the `YAML` file parser diff --git a/jc/cli.py b/jc/cli.py index 1feac4f42..1a268c249 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -87,6 +87,7 @@ class info(): 'uname', 'uptime', 'w', + 'wc', 'who', 'xml', 'yaml' diff --git a/jc/parsers/wc.py b/jc/parsers/wc.py new file mode 100644 index 000000000..bb3237782 --- /dev/null +++ b/jc/parsers/wc.py @@ -0,0 +1,130 @@ +"""jc - JSON CLI output utility `wc` command output parser + +Usage (cli): + + $ wc file.txt | jc --wc + + or + + $ jc wc file.txt + +Usage (module): + + import jc.parsers.wc + result = jc.parsers.wc.parse(wc_command_output) + +Compatibility: + + 'linux', 'darwin', 'cygwin', 'aix', 'freebsd' + +Examples: + + $ wc * | jc --wc -p + [ + { + "filename": "airport-I.json", + "lines": 1, + "words": 30, + "characters": 307 + }, + { + "filename": "airport-I.out", + "lines": 15, + "words": 33, + "characters": 348 + }, + { + "filename": "airport-s.json", + "lines": 1, + "words": 202, + "characters": 2152 + }, + ... + ] +""" +import jc.utils + + +class info(): + version = '1.0' + description = 'wc command parser' + author = 'Kelly Brazil' + author_email = 'kellyjonbrazil@gmail.com' + details = 'Parses wc and sum program output' + + # compatible options: linux, darwin, cygwin, win32, aix, freebsd + compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] + magic_commands = ['wc', 'sum'] + + +__version__ = info.version + + +def process(proc_data): + """ + Final processing to conform to the schema. + + Parameters: + + proc_data: (dictionary) raw structured data to process + + Returns: + + List of dictionaries. Structured data with the following schema: + + [ + { + "filename": string, + "lines": integer, + "words": integer, + "characters": integer + } + ] + """ + + for entry in proc_data: + int_list = ['lines', 'words', 'characters'] + for key in int_list: + if key in entry: + try: + entry[key] = int(entry[key]) + except (ValueError): + entry[key] = None + return proc_data + + +def parse(data, raw=False, quiet=False): + """ + Main text parsing function + + Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + + Returns: + + List of dictionaries. Raw or processed structured data. + """ + if not quiet: + jc.utils.compatibility(__name__, info.compatible) + + raw_output = [] + + if jc.utils.has_data(data): + + for line in filter(None, data.splitlines()): + split_line = line.split(maxsplit=3) + item = { + 'filename': split_line[3] if len(split_line) == 4 else None, + 'lines': split_line[0], + 'words': split_line[1], + 'characters': split_line[2] + } + raw_output.append(item) + + if raw: + return raw_output + else: + return process(raw_output) diff --git a/tests/fixtures/centos-7.7/wc.json b/tests/fixtures/centos-7.7/wc.json new file mode 100644 index 000000000..18b47cba0 --- /dev/null +++ b/tests/fixtures/centos-7.7/wc.json @@ -0,0 +1 @@ +[{"filename": "bin", "lines": 0, "words": 0, "characters": 0}, {"filename": "cksum.out", "lines": 59, "words": 182, "characters": 1943}, {"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm", "lines": 97735, "words": 543757, "characters": 24150660}, {"filename": "digout", "lines": 41, "words": 173, "characters": 1196}, {"filename": "dmidecode.out", "lines": 11810, "words": 38755, "characters": 277288}, {"filename": "Downloads", "lines": 0, "words": 0, "characters": 0}, {"filename": "ethtool.out", "lines": 24, "words": 77, "characters": 748}, {"filename": "file with spaces in the name", "lines": 0, "words": 0, "characters": 0}, {"filename": "git", "lines": 0, "words": 0, "characters": 0}, {"filename": "id-centos.out", "lines": 1, "words": 4, "characters": 129}, {"filename": "ifcfg.json", "lines": 1, "words": 164, "characters": 1600}, {"filename": "ifconfig.out", "lines": 26, "words": 157, "characters": 1278}, {"filename": "iptables-tests", "lines": 0, "words": 0, "characters": 0}, {"filename": "jc", "lines": 455649, "words": 1920906, "characters": 58764280}, {"filename": "jc-1.10.5-linux.sha256", "lines": 1, "words": 2, "characters": 69}, {"filename": "jc-1.10.5-linux.tar.gz", "lines": 80475, "words": 458331, "characters": 21978413}, {"filename": "jc-1.10.5.rpm", "lines": 80635, "words": 456923, "characters": 21716708}, {"filename": "jc-1.11.1-linux.sha256", "lines": 1, "words": 2, "characters": 69}, {"filename": "jc-1.11.1-linux.tar.gz", "lines": 74510, "words": 421533, "characters": 20226936}, {"filename": "jc-1.11.1.sha256", "lines": 1, "words": 2, "characters": 69}, {"filename": "jc-1.11.1.tar.gz", "lines": 73756, "words": 421486, "characters": 20225785}, {"filename": "jc-1.11.2-linux.sha256", "lines": 1, "words": 2, "characters": 69}, {"filename": "jc-1.11.2-linux.tar.gz", "lines": 73861, "words": 421614, "characters": 20231427}, {"filename": "jc-1.11.8-linux.sha256", "lines": 1, "words": 2, "characters": 69}, {"filename": "jc-1.11.8-linux.tar.gz", "lines": 74127, "words": 421977, "characters": 20241790}, {"filename": "jc-1.13.1-linux.sha256", "lines": 1, "words": 2, "characters": 69}, {"filename": "jc-1.13.1-linux.tar.gz", "lines": 74620, "words": 421848, "characters": 20268540}, {"filename": "jc-1.13.2-linux.sha256", "lines": 1, "words": 2, "characters": 69}, {"filename": "jc-1.13.2-linux.tar.gz", "lines": 74786, "words": 423881, "characters": 20263630}, {"filename": "jc-1.13.4-linux.sha256", "lines": 1, "words": 2, "characters": 69}, {"filename": "jc-1.13.4-linux.tar.gz", "lines": 74763, "words": 423408, "characters": 20264188}, {"filename": "jello-1.2.8-linux.sha256", "lines": 1, "words": 2, "characters": 72}, {"filename": "jello-1.2.8-linux.tar.gz", "lines": 72997, "words": 415356, "characters": 19899656}, {"filename": "jello-1.2.9-linux.sha256", "lines": 1, "words": 2, "characters": 72}, {"filename": "jello-1.2.9-linux.tar.gz", "lines": 73111, "words": 414558, "characters": 19901109}, {"filename": "journaljson", "lines": 6557, "words": 479675, "characters": 6014042}, {"filename": "jp", "lines": 19009, "words": 66861, "characters": 3426382}, {"filename": "jp_1.1.12_linux_x86_64.zip", "lines": 4154, "words": 24072, "characters": 1174326}, {"filename": "jq_twitter.json", "lines": 144, "words": 55888, "characters": 738160}, {"filename": "jtbl-1.1.6-linux.sha256", "lines": 1, "words": 2, "characters": 71}, {"filename": "jtbl-1.1.6-linux.tar.gz", "lines": 66057, "words": 377780, "characters": 18224334}, {"filename": "kbls.out", "lines": 58, "words": 520, "characters": 4152}, {"filename": "lastb.out", "lines": 5, "words": 35, "characters": 269}, {"filename": "lsblk-cols", "lines": 7, "words": 95, "characters": 1559}, {"filename": "ping-ip-O-D.out", "lines": 25, "words": 207, "characters": 1751}, {"filename": "ping-ip-O.out", "lines": 25, "words": 187, "characters": 1351}, {"filename": "psfile.txt", "lines": 104, "words": 912, "characters": 7786}, {"filename": "resizeterm.sh", "lines": 16, "words": 53, "characters": 355}, {"filename": "route-6-n.out", "lines": 23, "words": 159, "characters": 1802}, {"filename": "route-6.out", "lines": 23, "words": 159, "characters": 1814}, {"filename": "routeout", "lines": 41, "words": 74, "characters": 690}, {"filename": "sha384sum.out", "lines": 56, "words": 117, "characters": 6434}, {"filename": "shafile.txt", "lines": 56, "words": 117, "characters": 2850}, {"filename": "ss-aeep.out", "lines": 205, "words": 2004, "characters": 26724}, {"filename": "ssout", "lines": 205, "words": 1843, "characters": 20190}, {"filename": "sum.out", "lines": 58, "words": 179, "characters": 1668}, {"filename": "systemctl.out", "lines": 229, "words": 1609, "characters": 38746}, {"filename": "testfiles", "lines": 0, "words": 0, "characters": 0}, {"filename": "tmp", "lines": 0, "words": 0, "characters": 0}, {"filename": "top.out", "lines": 34, "words": 457, "characters": 5314}, {"filename": "tracepath6.out", "lines": 6, "words": 25, "characters": 252}, {"filename": "tracepath-cnn.out", "lines": 34, "words": 105, "characters": 939}, {"filename": "tr.out", "lines": 34, "words": 113, "characters": 1137}, {"filename": "who-aH.out", "lines": 6, "words": 36, "characters": 355}, {"filename": "who.out", "lines": 2, "words": 9, "characters": 93}, {"filename": "whotext", "lines": 5, "words": 28, "characters": 281}, {"filename": "total", "lines": 1490176, "words": 8218431, "characters": 338121827}] diff --git a/tests/fixtures/centos-7.7/wc.out b/tests/fixtures/centos-7.7/wc.out new file mode 100644 index 000000000..315588709 --- /dev/null +++ b/tests/fixtures/centos-7.7/wc.out @@ -0,0 +1,67 @@ + 0 0 0 bin + 59 182 1943 cksum.out + 97735 543757 24150660 devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm + 41 173 1196 digout + 11810 38755 277288 dmidecode.out + 0 0 0 Downloads + 24 77 748 ethtool.out + 0 0 0 file with spaces in the name + 0 0 0 git + 1 4 129 id-centos.out + 1 164 1600 ifcfg.json + 26 157 1278 ifconfig.out + 0 0 0 iptables-tests + 455649 1920906 58764280 jc + 1 2 69 jc-1.10.5-linux.sha256 + 80475 458331 21978413 jc-1.10.5-linux.tar.gz + 80635 456923 21716708 jc-1.10.5.rpm + 1 2 69 jc-1.11.1-linux.sha256 + 74510 421533 20226936 jc-1.11.1-linux.tar.gz + 1 2 69 jc-1.11.1.sha256 + 73756 421486 20225785 jc-1.11.1.tar.gz + 1 2 69 jc-1.11.2-linux.sha256 + 73861 421614 20231427 jc-1.11.2-linux.tar.gz + 1 2 69 jc-1.11.8-linux.sha256 + 74127 421977 20241790 jc-1.11.8-linux.tar.gz + 1 2 69 jc-1.13.1-linux.sha256 + 74620 421848 20268540 jc-1.13.1-linux.tar.gz + 1 2 69 jc-1.13.2-linux.sha256 + 74786 423881 20263630 jc-1.13.2-linux.tar.gz + 1 2 69 jc-1.13.4-linux.sha256 + 74763 423408 20264188 jc-1.13.4-linux.tar.gz + 1 2 72 jello-1.2.8-linux.sha256 + 72997 415356 19899656 jello-1.2.8-linux.tar.gz + 1 2 72 jello-1.2.9-linux.sha256 + 73111 414558 19901109 jello-1.2.9-linux.tar.gz + 6557 479675 6014042 journaljson + 19009 66861 3426382 jp + 4154 24072 1174326 jp_1.1.12_linux_x86_64.zip + 144 55888 738160 jq_twitter.json + 1 2 71 jtbl-1.1.6-linux.sha256 + 66057 377780 18224334 jtbl-1.1.6-linux.tar.gz + 58 520 4152 kbls.out + 5 35 269 lastb.out + 7 95 1559 lsblk-cols + 25 207 1751 ping-ip-O-D.out + 25 187 1351 ping-ip-O.out + 104 912 7786 psfile.txt + 16 53 355 resizeterm.sh + 23 159 1802 route-6-n.out + 23 159 1814 route-6.out + 41 74 690 routeout + 56 117 6434 sha384sum.out + 56 117 2850 shafile.txt + 205 2004 26724 ss-aeep.out + 205 1843 20190 ssout + 58 179 1668 sum.out + 229 1609 38746 systemctl.out + 0 0 0 testfiles + 0 0 0 tmp + 34 457 5314 top.out + 6 25 252 tracepath6.out + 34 105 939 tracepath-cnn.out + 34 113 1137 tr.out + 6 36 355 who-aH.out + 2 9 93 who.out + 5 28 281 whotext + 1490176 8218431 338121827 total diff --git a/tests/fixtures/osx-10.14.6/wc.json b/tests/fixtures/osx-10.14.6/wc.json new file mode 100644 index 000000000..bf544e853 --- /dev/null +++ b/tests/fixtures/osx-10.14.6/wc.json @@ -0,0 +1 @@ +[{"filename": "airport-I.json", "lines": 1, "words": 30, "characters": 307}, {"filename": "airport-I.out", "lines": 15, "words": 33, "characters": 348}, {"filename": "airport-s.json", "lines": 1, "words": 202, "characters": 2152}, {"filename": "airport-s.out", "lines": 15, "words": 112, "characters": 1423}, {"filename": "arp-a.json", "lines": 98, "words": 170, "characters": 2140}, {"filename": "arp-a.out", "lines": 12, "words": 99, "characters": 968}, {"filename": "arp-a2.json", "lines": 1, "words": 240, "characters": 2979}, {"filename": "arp-a2.out", "lines": 20, "words": 162, "characters": 1597}, {"filename": "cksum.json", "lines": 1, "words": 870, "characters": 10244}, {"filename": "cksum.out", "lines": 145, "words": 435, "characters": 4298}, {"filename": "df-h.json", "lines": 1, "words": 147, "characters": 1686}, {"filename": "df-h.out", "lines": 9, "words": 85, "characters": 1276}, {"filename": "df.json", "lines": 1, "words": 147, "characters": 1764}, {"filename": "df.out", "lines": 9, "words": 85, "characters": 1384}, {"filename": "dig-aaaa.json", "lines": 1, "words": 49, "characters": 438}, {"filename": "dig-aaaa.out", "lines": 20, "words": 80, "characters": 536}, {"filename": "dig-axfr.json", "lines": 1, "words": 585, "characters": 5984}, {"filename": "dig-axfr.out", "lines": 59, "words": 382, "characters": 3511}, {"filename": "dig-x.json", "lines": 1, "words": 49, "characters": 442}, {"filename": "dig-x.out", "lines": 20, "words": 80, "characters": 529}, {"filename": "dig.json", "lines": 1, "words": 138, "characters": 1266}, {"filename": "dig.out", "lines": 41, "words": 169, "characters": 1182}, {"filename": "du.json", "lines": 1, "words": 13448, "characters": 295780}, {"filename": "du.out", "lines": 3357, "words": 6734, "characters": 221925}, {"filename": "file.json", "lines": 1, "words": 370, "characters": 3589}, {"filename": "file.out", "lines": 53, "words": 264, "characters": 2890}, {"filename": "file2.json", "lines": 1, "words": 458, "characters": 4715}, {"filename": "file2.out", "lines": 88, "words": 282, "characters": 4780}, {"filename": "group.json", "lines": 1, "words": 1015, "characters": 9646}, {"filename": "group.out", "lines": 135, "words": 174, "characters": 2823}, {"filename": "id.json", "lines": 1, "words": 79, "characters": 759}, {"filename": "id.out", "lines": 1, "words": 3, "characters": 386}, {"filename": "ifconfig.json", "lines": 1, "words": 1107, "characters": 10823}, {"filename": "ifconfig.out", "lines": 91, "words": 331, "characters": 3779}, {"filename": "ifconfig2.json", "lines": 1, "words": 1162, "characters": 11375}, {"filename": "ifconfig2.out", "lines": 95, "words": 349, "characters": 3979}, {"filename": "last.json", "lines": 1, "words": 5483, "characters": 45274}, {"filename": "last.out", "lines": 383, "words": 3261, "characters": 25827}, {"filename": "ls-R-newlines.json", "lines": 1, "words": 88, "characters": 852}, {"filename": "ls-R-newlines.out", "lines": 36, "words": 43, "characters": 278}, {"filename": "ls-R.json", "lines": 1, "words": 18354, "characters": 469418}, {"filename": "ls-R.out", "lines": 5017, "words": 4805, "characters": 133787}, {"filename": "ls-al.json", "lines": 1, "words": 550, "characters": 4653}, {"filename": "ls-al.out", "lines": 35, "words": 314, "characters": 2111}, {"filename": "ls-alR.json", "lines": 1, "words": 82256, "characters": 959674}, {"filename": "ls-alR.out", "lines": 4996, "words": 41842, "characters": 364578}, {"filename": "ls-alh.json", "lines": 1, "words": 550, "characters": 4684}, {"filename": "ls-alh.out", "lines": 35, "words": 314, "characters": 2111}, {"filename": "ls-glob.json", "lines": 1, "words": 7272, "characters": 91544}, {"filename": "ls-glob.out", "lines": 1831, "words": 1825, "characters": 19369}, {"filename": "ls-l-newlines.json", "lines": 1, "words": 138, "characters": 1162}, {"filename": "ls-l-newlines.out", "lines": 34, "words": 99, "characters": 583}, {"filename": "ls-lR-empty-folder.json", "lines": 1, "words": 34164, "characters": 355547}, {"filename": "ls-lR-empty-folder.out", "lines": 2453, "words": 17640, "characters": 128740}, {"filename": "ls-lR-newlines.json", "lines": 1, "words": 168, "characters": 1450}, {"filename": "ls-lR-newlines.out", "lines": 38, "words": 111, "characters": 656}, {"filename": "ls-newlines.json", "lines": 1, "words": 56, "characters": 498}, {"filename": "ls-newlines.out", "lines": 33, "words": 41, "characters": 260}, {"filename": "ls.json", "lines": 1, "words": 46, "characters": 585}, {"filename": "ls.out", "lines": 23, "words": 23, "characters": 193}, {"filename": "md5.json", "lines": 1, "words": 416, "characters": 7764}, {"filename": "md5.out", "lines": 104, "words": 416, "characters": 5683}, {"filename": "mount.json", "lines": 1, "words": 55, "characters": 672}, {"filename": "mount.out", "lines": 6, "words": 43, "characters": 349}, {"filename": "mount2.json", "lines": 1, "words": 66, "characters": 841}, {"filename": "mount2.out", "lines": 7, "words": 52, "characters": 464}, {"filename": "netstat-Abn.json", "lines": 1, "words": 15133, "characters": 151042}, {"filename": "netstat-Abn.out", "lines": 689, "words": 5961, "characters": 76835}, {"filename": "netstat-An.json", "lines": 1, "words": 14085, "characters": 142438}, {"filename": "netstat-An.out", "lines": 689, "words": 5431, "characters": 71005}, {"filename": "netstat-i.json", "lines": 1, "words": 840, "characters": 7246}, {"filename": "netstat-i.out", "lines": 43, "words": 376, "characters": 3354}, {"filename": "netstat-r.json", "lines": 1, "words": 1456, "characters": 16929}, {"filename": "netstat-r.out", "lines": 93, "words": 435, "characters": 6178}, {"filename": "netstat-rnl.json", "lines": 1, "words": 1940, "characters": 21015}, {"filename": "netstat-rnl.out", "lines": 96, "words": 667, "characters": 10055}, {"filename": "netstat.json", "lines": 1, "words": 14100, "characters": 141195}, {"filename": "netstat.out", "lines": 737, "words": 5316, "characters": 70387}, {"filename": "passwd.json", "lines": 1, "words": 1517, "characters": 14855}, {"filename": "passwd.out", "lines": 108, "words": 292, "characters": 6804}, {"filename": "ping-hostname-p.json", "lines": 1, "words": 67, "characters": 714}, {"filename": "ping-hostname-p.out", "lines": 9, "words": 51, "characters": 400}, {"filename": "ping-hostname-s.json", "lines": 1, "words": 67, "characters": 714}, {"filename": "ping-hostname-s.out", "lines": 8, "words": 49, "characters": 389}, {"filename": "ping-hostname.json", "lines": 1, "words": 67, "characters": 706}, {"filename": "ping-hostname.out", "lines": 8, "words": 49, "characters": 381}, {"filename": "ping-ip-dup.json", "lines": 1, "words": 235, "characters": 2251}, {"filename": "ping-ip-dup.out", "lines": 20, "words": 147, "characters": 1156}, {"filename": "ping-ip-p.json", "lines": 1, "words": 67, "characters": 691}, {"filename": "ping-ip-p.out", "lines": 9, "words": 51, "characters": 381}, {"filename": "ping-ip-s.json", "lines": 1, "words": 67, "characters": 699}, {"filename": "ping-ip-s.out", "lines": 8, "words": 49, "characters": 375}, {"filename": "ping-ip.json", "lines": 1, "words": 67, "characters": 689}, {"filename": "ping-ip.out", "lines": 8, "words": 49, "characters": 367}, {"filename": "ping6-hostname-p.json", "lines": 1, "words": 69, "characters": 786}, {"filename": "ping6-hostname-p.out", "lines": 9, "words": 50, "characters": 460}, {"filename": "ping6-hostname-s.json", "lines": 1, "words": 69, "characters": 788}, {"filename": "ping6-hostname-s.out", "lines": 8, "words": 48, "characters": 449}, {"filename": "ping6-hostname.json", "lines": 1, "words": 69, "characters": 784}, {"filename": "ping6-hostname.out", "lines": 8, "words": 48, "characters": 446}, {"filename": "ping6-ip-dup.json", "lines": 1, "words": 909, "characters": 9447}, {"filename": "ping6-ip-dup.out", "lines": 68, "words": 530, "characters": 5225}, {"filename": "ping6-ip-p.json", "lines": 1, "words": 69, "characters": 683}, {"filename": "ping6-ip-p.out", "lines": 9, "words": 50, "characters": 355}, {"filename": "ping6-ip-s.json", "lines": 1, "words": 69, "characters": 688}, {"filename": "ping6-ip-s.out", "lines": 8, "words": 48, "characters": 352}, {"filename": "ping6-ip.json", "lines": 1, "words": 69, "characters": 681}, {"filename": "ping6-ip.out", "lines": 8, "words": 48, "characters": 341}, {"filename": "pip-list.json", "lines": 1, "words": 20, "characters": 224}, {"filename": "pip-list.out", "lines": 7, "words": 14, "characters": 168}, {"filename": "pip-show.json", "lines": 1, "words": 84, "characters": 1067}, {"filename": "pip-show.out", "lines": 32, "words": 82, "characters": 910}, {"filename": "ps-axu.json", "lines": 1, "words": 8641, "characters": 99173}, {"filename": "ps-axu.out", "lines": 378, "words": 4505, "characters": 60107}, {"filename": "ps-ef.json", "lines": 1, "words": 6379, "characters": 71162}, {"filename": "ps-ef.out", "lines": 378, "words": 3371, "characters": 48758}, {"filename": "shasum.json", "lines": 1, "words": 568, "characters": 11817}, {"filename": "shasum.out", "lines": 142, "words": 284, "characters": 7982}, {"filename": "stat.json", "lines": 1, "words": 4136, "characters": 35152}, {"filename": "stat.out", "lines": 94, "words": 2632, "characters": 15599}, {"filename": "sum.json", "lines": 1, "words": 876, "characters": 9234}, {"filename": "sum.out", "lines": 146, "words": 438, "characters": 3247}, {"filename": "sysctl-a.json", "lines": 1, "words": 2793, "characters": 46473}, {"filename": "sysctl-a.out", "lines": 1287, "words": 2785, "characters": 42505}, {"filename": "traceroute-asn.json", "lines": 1, "words": 108, "characters": 1123}, {"filename": "traceroute-asn.out", "lines": 5, "words": 44, "characters": 323}, {"filename": "traceroute-mult-addresses.json", "lines": 1, "words": 75, "characters": 807}, {"filename": "traceroute-mult-addresses.out", "lines": 4, "words": 39, "characters": 305}, {"filename": "traceroute-no-header.json", "lines": 1, "words": 75, "characters": 793}, {"filename": "traceroute-no-header.out", "lines": 3, "words": 22, "characters": 166}, {"filename": "traceroute-q.json", "lines": 1, "words": 115, "characters": 1240}, {"filename": "traceroute-q.out", "lines": 4, "words": 42, "characters": 272}, {"filename": "traceroute.json", "lines": 1, "words": 244, "characters": 2419}, {"filename": "traceroute.out", "lines": 11, "words": 81, "characters": 579}, {"filename": "traceroute6-mult-addresses.json", "lines": 1, "words": 83, "characters": 859}, {"filename": "traceroute6-mult-addresses.out", "lines": 8, "words": 48, "characters": 401}, {"filename": "traceroute6.json", "lines": 1, "words": 83, "characters": 859}, {"filename": "traceroute6.out", "lines": 7, "words": 40, "characters": 304}, {"filename": "uname-a.json", "lines": 1, "words": 20, "characters": 221}, {"filename": "uname-a.out", "lines": 1, "words": 15, "characters": 131}, {"filename": "uname.out", "lines": 1, "words": 1, "characters": 7}, {"filename": "uptime.json", "lines": 1, "words": 14, "characters": 110}, {"filename": "uptime.out", "lines": 1, "words": 12, "characters": 65}, {"filename": "w.json", "lines": 1, "words": 99, "characters": 836}, {"filename": "w.out", "lines": 10, "words": 69, "characters": 570}, {"filename": "who-a.json", "lines": 1, "words": 86, "characters": 659}, {"filename": "who-a.out", "lines": 9, "words": 62, "characters": 419}, {"filename": "who.json", "lines": 1, "words": 32, "characters": 251}, {"filename": "who.out", "lines": 4, "words": 20, "characters": 128}, {"filename": "total", "lines": 24562, "words": 360529, "characters": 4491471}] diff --git a/tests/fixtures/osx-10.14.6/wc.out b/tests/fixtures/osx-10.14.6/wc.out new file mode 100644 index 000000000..ab19eeec0 --- /dev/null +++ b/tests/fixtures/osx-10.14.6/wc.out @@ -0,0 +1,150 @@ + 1 30 307 airport-I.json + 15 33 348 airport-I.out + 1 202 2152 airport-s.json + 15 112 1423 airport-s.out + 98 170 2140 arp-a.json + 12 99 968 arp-a.out + 1 240 2979 arp-a2.json + 20 162 1597 arp-a2.out + 1 870 10244 cksum.json + 145 435 4298 cksum.out + 1 147 1686 df-h.json + 9 85 1276 df-h.out + 1 147 1764 df.json + 9 85 1384 df.out + 1 49 438 dig-aaaa.json + 20 80 536 dig-aaaa.out + 1 585 5984 dig-axfr.json + 59 382 3511 dig-axfr.out + 1 49 442 dig-x.json + 20 80 529 dig-x.out + 1 138 1266 dig.json + 41 169 1182 dig.out + 1 13448 295780 du.json + 3357 6734 221925 du.out + 1 370 3589 file.json + 53 264 2890 file.out + 1 458 4715 file2.json + 88 282 4780 file2.out + 1 1015 9646 group.json + 135 174 2823 group.out + 1 79 759 id.json + 1 3 386 id.out + 1 1107 10823 ifconfig.json + 91 331 3779 ifconfig.out + 1 1162 11375 ifconfig2.json + 95 349 3979 ifconfig2.out + 1 5483 45274 last.json + 383 3261 25827 last.out + 1 88 852 ls-R-newlines.json + 36 43 278 ls-R-newlines.out + 1 18354 469418 ls-R.json + 5017 4805 133787 ls-R.out + 1 550 4653 ls-al.json + 35 314 2111 ls-al.out + 1 82256 959674 ls-alR.json + 4996 41842 364578 ls-alR.out + 1 550 4684 ls-alh.json + 35 314 2111 ls-alh.out + 1 7272 91544 ls-glob.json + 1831 1825 19369 ls-glob.out + 1 138 1162 ls-l-newlines.json + 34 99 583 ls-l-newlines.out + 1 34164 355547 ls-lR-empty-folder.json + 2453 17640 128740 ls-lR-empty-folder.out + 1 168 1450 ls-lR-newlines.json + 38 111 656 ls-lR-newlines.out + 1 56 498 ls-newlines.json + 33 41 260 ls-newlines.out + 1 46 585 ls.json + 23 23 193 ls.out + 1 416 7764 md5.json + 104 416 5683 md5.out + 1 55 672 mount.json + 6 43 349 mount.out + 1 66 841 mount2.json + 7 52 464 mount2.out + 1 15133 151042 netstat-Abn.json + 689 5961 76835 netstat-Abn.out + 1 14085 142438 netstat-An.json + 689 5431 71005 netstat-An.out + 1 840 7246 netstat-i.json + 43 376 3354 netstat-i.out + 1 1456 16929 netstat-r.json + 93 435 6178 netstat-r.out + 1 1940 21015 netstat-rnl.json + 96 667 10055 netstat-rnl.out + 1 14100 141195 netstat.json + 737 5316 70387 netstat.out + 1 1517 14855 passwd.json + 108 292 6804 passwd.out + 1 67 714 ping-hostname-p.json + 9 51 400 ping-hostname-p.out + 1 67 714 ping-hostname-s.json + 8 49 389 ping-hostname-s.out + 1 67 706 ping-hostname.json + 8 49 381 ping-hostname.out + 1 235 2251 ping-ip-dup.json + 20 147 1156 ping-ip-dup.out + 1 67 691 ping-ip-p.json + 9 51 381 ping-ip-p.out + 1 67 699 ping-ip-s.json + 8 49 375 ping-ip-s.out + 1 67 689 ping-ip.json + 8 49 367 ping-ip.out + 1 69 786 ping6-hostname-p.json + 9 50 460 ping6-hostname-p.out + 1 69 788 ping6-hostname-s.json + 8 48 449 ping6-hostname-s.out + 1 69 784 ping6-hostname.json + 8 48 446 ping6-hostname.out + 1 909 9447 ping6-ip-dup.json + 68 530 5225 ping6-ip-dup.out + 1 69 683 ping6-ip-p.json + 9 50 355 ping6-ip-p.out + 1 69 688 ping6-ip-s.json + 8 48 352 ping6-ip-s.out + 1 69 681 ping6-ip.json + 8 48 341 ping6-ip.out + 1 20 224 pip-list.json + 7 14 168 pip-list.out + 1 84 1067 pip-show.json + 32 82 910 pip-show.out + 1 8641 99173 ps-axu.json + 378 4505 60107 ps-axu.out + 1 6379 71162 ps-ef.json + 378 3371 48758 ps-ef.out + 1 568 11817 shasum.json + 142 284 7982 shasum.out + 1 4136 35152 stat.json + 94 2632 15599 stat.out + 1 876 9234 sum.json + 146 438 3247 sum.out + 1 2793 46473 sysctl-a.json + 1287 2785 42505 sysctl-a.out + 1 108 1123 traceroute-asn.json + 5 44 323 traceroute-asn.out + 1 75 807 traceroute-mult-addresses.json + 4 39 305 traceroute-mult-addresses.out + 1 75 793 traceroute-no-header.json + 3 22 166 traceroute-no-header.out + 1 115 1240 traceroute-q.json + 4 42 272 traceroute-q.out + 1 244 2419 traceroute.json + 11 81 579 traceroute.out + 1 83 859 traceroute6-mult-addresses.json + 8 48 401 traceroute6-mult-addresses.out + 1 83 859 traceroute6.json + 7 40 304 traceroute6.out + 1 20 221 uname-a.json + 1 15 131 uname-a.out + 1 1 7 uname.out + 1 14 110 uptime.json + 1 12 65 uptime.out + 1 99 836 w.json + 10 69 570 w.out + 1 86 659 who-a.json + 9 62 419 who-a.out + 1 32 251 who.json + 4 20 128 who.out + 24562 360529 4491471 total From 1f547edd361e66b19ccbcb59f6ba0ae78f6080ce Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 31 Dec 2020 14:10:56 -0800 Subject: [PATCH 18/24] add printenv to env docs --- docs/parsers/env.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/parsers/env.md b/docs/parsers/env.md index 04b998a8c..eb70a4bd8 100644 --- a/docs/parsers/env.md +++ b/docs/parsers/env.md @@ -1,6 +1,6 @@ # jc.parsers.env -jc - JSON CLI output utility `env` command output parser +jc - JSON CLI output utility `env` and `printenv` command output parser This parser will output a list of dictionaries each containing `name` and `value` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function. From bd443bf39227515ae5f8df65d07b30268dcc90a9 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 31 Dec 2020 14:11:25 -0800 Subject: [PATCH 19/24] add printenv to env docs --- jc/parsers/env.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jc/parsers/env.py b/jc/parsers/env.py index bcfb176dc..3bac5f2af 100644 --- a/jc/parsers/env.py +++ b/jc/parsers/env.py @@ -1,4 +1,4 @@ -"""jc - JSON CLI output utility `env` command output parser +"""jc - JSON CLI output utility `env` and `printenv` command output parser This parser will output a list of dictionaries each containing `name` and `value` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function. @@ -70,7 +70,7 @@ class info(): # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'] - magic_commands = ['env'] + magic_commands = ['env', 'printenv'] __version__ = info.version From cb0221142455a6bcb904fbe9ade657be45815b63 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 31 Dec 2020 14:19:45 -0800 Subject: [PATCH 20/24] add wc tests --- jc/parsers/wc.py | 3 +- tests/fixtures/osx-10.14.6/wc-stdin.json | 1 + tests/fixtures/osx-10.14.6/wc-stdin.out | 1 + tests/test_wc.py | 58 ++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/osx-10.14.6/wc-stdin.json create mode 100644 tests/fixtures/osx-10.14.6/wc-stdin.out create mode 100644 tests/test_wc.py diff --git a/jc/parsers/wc.py b/jc/parsers/wc.py index bb3237782..a5d4e39aa 100644 --- a/jc/parsers/wc.py +++ b/jc/parsers/wc.py @@ -50,11 +50,10 @@ class info(): description = 'wc command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' - details = 'Parses wc and sum program output' # compatible options: linux, darwin, cygwin, win32, aix, freebsd compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] - magic_commands = ['wc', 'sum'] + magic_commands = ['wc'] __version__ = info.version diff --git a/tests/fixtures/osx-10.14.6/wc-stdin.json b/tests/fixtures/osx-10.14.6/wc-stdin.json new file mode 100644 index 000000000..896a67a3a --- /dev/null +++ b/tests/fixtures/osx-10.14.6/wc-stdin.json @@ -0,0 +1 @@ +[{"filename": null, "lines": 1, "words": 2, "characters": 12}] diff --git a/tests/fixtures/osx-10.14.6/wc-stdin.out b/tests/fixtures/osx-10.14.6/wc-stdin.out new file mode 100644 index 000000000..6367ec193 --- /dev/null +++ b/tests/fixtures/osx-10.14.6/wc-stdin.out @@ -0,0 +1 @@ + 1 2 12 diff --git a/tests/test_wc.py b/tests/test_wc.py new file mode 100644 index 000000000..d9554cda3 --- /dev/null +++ b/tests/test_wc.py @@ -0,0 +1,58 @@ +import os +import unittest +import json +import jc.parsers.wc + +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + + +class MyTests(unittest.TestCase): + + def setUp(self): + # input + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/wc.out'), 'r', encoding='utf-8') as f: + self.centos_7_7_wc = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/wc.out'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_wc = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/wc-stdin.out'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_wc_stdin = f.read() + + # output + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/wc.json'), 'r', encoding='utf-8') as f: + self.centos_7_7_wc_json = json.loads(f.read()) + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/wc.json'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_wc_json = json.loads(f.read()) + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/wc-stdin.json'), 'r', encoding='utf-8') as f: + self.osx_10_14_6_wc_stdin_json = json.loads(f.read()) + + def test_wc_nodata(self): + """ + Test 'wc' parser with no data + """ + self.assertEqual(jc.parsers.wc.parse('', quiet=True), []) + + def test_wc_centos_7_7(self): + """ + Test 'wc' on Centos 7.7 + """ + self.assertEqual(jc.parsers.wc.parse(self.centos_7_7_wc, quiet=True), self.centos_7_7_wc_json) + + def test_wc_osx_10_14_6(self): + """ + Test 'wc' on OSX 10.14.6 + """ + self.assertEqual(jc.parsers.wc.parse(self.osx_10_14_6_wc, quiet=True), self.osx_10_14_6_wc_json) + + def test_wc_stdin_osx_10_14_6(self): + """ + Test 'wc' from STDIN on OSX 10.14.6 + """ + self.assertEqual(jc.parsers.wc.parse(self.osx_10_14_6_wc_stdin, quiet=True), self.osx_10_14_6_wc_stdin_json) + + +if __name__ == '__main__': + unittest.main() From a7b0e936e400d2f9e55629e2d722cc002e035e9f Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 31 Dec 2020 14:21:24 -0800 Subject: [PATCH 21/24] add vdir and printenv info --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 28ef0cebc..d81e9b8c3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,8 @@ jc changelog - Add hash parser tested on linux, macos - Add cksum parser tested on linux, macos - Add wc parser tested on linux, macos +- Add printenv support under env parser +- add vdir support under ls parser - Add python 3.9 to github automation tests 20200805 v1.13.4 From 5986ce03db6fcd1aa0f7b064eaa96c2120c06d2d Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 31 Dec 2020 16:36:27 -0800 Subject: [PATCH 22/24] add printenv info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7aea5adf6..288d85a5f 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio - `--dig` enables the `dig` command parser - `--dmidecode` enables the `dmidecode` command parser - `--du` enables the `du` command parser -- `--env` enables the `env` command parser +- `--env` enables the `env` and `printenv` command parser - `--file` enables the `file` command parser - `--free` enables the `free` command parser - `--fstab` enables the `/etc/fstab` file parser From 8b9c932f9b05295e63b3e7d0073f243458fd4dd9 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 31 Dec 2020 16:37:14 -0800 Subject: [PATCH 23/24] update date --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d81e9b8c3..b50e0cdaa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ jc changelog -20201229 v1.14.0 +20201231 v1.14.0 - Add hashsum parser tested on linux, macos - Add hash parser tested on linux, macos - Add cksum parser tested on linux, macos From b12217466e906829d19be4cfd80dfe7cf4008e57 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 31 Dec 2020 16:37:47 -0800 Subject: [PATCH 24/24] spelling --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index b50e0cdaa..024cc591a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,7 +6,7 @@ jc changelog - Add cksum parser tested on linux, macos - Add wc parser tested on linux, macos - Add printenv support under env parser -- add vdir support under ls parser +- Add vdir support under ls parser - Add python 3.9 to github automation tests 20200805 v1.13.4