From d8264d9c29711b0f07c8751019eb97b9f16c0a1d Mon Sep 17 00:00:00 2001 From: Jarry Shaw Date: Thu, 8 Aug 2019 21:01:18 +0800 Subject: [PATCH] New distribution [0.14.3] * bugfix for pull#30 * bugfix for issue#29 * updated Pipfile * updated sample output * updated Makefile * update const files * fix wikipefia block issue --- .gitignore | 5 - .vscode/settings.json | 20 + Makefile | 36 +- Pipfile | 12 +- Pipfile.lock | 471 ++++++++++++++++++ {docker => archive/docker}/.dockerignore | 0 {docker => archive/docker}/Dockerfile | 2 +- {docker => archive/docker}/docker-compose.yml | 0 {docker => archive/docker}/docker.sh | 0 release | 2 +- sample/out.json | 18 +- sample/out.plist | 18 +- sample/out.txt | 18 +- setup.py | 3 +- src/__init__.py | 9 +- src/const/http/setting.py | 4 +- src/const/ipv6/option.py | 3 +- src/const/misc/linktype.py | 5 + src/const/tcp/option.py | 4 +- src/utilities/validations.py | 196 ++++---- src/vendor/ftp/return_code.py | 27 +- src/vendor/ipx/packet.py | 23 +- src/vendor/ipx/socket.py | 23 +- src/vendor/vlan/priority_level.py | 22 +- 24 files changed, 728 insertions(+), 193 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 Pipfile.lock rename {docker => archive/docker}/.dockerignore (100%) rename {docker => archive/docker}/Dockerfile (98%) rename {docker => archive/docker}/docker-compose.yml (100%) rename {docker => archive/docker}/docker.sh (100%) diff --git a/.gitignore b/.gitignore index 2c9242f4e..17631030e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,4 @@ -.vscode/ - -*.icloud -Pipfile.lock - out *.js !out.js diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..fb033e438 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,20 @@ +{ + "python.pythonPath": ".venv/bin/python", + "cSpell.words": [ + "INET", + "aktau", + "bufid", + "cmmt", + "distro", + "dscp", + "gaocegege", + "ipsuite", + "prio", + "pval", + "pyenv", + "srcport", + "sufs", + "tbitem", + "tbody" + ] +} \ No newline at end of file diff --git a/Makefile b/Makefile index a19123916..b15cd9316 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,6 @@ export PIPENV_VENV_IN_PROJECT=1 SHELL := /usr/local/bin/bash DIR ?= . -# fetch platform spec -platform = $(shell python3 -c "import distutils.util; print(distutils.util.get_platform().replace('-', '_').replace('.', '_'))") # get version string version = $(shell cat setup.py | grep "^__version__" | sed "s/__version__ = '\(.*\)'/\1/") # commit message @@ -78,36 +76,39 @@ update-maintainer: go run github.com/gaocegege/maintainer contributing # make PyPI distribution -dist-pypi: clean-pypi dist-pypi-new dist-pypi-old dist-linux +# dist-pypi: clean-pypi dist-pypi-new dist-pypi-old dist-linux +dist-pypi: clean-pypi dist-pypi-new dist-pypi-old # make Python >=3.6 distribution .ONESHELL: dist-pypi-new: set -ex cd $(DIR) - python3.7 setup.py bdist_egg bdist_wheel --plat-name="$(platform)" --python-tag='cp37' - python3.6 setup.py bdist_egg bdist_wheel --plat-name="$(platform)" --python-tag='cp36' + ~/.pyenv/versions/3.8-dev/bin/python3.8 setup.py bdist_egg bdist_wheel --python-tag='cp38' + ~/.pyenv/versions/3.7.4/bin/python3.7 setup.py bdist_egg bdist_wheel --python-tag='cp37' + ~/.pyenv/versions/3.6.9/bin/python3.6 setup.py bdist_egg bdist_wheel --python-tag='cp36' + ~/.pyenv/versions/pypy3.6-7.1.1/bin/pypy3 setup.py bdist_egg bdist_wheel --python-tag='pp36' # perform f2format dist-f2format: - f2format -n $(DIR)/pcapkit + pipenv run f2format -n $(DIR)/pcapkit # make Python <3.6 distribution .ONESHELL: dist-pypi-old: dist-f2format set -ex cd $(DIR) - python3.5 setup.py bdist_egg bdist_wheel --plat-name="$(platform)" --python-tag='cp35' - python3.4 setup.py bdist_egg bdist_wheel --plat-name="$(platform)" --python-tag='cp34' - pypy3 setup.py bdist_wheel --plat-name="$(platform)" --python-tag='pp35' - python3 setup.py sdist - -# make Linux distribution -.ONESHELL: -dist-linux: - set -ex - cd $(DIR)/docker - docker-compose up --build + ~/.pyenv/versions/3.5.7/bin/python3.5 setup.py bdist_egg bdist_wheel --python-tag='cp35' + ~/.pyenv/versions/3.4.10/bin/python3.4 setup.py bdist_egg bdist_wheel --python-tag='cp34' + ~/.pyenv/versions/pypy3.5-7.0.0/bin/pypy3 setup.py bdist_egg bdist_wheel --python-tag='pp35' + pipenv run python setup.py sdist + +# # make Linux distribution +# .ONESHELL: +# dist-linux: +# set -ex +# cd $(DIR)/docker +# docker-compose up --build # upload PyPI distribution .ONESHELL: @@ -164,6 +165,7 @@ git-aftermath: # file new release on master release-master: + $(eval message := $(shell git log -1 --pretty=%B)) go run github.com/aktau/github-release release \ --user JarryShaw \ --repo PyPCAPKit \ diff --git a/Pipfile b/Pipfile index 03d37e027..4bf0e46af 100644 --- a/Pipfile +++ b/Pipfile @@ -11,19 +11,17 @@ emoji = "*" tbtrim = ">=0.2.1" [dev-packages] -pcapkit = {editable = true, path = "."} +pypcapkit = {editable = true, path = "."} pyshark = "*" dpkt = "*" scapy = "*" -"beautifulsoup4" = "*" -"html5lib" = "*" +bs4 = "*" +html5lib = "*" requests = "*" ipython = "*" -rope = "*" -"autopep8" = "*" +autopep8 = "*" pylint = "*" -pycodestyle = "*" -isort = {extras = ["pipfile", "requirements"], version = "*"} +f2format = "*" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 000000000..7d1a0988d --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,471 @@ +{ + "_meta": { + "hash": { + "sha256": "3fa4db4f0b5ba86e042f24d6e57dc106bb531359a29e89eeb70c5978f9b6bd60" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.7" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "aenum": { + "hashes": [ + "sha256:0e3589654ef090784971f7778dcb74b08c9b4ef80b33267c00f82ddeedac179a", + "sha256:b12a7be3d89b270f266f8643aaa126404e5cdc0929bd6f09548b8eaed85e2aa1", + "sha256:e4dab068cbe00295bbc3660cd562221b008687d0f7a4c40fc2dd7a80002126a7" + ], + "index": "pypi", + "version": "==2.2.1" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "index": "pypi", + "version": "==3.0.4" + }, + "dictdumper": { + "hashes": [ + "sha256:1453b3dc017eecf177909d11e084a6c8eeb5bd980d6ddf78d44d4bf9ceb24f46", + "sha256:335e8bd44ce2b3a1e2132ad16745b75e16d86284b17925088129d0f8bf93e976", + "sha256:803eeb6fedf92812b97ff79cb0cae021e2316f1c7374da3cff68691dd2204620", + "sha256:8205854aaeb6c1a90adab51e24542ee5e824613c86594f34cd2fb6c843f62a60", + "sha256:8ce423d37f5204f0709ae025b5edc4a91d974aff6b710ed66605b3acd2a10955", + "sha256:a57e9edc720b6d99a4747aba3a1e01ace95236c43092d184d1355518912aee80", + "sha256:ac48e337fcab1e4934bbbbc09d98d93a037d4f12f0f29074a901a1fa00238c94", + "sha256:bffa44a460fa685fd2ef9433fe6ce02bf8009904ceefac8fdc0b846b378e1443", + "sha256:c0c76d9de181b768a53d3603b6f02e2536b979606bb035e6ef10580bbb11be39", + "sha256:c8c42d3540e75f533031dc29c32e0fd838982f2c024f92af0b400c83b2db66a2", + "sha256:d168a5f34823987b800811402f8b2c6a23074ba8677c393efb61e104b9e6d05a", + "sha256:dcfc9ea2917252f46150483814d6d2babb33412f6667f39b8881e1441156f3f0", + "sha256:dd7575db24e6f1a2b9278389df000a6db8fba4c45a92398c7e6d3e5fa575a3ab", + "sha256:ec79a036569c7867fd121132ffd65bb07c974f1d7cbc0c44105cd45a55f4509c", + "sha256:f028983cb749762c98f2c50a6463dcc74c9b5ad77ae9bbc3fbbc2d04f70e508f" + ], + "index": "pypi", + "version": "==0.7.0.post2" + }, + "emoji": { + "hashes": [ + "sha256:b68112d40482a05e5da5d53da33d0aba3cce96891282c9c179cc340003c6c64e" + ], + "index": "pypi", + "version": "==0.5.3" + }, + "tbtrim": { + "hashes": [ + "sha256:860839d7296298a8823b3a0ac49a7f29424819d1481b5521329d339eac062bb9", + "sha256:b0810edfb5dcf94c5fe3335a8a8e18ae38a411f6ff6afca188c66ac72444218f" + ], + "index": "pypi", + "version": "==0.2.1" + } + }, + "develop": { + "aenum": { + "hashes": [ + "sha256:0e3589654ef090784971f7778dcb74b08c9b4ef80b33267c00f82ddeedac179a", + "sha256:b12a7be3d89b270f266f8643aaa126404e5cdc0929bd6f09548b8eaed85e2aa1", + "sha256:e4dab068cbe00295bbc3660cd562221b008687d0f7a4c40fc2dd7a80002126a7" + ], + "index": "pypi", + "version": "==2.2.1" + }, + "appnope": { + "hashes": [ + "sha256:5b26757dc6f79a3b7dc9fab95359328d5747fcb2409d331ea66d0272b90ab2a0", + "sha256:8b995ffe925347a2138d7ac0fe77155e4311a0ea6d6da4f5128fe4b3cbe5ed71" + ], + "markers": "sys_platform == 'darwin'", + "version": "==0.1.0" + }, + "astroid": { + "hashes": [ + "sha256:6560e1e1749f68c64a4b5dee4e091fce798d2f0d84ebe638cf0e0585a343acf4", + "sha256:b65db1bbaac9f9f4d190199bb8680af6f6f84fd3769a5ea883df8a91fe68b4c4" + ], + "version": "==2.2.5" + }, + "autopep8": { + "hashes": [ + "sha256:4d8eec30cc81bc5617dbf1218201d770dc35629363547f17577c61683ccfb3ee" + ], + "index": "pypi", + "version": "==1.4.4" + }, + "backcall": { + "hashes": [ + "sha256:38ecd85be2c1e78f77fd91700c76e14667dc21e2713b63876c0eb901196e01e4", + "sha256:bbbf4b1e5cd2bdb08f915895b51081c041bac22394fdfcfdfbe9f14b77c08bf2" + ], + "version": "==0.1.0" + }, + "beautifulsoup4": { + "hashes": [ + "sha256:05668158c7b85b791c5abde53e50265e16f98ad601c402ba44d70f96c4159612", + "sha256:25288c9e176f354bf277c0a10aa96c782a6a18a17122dba2e8cec4a97e03343b", + "sha256:f040590be10520f2ea4c2ae8c3dae441c7cfff5308ec9d58a0ec0c1b8f81d469" + ], + "version": "==4.8.0" + }, + "bs4": { + "hashes": [ + "sha256:36ecea1fd7cc5c0c6e4a1ff075df26d50da647b75376626cc186e2212886dd3a" + ], + "index": "pypi", + "version": "==0.0.1" + }, + "certifi": { + "hashes": [ + "sha256:046832c04d4e752f37383b628bc601a7ea7211496b4638f6514d0e5b9acc4939", + "sha256:945e3ba63a0b9f577b1395204e13c3a231f9bc0223888be653286534e5873695" + ], + "version": "==2019.6.16" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "index": "pypi", + "version": "==3.0.4" + }, + "decorator": { + "hashes": [ + "sha256:86156361c50488b84a3f148056ea716ca587df2f0de1d34750d35c21312725de", + "sha256:f069f3a01830ca754ba5258fde2278454a0b5b79e0d7f5c13b3b97e57d4acff6" + ], + "version": "==4.4.0" + }, + "dictdumper": { + "hashes": [ + "sha256:1453b3dc017eecf177909d11e084a6c8eeb5bd980d6ddf78d44d4bf9ceb24f46", + "sha256:335e8bd44ce2b3a1e2132ad16745b75e16d86284b17925088129d0f8bf93e976", + "sha256:803eeb6fedf92812b97ff79cb0cae021e2316f1c7374da3cff68691dd2204620", + "sha256:8205854aaeb6c1a90adab51e24542ee5e824613c86594f34cd2fb6c843f62a60", + "sha256:8ce423d37f5204f0709ae025b5edc4a91d974aff6b710ed66605b3acd2a10955", + "sha256:a57e9edc720b6d99a4747aba3a1e01ace95236c43092d184d1355518912aee80", + "sha256:ac48e337fcab1e4934bbbbc09d98d93a037d4f12f0f29074a901a1fa00238c94", + "sha256:bffa44a460fa685fd2ef9433fe6ce02bf8009904ceefac8fdc0b846b378e1443", + "sha256:c0c76d9de181b768a53d3603b6f02e2536b979606bb035e6ef10580bbb11be39", + "sha256:c8c42d3540e75f533031dc29c32e0fd838982f2c024f92af0b400c83b2db66a2", + "sha256:d168a5f34823987b800811402f8b2c6a23074ba8677c393efb61e104b9e6d05a", + "sha256:dcfc9ea2917252f46150483814d6d2babb33412f6667f39b8881e1441156f3f0", + "sha256:dd7575db24e6f1a2b9278389df000a6db8fba4c45a92398c7e6d3e5fa575a3ab", + "sha256:ec79a036569c7867fd121132ffd65bb07c974f1d7cbc0c44105cd45a55f4509c", + "sha256:f028983cb749762c98f2c50a6463dcc74c9b5ad77ae9bbc3fbbc2d04f70e508f" + ], + "index": "pypi", + "version": "==0.7.0.post2" + }, + "dpkt": { + "hashes": [ + "sha256:472c8fbf992f913cee2760fed8fb4253a600d7fb2210c793e2c0c0c23eb3b629", + "sha256:52a92ecd5ca04d5bd852bb11cb2eac4bbe38b42a7c472e0d950eeb9f82a81e54" + ], + "index": "pypi", + "version": "==1.9.2" + }, + "emoji": { + "hashes": [ + "sha256:b68112d40482a05e5da5d53da33d0aba3cce96891282c9c179cc340003c6c64e" + ], + "index": "pypi", + "version": "==0.5.3" + }, + "f2format": { + "hashes": [ + "sha256:d0ae4ca7d68e9863bd3e705f6ef80604b4aab7c12524dd99adbb5994917d1cb1", + "sha256:e11951aefb9d9fc178c15f3ddac38bf2bbd1e6e214f03865b2c71cd975fc9fad" + ], + "index": "pypi", + "version": "==0.8.2" + }, + "html5lib": { + "hashes": [ + "sha256:20b159aa3badc9d5ee8f5c647e5efd02ed2a66ab8d354930bd9ff139fc1dc0a3", + "sha256:66cb0dcfdbbc4f9c3ba1a63fdb511ffdbd4f513b2b6d81b80cd26ce6b3fb3736" + ], + "index": "pypi", + "version": "==1.0.1" + }, + "idna": { + "hashes": [ + "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", + "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" + ], + "version": "==2.8" + }, + "ipython": { + "hashes": [ + "sha256:1d3a1692921e932751bc1a1f7bb96dc38671eeefdc66ed33ee4cbc57e92a410e", + "sha256:537cd0176ff6abd06ef3e23f2d0c4c2c8a4d9277b7451544c6cbf56d1c79a83d" + ], + "index": "pypi", + "version": "==7.7.0" + }, + "ipython-genutils": { + "hashes": [ + "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8", + "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8" + ], + "version": "==0.2.0" + }, + "isort": { + "hashes": [ + "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", + "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" + ], + "version": "==4.3.21" + }, + "jedi": { + "hashes": [ + "sha256:53c850f1a7d3cfcd306cc513e2450a54bdf5cacd7604b74e42dd1f0758eaaf36", + "sha256:e07457174ef7cb2342ff94fa56484fe41cec7ef69b0059f01d3f812379cb6f7c" + ], + "version": "==0.14.1" + }, + "lazy-object-proxy": { + "hashes": [ + "sha256:159a745e61422217881c4de71f9eafd9d703b93af95618635849fe469a283661", + "sha256:23f63c0821cc96a23332e45dfaa83266feff8adc72b9bcaef86c202af765244f", + "sha256:3b11be575475db2e8a6e11215f5aa95b9ec14de658628776e10d96fa0b4dac13", + "sha256:3f447aff8bc61ca8b42b73304f6a44fa0d915487de144652816f950a3f1ab821", + "sha256:4ba73f6089cd9b9478bc0a4fa807b47dbdb8fad1d8f31a0f0a5dbf26a4527a71", + "sha256:4f53eadd9932055eac465bd3ca1bd610e4d7141e1278012bd1f28646aebc1d0e", + "sha256:64483bd7154580158ea90de5b8e5e6fc29a16a9b4db24f10193f0c1ae3f9d1ea", + "sha256:6f72d42b0d04bfee2397aa1862262654b56922c20a9bb66bb76b6f0e5e4f9229", + "sha256:7c7f1ec07b227bdc561299fa2328e85000f90179a2f44ea30579d38e037cb3d4", + "sha256:7c8b1ba1e15c10b13cad4171cfa77f5bb5ec2580abc5a353907780805ebe158e", + "sha256:8559b94b823f85342e10d3d9ca4ba5478168e1ac5658a8a2f18c991ba9c52c20", + "sha256:a262c7dfb046f00e12a2bdd1bafaed2408114a89ac414b0af8755c696eb3fc16", + "sha256:acce4e3267610c4fdb6632b3886fe3f2f7dd641158a843cf6b6a68e4ce81477b", + "sha256:be089bb6b83fac7f29d357b2dc4cf2b8eb8d98fe9d9ff89f9ea6012970a853c7", + "sha256:bfab710d859c779f273cc48fb86af38d6e9210f38287df0069a63e40b45a2f5c", + "sha256:c10d29019927301d524a22ced72706380de7cfc50f767217485a912b4c8bd82a", + "sha256:dd6e2b598849b3d7aee2295ac765a578879830fb8966f70be8cd472e6069932e", + "sha256:e408f1eacc0a68fed0c08da45f31d0ebb38079f043328dce69ff133b95c29dc1" + ], + "version": "==1.4.1" + }, + "logbook": { + "hashes": [ + "sha256:a5a96792abd8172c80d61b7530e134524f20e2841981038031e602ed5920fef5" + ], + "version": "==1.4.3" + }, + "lxml": { + "hashes": [ + "sha256:06e5599b9c54f797a3c0f384c67705a0d621031007aa2400a6c7d17300fdb995", + "sha256:092237cfe4ece074401b75001a2e525fa6e1fb9d40fee8b7b132b1947d3bd2f8", + "sha256:0b6d49d0a26fe8207df8dd27c40b75be4deb2277173903aa76ec3e82df77cbe7", + "sha256:0f77061c20b4f32b1cf39e8f661c74e966344084c996e7b23c3a94e472461df0", + "sha256:0fef86edfa2f146b4b0ae2c6c05c3e4a8f3388b3655eafbc4aab3247f4dabb24", + "sha256:2f163c8844db4ed06a230ef092e2461ad01830972a896b8f3cf8b5bac70ae85d", + "sha256:350333190052bbfbc3222b1805b59b7979d7276e57af2257367e15a2db27082d", + "sha256:3b57dc5ed7b6a7d852c961f2389ca99404c2b59fd2088baec6fbaca02f688be4", + "sha256:3e86e5df4a8edd6f725f3c76f1d45e046d4f3aa40478092e4f5f373ad1f526e2", + "sha256:43dac60d10341d3e56be089cd0798b70e70d45ce32279f4c3190d8cbd71350e4", + "sha256:4665ee84ac8ba11d58f1ed517e29ea8536b4ae4e0c6fb6c7d3dce70abcd279f0", + "sha256:5033cf606a7cb559db967689b1b2e743994000f783607ba4c484e90917395ad7", + "sha256:75d731af05bf40f808d7716e0d26b4b02913402f861c032ce8c36efca350ae72", + "sha256:7720174604c7647e357566ac9e4d135c137caed5e7b01223551a4c81c8dc8b9a", + "sha256:b33ec641309bcea40c76c1b105f988e4e8f9a2f1ee1486aa5c0eeef33956c9bb", + "sha256:d1135dc0ac197242028ede085b693ba1f2bff7f0f9b91080e2540348312bfa53", + "sha256:d5a61e9c2322b45f259909a02b76bc98c4641214e22a37191d00c151aa9cdb9a", + "sha256:da22c4b17bc17dad9c8faf6d94c8fe568ac71c867a56631ab874da418fc7f8f7", + "sha256:da5c48ec9f8d8b5df42d328b6d1fb8d9413cd664a2367ef4f6f7cc48ee5b82c0", + "sha256:db2794bad21b7b30b6849b4e1537171cae8a7087711d958d69c233470dc612e7", + "sha256:f1c2f67df727034f94ccb590142d1d110f3dd38f638a4f1567fdd9f39892ba05", + "sha256:f840dddded8b046edc774c88ed8d2442cdb231a68894c42c74e3a809450fae76" + ], + "version": "==4.4.0" + }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, + "parso": { + "hashes": [ + "sha256:63854233e1fadb5da97f2744b6b24346d2750b85965e7e399bec1620232797dc", + "sha256:666b0ee4a7a1220f65d367617f2cd3ffddff3e205f3f16a0284df30e774c2a9c" + ], + "version": "==0.5.1" + }, + "pypcapkit": { + "editable": true, + "path": "." + }, + "pexpect": { + "hashes": [ + "sha256:2094eefdfcf37a1fdbfb9aa090862c1a4878e5c7e0e7e7088bdb511c558e5cd1", + "sha256:9e2c1fd0e6ee3a49b28f95d4b33bc389c89b20af6a1255906e90ff1262ce62eb" + ], + "markers": "sys_platform != 'win32'", + "version": "==4.7.0" + }, + "pickleshare": { + "hashes": [ + "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca", + "sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56" + ], + "version": "==0.7.5" + }, + "prompt-toolkit": { + "hashes": [ + "sha256:11adf3389a996a6d45cc277580d0d53e8a5afd281d0c9ec71b28e6f121463780", + "sha256:2519ad1d8038fd5fc8e770362237ad0364d16a7650fb5724af6997ed5515e3c1", + "sha256:977c6583ae813a37dc1c2e1b715892461fcbdaa57f6fc62f33a528c4886c8f55" + ], + "version": "==2.0.9" + }, + "ptyprocess": { + "hashes": [ + "sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0", + "sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f" + ], + "version": "==0.6.0" + }, + "py": { + "hashes": [ + "sha256:64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa", + "sha256:dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53" + ], + "version": "==1.8.0" + }, + "pycodestyle": { + "hashes": [ + "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", + "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c" + ], + "version": "==2.5.0" + }, + "pygments": { + "hashes": [ + "sha256:71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127", + "sha256:881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297" + ], + "version": "==2.4.2" + }, + "pylint": { + "hashes": [ + "sha256:5d77031694a5fb97ea95e828c8d10fc770a1df6eb3906067aaed42201a8a6a09", + "sha256:723e3db49555abaf9bf79dc474c6b9e2935ad82230b10c1138a71ea41ac0fff1" + ], + "index": "pypi", + "version": "==2.3.1" + }, + "pyshark": { + "hashes": [ + "sha256:46ee30c6f23fb18c7ed6dd26a86e76c223b40e3dcc66d51c34f6df3915bc41cc", + "sha256:e885690b8144c7f7f14bf4ba1527b0c30c640f5e7f7aa15b4cdb408f7f576fa2" + ], + "index": "pypi", + "version": "==0.4.2.8" + }, + "requests": { + "hashes": [ + "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", + "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" + ], + "index": "pypi", + "version": "==2.22.0" + }, + "scapy": { + "hashes": [ + "sha256:e2f8d11f6a941c14a789ae8b236b27bd634681f1b29b5e893861e284d234f6b0" + ], + "index": "pypi", + "version": "==2.4.3" + }, + "six": { + "hashes": [ + "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", + "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" + ], + "version": "==1.12.0" + }, + "soupsieve": { + "hashes": [ + "sha256:72b5f1aea9101cf720a36bb2327ede866fd6f1a07b1e87c92a1cc18113cbc946", + "sha256:e4e9c053d59795e440163733a7fec6c5972210e1790c507e4c7b051d6c5259de" + ], + "version": "==1.9.2" + }, + "tbtrim": { + "hashes": [ + "sha256:860839d7296298a8823b3a0ac49a7f29424819d1481b5521329d339eac062bb9", + "sha256:b0810edfb5dcf94c5fe3335a8a8e18ae38a411f6ff6afca188c66ac72444218f" + ], + "index": "pypi", + "version": "==0.2.1" + }, + "traitlets": { + "hashes": [ + "sha256:9c4bd2d267b7153df9152698efb1050a5d84982d3384a37b2c1f7723ba3e7835", + "sha256:c6cb5e6f57c5a9bdaa40fa71ce7b4af30298fbab9ece9815b5d995ab6217c7d9" + ], + "version": "==4.3.2" + }, + "typed-ast": { + "hashes": [ + "sha256:18511a0b3e7922276346bcb47e2ef9f38fb90fd31cb9223eed42c85d1312344e", + "sha256:262c247a82d005e43b5b7f69aff746370538e176131c32dda9cb0f324d27141e", + "sha256:2b907eb046d049bcd9892e3076c7a6456c93a25bebfe554e931620c90e6a25b0", + "sha256:354c16e5babd09f5cb0ee000d54cfa38401d8b8891eefa878ac772f827181a3c", + "sha256:4e0b70c6fc4d010f8107726af5fd37921b666f5b31d9331f0bd24ad9a088e631", + "sha256:630968c5cdee51a11c05a30453f8cd65e0cc1d2ad0d9192819df9978984529f4", + "sha256:66480f95b8167c9c5c5c87f32cf437d585937970f3fc24386f313a4c97b44e34", + "sha256:71211d26ffd12d63a83e079ff258ac9d56a1376a25bc80b1cdcdf601b855b90b", + "sha256:95bd11af7eafc16e829af2d3df510cecfd4387f6453355188342c3e79a2ec87a", + "sha256:bc6c7d3fa1325a0c6613512a093bc2a2a15aeec350451cbdf9e1d4bffe3e3233", + "sha256:cc34a6f5b426748a507dd5d1de4c1978f2eb5626d51326e43280941206c209e1", + "sha256:d755f03c1e4a51e9b24d899561fec4ccaf51f210d52abdf8c07ee2849b212a36", + "sha256:d7c45933b1bdfaf9f36c579671fec15d25b06c8398f113dab64c18ed1adda01d", + "sha256:d896919306dd0aa22d0132f62a1b78d11aaf4c9fc5b3410d3c666b818191630a", + "sha256:ffde2fbfad571af120fcbfbbc61c72469e72f550d676c3342492a9dfdefb8f12" + ], + "markers": "implementation_name == 'cpython'", + "version": "==1.4.0" + }, + "urllib3": { + "hashes": [ + "sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", + "sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232" + ], + "version": "==1.25.3" + }, + "wcwidth": { + "hashes": [ + "sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e", + "sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c" + ], + "version": "==0.1.7" + }, + "webencodings": { + "hashes": [ + "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78", + "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923" + ], + "version": "==0.5.1" + }, + "wrapt": { + "hashes": [ + "sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1" + ], + "version": "==1.11.2" + } + } +} diff --git a/docker/.dockerignore b/archive/docker/.dockerignore similarity index 100% rename from docker/.dockerignore rename to archive/docker/.dockerignore diff --git a/docker/Dockerfile b/archive/docker/Dockerfile similarity index 98% rename from docker/Dockerfile rename to archive/docker/Dockerfile index cbfda7dfd..bb04cbb13 100644 --- a/docker/Dockerfile +++ b/archive/docker/Dockerfile @@ -1,6 +1,6 @@ # basic info FROM library/ubuntu -LABEL version 2019.03.28 +LABEL version 2019.08.08 LABEL description "Ubuntu Environment" # prepare environment diff --git a/docker/docker-compose.yml b/archive/docker/docker-compose.yml similarity index 100% rename from docker/docker-compose.yml rename to archive/docker/docker-compose.yml diff --git a/docker/docker.sh b/archive/docker/docker.sh similarity index 100% rename from docker/docker.sh rename to archive/docker/docker.sh diff --git a/release b/release index 9f69d97f4..248808c7e 160000 --- a/release +++ b/release @@ -1 +1 @@ -Subproject commit 9f69d97f44b90ebf729183c36f2cf88f5bede42d +Subproject commit 248808c7ee227476524a49cdbf78333df3044471 diff --git a/sample/out.json b/sample/out.json index 9b3caaa45..06e67fc9f 100644 --- a/sample/out.json +++ b/sample/out.json @@ -156,11 +156,11 @@ "flags" : { "ns" : false, "cwr" : false, - "ecn" : false, + "ece" : false, "urg" : false, "ack" : true, - "push" : false, - "reset" : false, + "psh" : false, + "rst" : false, "syn" : false, "fin" : true }, @@ -231,11 +231,11 @@ "flags" : { "ns" : false, "cwr" : false, - "ecn" : false, + "ece" : false, "urg" : false, "ack" : true, - "push" : false, - "reset" : false, + "psh" : false, + "rst" : false, "syn" : false, "fin" : false }, @@ -306,11 +306,11 @@ "flags" : { "ns" : false, "cwr" : false, - "ecn" : false, + "ece" : false, "urg" : false, "ack" : true, - "push" : false, - "reset" : false, + "psh" : false, + "rst" : false, "syn" : false, "fin" : true }, diff --git a/sample/out.plist b/sample/out.plist index 68d8f2392..1a1d3fb72 100644 --- a/sample/out.plist +++ b/sample/out.plist @@ -296,15 +296,15 @@ cwr - ecn + ece urg ack - push + psh - reset + rst syn @@ -439,15 +439,15 @@ cwr - ecn + ece urg ack - push + psh - reset + rst syn @@ -582,15 +582,15 @@ cwr - ecn + ece urg ack - push + psh - reset + rst syn diff --git a/sample/out.txt b/sample/out.txt index 36096042c..beea228b2 100644 --- a/sample/out.txt +++ b/sample/out.txt @@ -190,11 +190,11 @@ Frame 3 | |-- flags | | |-- ns -> False | | |-- cwr -> False - | | |-- ecn -> False + | | |-- ece -> False | | |-- urg -> False | | |-- ack -> True - | | |-- push -> False - | | |-- reset -> False + | | |-- psh -> False + | | |-- rst -> False | | |-- syn -> False | | |-- fin -> True | |-- window_size -> 31920 @@ -271,11 +271,11 @@ Frame 4 | |-- flags | | |-- ns -> False | | |-- cwr -> False - | | |-- ecn -> False + | | |-- ece -> False | | |-- urg -> False | | |-- ack -> True - | | |-- push -> False - | | |-- reset -> False + | | |-- psh -> False + | | |-- rst -> False | | |-- syn -> False | | |-- fin -> False | |-- window_size -> 65535 @@ -352,11 +352,11 @@ Frame 5 | |-- flags | | |-- ns -> False | | |-- cwr -> False - | | |-- ecn -> False + | | |-- ece -> False | | |-- urg -> False | | |-- ack -> True - | | |-- push -> False - | | |-- reset -> False + | | |-- psh -> False + | | |-- rst -> False | | |-- syn -> False | | |-- fin -> True | |-- window_size -> 65535 diff --git a/setup.py b/setup.py index 4ec732c72..f8da1af89 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from distutils.core import setup # version string -__version__ = '0.14.2' +__version__ = '0.14.3' # README with open('README.md', encoding='utf-8') as file: @@ -108,6 +108,7 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: Implementation', 'Programming Language :: Python :: Implementation :: CPython', diff --git a/src/__init__.py b/src/__init__.py index ab096c471..1ac86dc70 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -53,6 +53,7 @@ dump utilities for `pcapkit` implementation """ +# pylint: disable=wrong-import-position, unused-import, unused-wildcard-import import os import warnings @@ -66,12 +67,12 @@ filename=__file__, lineno=0, line=f"PCAPKIT_DEVMODE={os.environ['PCAPKIT_DEVMODE']}") else: - ROOT = os.path.dirname(os.path.relpath(__file__)) + ROOT = os.path.dirname(os.path.realpath(__file__)) tbtrim.set_trim_rule(lambda filename: ROOT in os.path.realpath(filename), exception=BaseError, strict=False) # All Reference -import pcapkit.__all__ as all # pylint: disable +import pcapkit.__all__ as all # pylint: disable=redefined-builtin # Interface from pcapkit.interface import * @@ -110,13 +111,13 @@ 'TREE', 'JSON', 'PLIST', 'PCAP', # Format Macros 'LINK', 'INET', 'TRANS', 'APP', 'RAW', # Layer Macros 'DPKT', 'Scapy', 'PyShark', 'MPServer', 'MPPipeline', 'PCAPKit', - # Engine Macros + # Engine Macros # pylint: disable=bad-continuation 'NoPayload', # No Payload 'Raw', # Raw Packet 'ARP', 'Ethernet', 'L2TP', 'OSPF', 'RARP', 'VLAN', # Link Layer 'AH', 'IP', 'IPsec', 'IPv4', 'IPv6', 'IPX', # Internet Layer 'HIP', 'HOPOPT', 'IPv6_Frag', 'IPv6_Opts', 'IPv6_Route', 'MH', - # IPv6 Extension Header + # IPv6 Extension Header # pylint: disable=bad-continuation 'TCP', 'UDP', # Transport Layer 'FTP', 'HTTP', # Application Layer ] diff --git a/src/const/http/setting.py b/src/const/http/setting.py index b7c1faef0..3e9f07d69 100644 --- a/src/const/http/setting.py +++ b/src/const/http/setting.py @@ -16,6 +16,7 @@ class Setting(IntEnum): Setting['INITIAL_WINDOW_SIZE'] = 0x0004 # [RFC 7540, Section 6.5.2] 65535 Setting['MAX_FRAME_SIZE'] = 0x0005 # [RFC 7540, Section 6.5.2] 16384 Setting['MAX_HEADER_LIST_SIZE'] = 0x0006 # [RFC 7540, Section 6.5.2] infinite + Setting['Unassigned'] = 0x0007 Setting['SETTINGS_ENABLE_CONNECT_PROTOCOL'] = 0x0008 # [RFC 8441] 0 Setting['TLS_RENEG_PERMITTED'] = 0x0010 # [MS-HTTP2E][Gabriel_Montenegro] 0x00 @@ -33,9 +34,6 @@ def _missing_(cls, value): """Lookup function used when value is not found.""" if not (isinstance(value, int) and 0x0000 <= value <= 0xFFFF): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) - if 0x0007 <= value <= 0x000F: - extend_enum(cls, 'Unassigned [0x%s]' % hex(value)[2:].upper().zfill(4), value) - return cls(value) if 0x0009 <= value <= 0x000F: extend_enum(cls, 'Unassigned [0x%s]' % hex(value)[2:].upper().zfill(4), value) return cls(value) diff --git a/src/const/ipv6/option.py b/src/const/ipv6/option.py index e89f109b7..a120494ce 100644 --- a/src/const/ipv6/option.py +++ b/src/const/ipv6/option.py @@ -12,7 +12,8 @@ class Option(IntEnum): Option['PAD'] = 0x00 # [IPV6] Option['PADN'] = 0x01 # [IPV6] Option['JUMBO'] = 0xC2 # [RFC 2675] - Option['RPL'] = 0x63 # [RFC 6553] + Option['RPL Option'] = 0x23 # [RFC -ietf-roll-useofrplinfo-31] + Option['RPL'] = 0x63 # [RFC 6553][RFC -ietf-roll-useofrplinfo-31] Option['TUN'] = 0x04 # [RFC 2473] Option['RA'] = 0x05 # [RFC 2711] Option['QS'] = 0x26 # [RFC 4782][RFC Errata 2034] diff --git a/src/const/misc/linktype.py b/src/const/misc/linktype.py index 961c07339..bedca98c8 100644 --- a/src/const/misc/linktype.py +++ b/src/const/misc/linktype.py @@ -131,6 +131,11 @@ class LinkType(IntEnum): LinkType['DSA_TAG_BRCM'] = 281 # DLT_DSA_TAG_BRCM LinkType['DSA_TAG_BRCM_PREPEND'] = 282 # DLT_DSA_TAG_BRCM_PREPEND LinkType['IEEE802_15_4_TAP'] = 283 # DLT_IEEE802_15_4_TAP + LinkType['DSA_TAG_DSA'] = 284 # DLT_DSA_TAG_DSA + LinkType['DSA_TAG_EDSA'] = 285 # DLT_DSA_TAG_EDSA + LinkType['ELEE'] = 286 # DLT_ELEE + LinkType['Z_WAVE_SERIAL'] = 287 # DLT_Z_WAVE_SERIAL + LinkType['USB_2_0'] = 288 # DLT_USB_2_0 @staticmethod def get(key, default=-1): diff --git a/src/const/tcp/option.py b/src/const/tcp/option.py index 59ecff7d8..659d7bd28 100644 --- a/src/const/tcp/option.py +++ b/src/const/tcp/option.py @@ -39,12 +39,12 @@ class Option(IntEnum): Option['QS'] = 27 # [RFC 4782] Option['TIMEOUT'] = 28 # [RFC 5482] Option['AO'] = 29 # [RFC 5925] - Option['MP'] = 30 # [RFC 6824] + Option['MP'] = 30 # [RFC -ietf-mptcp-rfc6824bis-18] Option['Reserved [31]'] = 31 Option['Reserved [32]'] = 32 Option['Reserved [33]'] = 33 Option['FASTOPEN'] = 34 # [RFC 7413] - Option['Encryption Negotiation'] = 69 # [RFC -ietf-tcpinc-tcpeno-19] + Option['Encryption Negotiation'] = 69 # [RFC 8547] Option['Reserved [70]'] = 70 Option['Reserved [76]'] = 76 Option['Reserved [77]'] = 77 diff --git a/src/utilities/validations.py b/src/utilities/validations.py index 4764a77a1..dd1fef834 100644 --- a/src/utilities/validations.py +++ b/src/utilities/validations.py @@ -18,12 +18,10 @@ import aenum -from pcapkit.utilities.exceptions import (BoolError, BytearrayError, - BytesError, ComplexError, DictError, - DigitError, EnumError, FragmentError, - InfoError, IntError, IOObjError, - IPError, ListError, PacketError, - RealError, StringError, TupleError) +from pcapkit.utilities.exceptions import (BoolError, BytearrayError, BytesError, ComplexError, + DictError, DigitError, EnumError, FragmentError, + InfoError, IntError, IOObjError, IPError, ListError, + PacketError, RealError, StringError, TupleError) __all__ = [ 'int_check', 'real_check', 'complex_check', 'number_check', @@ -33,207 +31,203 @@ ] -def int_check(*args, func=None): +def int_check(*args, stacklevel=2): """Check if arguments are integrals.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, numbers.Integral): name = type(var).__name__ - raise ComplexError( - f'Function {func} expected integral number, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise IntError(f'Function {func} expected integral number, {name} got instead.') -def real_check(*args, func=None): +def real_check(*args, stacklevel=2): """Check if arguments are real numbers.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, numbers.Real): name = type(var).__name__ - raise ComplexError( - f'Function {func} expected real number, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise RealError(f'Function {func} expected real number, {name} got instead.') -def complex_check(*args, func=None): +def complex_check(*args, stacklevel=2): """Check if arguments are complex numbers.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, numbers.Complex): name = type(var).__name__ - raise ComplexError( - f'Function {func} expected complex number, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise ComplexError(f'Function {func} expected complex number, {name} got instead.') -def number_check(*args, func=None): +def number_check(*args, stacklevel=2): """Check if arguments are numbers.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, numbers.Number): name = type(var).__name__ - raise DigitError( - f'Function {func} expected number, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise DigitError(f'Function {func} expected number, {name} got instead.') -def bytes_check(*args, func=None): +def bytes_check(*args, stacklevel=2): """Check if arguments are bytes type.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (bytes, collections.abc.ByteString)): name = type(var).__name__ - raise BytesError( - f'Function {func} expected bytes, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise BytesError(f'Function {func} expected bytes, {name} got instead.') -def bytearray_check(*args, func=None): +def bytearray_check(*args, stacklevel=2): """Check if arguments are bytearray type.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (bytearray, collections.abc.ByteString, collections.abc.MutableSequence)): - name = type(var).__name__ - raise BytearrayError( - f'Function {func} expected bytearray, {name} got instead.') + name = type(var).__name__func = inspect.stack()[stacklevel][3] + func = inspect.stack()[stacklevel][3] + raise BytearrayError(f'Function {func} expected bytearray, {name} got instead.') -def str_check(*args, func=None): +def str_check(*args, stacklevel=2): """Check if arguments are str type.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (str, collections.UserString, collections.abc.Sequence)): name = type(var).__name__ - raise StringError( - f'Function {func} expected str, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise StringError(f'Function {func} expected str, {name} got instead.') -def bool_check(*args, func=None): +def bool_check(*args, stacklevel=2): """Check if arguments are bytes type.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, bool): name = type(var).__name__ - raise BoolError( - f'Function {func} expected bool, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise BoolError(f'Function {func} expected bool, {name} got instead.') -def list_check(*args, func=None): +def list_check(*args, stacklevel=2): """Check if arguments are list type.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (list, collections.UserList, collections.abc.MutableSequence)): name = type(var).__name__ - raise ListError( - f'Function {func} expected list, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise ListError(f'Function {func} expected list, {name} got instead.') -def dict_check(*args, func=None): +def dict_check(*args, stacklevel=2): """Check if arguments are dict type.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (dict, collections.UserDict, collections.abc.MutableMapping)): name = type(var).__name__ - raise DictError( - f'Function {func} expected dict, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise DictError(f'Function {func} expected dict, {name} got instead.') -def tuple_check(*args, func=None): +def tuple_check(*args, stacklevel=2): """Check if arguments are tuple type.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (tuple, collections.abc.Sequence)): name = type(var).__name__ - raise TupleError( - f'Function {func} expected tuple, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise TupleError(f'Function {func} expected tuple, {name} got instead.') -def io_check(*args, func=None): +def io_check(*args, stacklevel=2): """Check if arguments are file-like object.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, io.IOBase): name = type(var).__name__ - raise IOObjError( - f'Function {func} expected file-like object, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise IOObjError(f'Function {func} expected file-like object, {name} got instead.') -def info_check(*args, func=None): +def info_check(*args, stacklevel=2): """Check if arguments are Info instance.""" from pcapkit.corekit.infoclass import Info - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, Info): name = type(var).__name__ - raise InfoError( - f'Function {func} expected Info instance, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise InfoError(f'Function {func} expected Info instance, {name} got instead.') -def ip_check(*args, func=None): +def ip_check(*args, stacklevel=2): """Check if arguments are IP addresses.""" - func = func or inspect.stack()[2][3] for var in args: - if not isinstance(var, ipaddress._IPAddressBase): + if not isinstance(var, ipaddress._IPAddressBase): # pylint: disable=protected-access name = type(var).__name__ - raise IPError( - f'Function {func} expected IP address, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise IPError(f'Function {func} expected IP address, {name} got instead.') -def enum_check(*args, func=None): +def enum_check(*args, stacklevel=2): """Check if arguments are of protocol type.""" - func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (enum.EnumMeta, aenum.EnumMeta)): name = type(var).__name__ - raise EnumError( - f'Function {func} expected enumeration, {name} got instead.') + func = inspect.stack()[stacklevel][3] + raise EnumError(f'Function {func} expected enumeration, {name} got instead.') -def frag_check(*args, protocol, func=None): +def frag_check(*args, protocol, stacklevel=3): """Check if arguments are valid fragments.""" - func = func or inspect.stack()[2][3] if 'IP' in protocol: - _ip_frag_check(*args, func=func) + try: + _ip_frag_check(*args, stacklevel=stacklevel) + except KeyError as error: + raise FragmentError(f'Missing fragment key: {error.args[0]}') + except Exception as error: + raise FragmentError(f'Malformed fragment object: {error}') elif 'TCP' in protocol: - _tcp_frag_check(*args, func=func) + try: + _tcp_frag_check(*args, stacklevel=stacklevel) + except KeyError as error: + raise FragmentError(f'Missing fragment key: {error.args[0]}') + except Exception as error: + raise FragmentError(f'Malformed fragment object: {error}') else: raise FragmentError(f'Unknown fragmented protocol {protocol}.') -def _ip_frag_check(*args, func=None): +def _ip_frag_check(*args, stacklevel=3): """Check if arguments are valid IP fragments.""" - func = func or inspect.stack()[2][3] for var in args: - dict_check(var, func=func) - bufid = var.get('bufid') - str_check(bufid[3], func=func) - bool_check(var.get('mf'), func=func) - ip_check(bufid[0], bufid[1], func=func) - bytearray_check(var.get('header'), var.get('payload'), func=func) - int_check(bufid[2], var.get('num'), var.get('fo'), - var.get('ihl'), var.get('tl'), func=func) + dict_check(var, stacklevel=stacklevel) + bufid = var['bufid'] + str_check(bufid[3], stacklevel=stacklevel) + bool_check(var['mf'], stacklevel=stacklevel) + ip_check(bufid[0], bufid[1], stacklevel=stacklevel) + bytearray_check(var['header'], var['payload'], stacklevel=stacklevel) + int_check(bufid[2], var['num'], var['fo'], + var['ihl'], var['tl'], stacklevel=stacklevel) -def _tcp_frag_check(*args, func=None): +def _tcp_frag_check(*args, stacklevel=3): """Check if arguments are valid TCP fragments.""" - func = func or inspect.stack()[2][3] for var in args: - dict_check(var, func=func) - bufid = var.get('bufid') - ip_check(bufid[0], bufid[1], func=func) - bytearray_check(var.get('payload'), func=func) - bool_check(var.get('syn'), var.get('fin'), func=func) - int_check(bufid[2], bufid[3], var.get('num'), var.get('ack'), var.get('dsn'), - var.get('first'), var.get('last'), var.get('len'), func=func) + dict_check(var, stacklevel=stacklevel) + bufid = var['bufid'] + ip_check(bufid[0], bufid[1], stacklevel=stacklevel) + bytearray_check(var['payload'], stacklevel=stacklevel) + bool_check(var['syn'], var['fin'], stacklevel=stacklevel) + int_check(bufid[2], bufid[3], var['num'], var['ack'], var['dsn'], + var['first'], var['last'], var['len'], stacklevel=stacklevel) -def pkt_check(*args, func=None): +def pkt_check(*args, stacklevel=3): """Check if arguments are valid packets.""" - func = func or inspect.stack()[2][3] - for var in args: - dict_check(var, func=func) - dict_check(var.get('frame'), func=func) - enum_check(var.get('protocol'), func=func) - real_check(var.get('timestamp'), func=func) - ip_check(var.get('src'), var.get('dst'), func=func) - bool_check(var.get('syn'), var.get('fin'), func=func) - int_check(var.get('srcport'), var.get('dstport'), var.get('index'), func=func) + try: + for var in args: + dict_check(var, stacklevel=stacklevel) + dict_check(var['frame'], stacklevel=stacklevel) + enum_check(var['protocol'], stacklevel=stacklevel) + real_check(var['timestamp'], stacklevel=stacklevel) + ip_check(var['src'], var['dst'], stacklevel=stacklevel) + bool_check(var['syn'], var['fin'], stacklevel=stacklevel) + int_check(var['srcport'], var['dstport'], var['index'], stacklevel=stacklevel) + except KeyError as error: + raise PacketError(f'Missing packet key: {error.args[0]}') + except Exception as error: + raise PacketError(f'Malformed packet object: {error}') ############################################################################### diff --git a/src/vendor/ftp/return_code.py b/src/vendor/ftp/return_code.py index ad2499cd4..0accb1cbe 100644 --- a/src/vendor/ftp/return_code.py +++ b/src/vendor/ftp/return_code.py @@ -3,10 +3,11 @@ import collections import contextlib import os -import re +import tempfile +import webbrowser import bs4 -import requests +# import requests ############### # Macros @@ -21,11 +22,21 @@ # Processors ############### -page = requests.get(LINK) -soup = bs4.BeautifulSoup(page.text, 'html5lib') +# page = requests.get(LINK) +# soup = bs4.BeautifulSoup(page.text, 'html5lib') +with tempfile.TemporaryDirectory(prefix=f'{os.path.realpath(os.curdir)}/') as tempdir: + index_html = os.path.join(tempdir, 'index.html') + + webbrowser.open(LINK) + print(f'Please save the HTML code as {index_html!r}.') + input('Press ENTER to continue...') + + with open(index_html) as file: + text = file.read() +soup = bs4.BeautifulSoup(text, 'html5lib') table = soup.find_all('table', class_='wikitable')[2] -content = filter(lambda item: isinstance(item, bs4.element.Tag), table.tbody) +content = filter(lambda item: isinstance(item, bs4.element.Tag), table.tbody) # pylint: disable=filter-builtin-not-iterating header = next(content) temp = list() @@ -40,14 +51,14 @@ record = collections.Counter(temp) -def rename(name, code): +def rename(name, code): # pylint: disable=redefined-outer-name if record[name] > 1: name = f'{name} [{code}]' return name table = soup.find_all('table', class_='wikitable')[2] -content = filter(lambda item: isinstance(item, bs4.element.Tag), table.tbody) +content = filter(lambda item: isinstance(item, bs4.element.Tag), table.tbody) # pylint: disable=filter-builtin-not-iterating header = next(content) enum = list() @@ -70,7 +81,7 @@ def rename(name, code): ENUM = '\n '.join(map(lambda s: s.rstrip(), enum)) -def LINE(NAME, DOCS, FLAG, ENUM): return f'''\ +LINE = lambda NAME, DOCS, FLAG, ENUM: f'''\ # -*- coding: utf-8 -*- from aenum import IntEnum, extend_enum diff --git a/src/vendor/ipx/packet.py b/src/vendor/ipx/packet.py index b3155f5ca..d5996fd42 100644 --- a/src/vendor/ipx/packet.py +++ b/src/vendor/ipx/packet.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# pylint: disable=wrong-import-position ############################################################################### import sys @@ -8,9 +9,11 @@ import contextlib import os import re +import webbrowser +import tempfile import bs4 -import requests +# import requests ############### # Macros @@ -25,11 +28,21 @@ # Processors ############### -page = requests.get(LINK) -soup = bs4.BeautifulSoup(page.text, 'html5lib') +# page = requests.get(LINK) +# soup = bs4.BeautifulSoup(page.text, 'html5lib') +with tempfile.TemporaryDirectory(prefix=f'{os.path.realpath(os.curdir)}/') as tempdir: + index_html = os.path.join(tempdir, 'index.html') + + webbrowser.open(LINK) + print(f'Please save the HTML code as {index_html!r}.') + input('Press ENTER to continue...') + + with open(index_html) as file: + text = file.read() +soup = bs4.BeautifulSoup(text, 'html5lib') table = soup.find_all('table', class_='wikitable')[1] -content = filter(lambda item: isinstance(item, bs4.element.Tag), table.tbody) +content = filter(lambda item: isinstance(item, bs4.element.Tag), table.tbody) # pylint: disable=filter-builtin-not-iterating header = next(content) enum = list() @@ -67,7 +80,7 @@ MISS = '\n '.join(map(lambda s: s.rstrip(), miss)) -def LINE(NAME, DOCS, FLAG, ENUM, MISS): return f'''\ +LINE = lambda NAME, DOCS, FLAG, ENUM, MISS: f'''\ # -*- coding: utf-8 -*- from aenum import IntEnum, extend_enum diff --git a/src/vendor/ipx/socket.py b/src/vendor/ipx/socket.py index e77e5794e..a15645734 100644 --- a/src/vendor/ipx/socket.py +++ b/src/vendor/ipx/socket.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# pylint: disable=wrong-import-position ############################################################################### import sys @@ -8,9 +9,11 @@ import contextlib import os import re +import webbrowser +import tempfile import bs4 -import requests +# import requests ############### # Macros @@ -25,11 +28,21 @@ # Processors ############### -page = requests.get(LINK) -soup = bs4.BeautifulSoup(page.text, 'html5lib') +# page = requests.get(LINK) +# soup = bs4.BeautifulSoup(page.text, 'html5lib') +with tempfile.TemporaryDirectory(prefix=f'{os.path.realpath(os.curdir)}/') as tempdir: + index_html = os.path.join(tempdir, 'index.html') + + webbrowser.open(LINK) + print(f'Please save the HTML code as {index_html!r}.') + input('Press ENTER to continue...') + + with open(index_html) as file: + text = file.read() +soup = bs4.BeautifulSoup(text, 'html5lib') table = soup.find_all('table', class_='wikitable')[3] -content = filter(lambda item: isinstance(item, bs4.element.Tag), table.tbody) +content = filter(lambda item: isinstance(item, bs4.element.Tag), table.tbody) # pylint: disable=filter-builtin-not-iterating header = next(content) enum = list() @@ -75,7 +88,7 @@ MISS = '\n '.join(map(lambda s: s.rstrip(), miss)) -def LINE(NAME, DOCS, FLAG, ENUM, MISS): return f'''\ +LINE = lambda NAME, DOCS, FLAG, ENUM, MISS: f'''\ # -*- coding: utf-8 -*- from aenum import IntEnum, extend_enum diff --git a/src/vendor/vlan/priority_level.py b/src/vendor/vlan/priority_level.py index 97f6ae9c3..823ac1c03 100644 --- a/src/vendor/vlan/priority_level.py +++ b/src/vendor/vlan/priority_level.py @@ -3,9 +3,11 @@ import contextlib import os import re +import webbrowser +import tempfile import bs4 -import requests +# import requests ############### # Macros @@ -20,11 +22,21 @@ # Processors ############### -page = requests.get(LINK) -soup = bs4.BeautifulSoup(page.text, 'html5lib') +# page = requests.get(LINK) +# soup = bs4.BeautifulSoup(page.text, 'html5lib') +with tempfile.TemporaryDirectory(prefix=f'{os.path.realpath(os.curdir)}/') as tempdir: + index_html = os.path.join(tempdir, 'index.html') + + webbrowser.open(LINK) + print(f'Please save the HTML code as {index_html!r}.') + input('Press ENTER to continue...') + + with open(index_html) as file: + text = file.read() +soup = bs4.BeautifulSoup(text, 'html5lib') table = soup.find_all('table', class_='wikitable')[0] -content = filter(lambda item: isinstance(item, bs4.element.Tag), table.tbody) +content = filter(lambda item: isinstance(item, bs4.element.Tag), table.tbody) # pylint: disable=filter-builtin-not-iterating header = next(content) enum = list() @@ -61,7 +73,7 @@ MISS = '\n '.join(map(lambda s: s.rstrip(), miss)) -def LINE(NAME, DOCS, FLAG, ENUM, MISS): return f'''\ +LINE = lambda NAME, DOCS, FLAG, ENUM, MISS: f'''\ # -*- coding: utf-8 -*- from aenum import IntEnum, extend_enum