diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..6deafc2 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +max-line-length = 120 diff --git a/.gitignore b/.gitignore index 0a4e5c3..f023089 100644 --- a/.gitignore +++ b/.gitignore @@ -5,11 +5,10 @@ *.pyc -.coverage -.idea -.mypy_cache +*.egg-info + +/.coverage -/*.egg-info /.eggs /.tox /Pipfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c3a0d70..6ed562b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ stages: - deploy before_script: -- pip install -r dev-requirements.txt +- pip install tox .[tests] variables: GIT_SUBMODULE_DEPTH: 1 @@ -71,7 +71,8 @@ coveralls: stage: deploy script: - pip install coveralls - - pip install -r requirements.txt + - pip install . + - pip install .[tests] - coverage run -m unittest -v -f - coveralls only: diff --git a/.pylintrc b/.pylintrc index e477af8..2618c9b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,10 +1,6 @@ -[BASIC] +[MAIN] -good-names = e,f,g,n,p,q,y,_,H2 - -class-attribute-rgx = ([A-Za-z_][A-Za-z0-9_]{2,50}|(__.*__))$ -method-rgx = [a-z_][a-z0-9_]{2,50}$ -variable-rgx = [a-z_][a-z0-9_]{2,50}$ +jobs=0 [MASTER] @@ -12,8 +8,13 @@ load-plugins = pylint.extensions.no_self_use [FORMAT] -max-line-length = 120 +max-line-length=120 [MESSAGES CONTROL] -disable = missing-docstring,too-few-public-methods,too-many-ancestors,duplicate-code +disable= + missing-docstring, + too-few-public-methods, + too-many-function-args, + too-many-ancestors, + duplicate-code, diff --git a/.readthedocs.yaml b/.readthedocs.yaml index dc0fa1e..a27f1e8 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -11,5 +11,7 @@ build: python: install: - - requirements: docs-requirements.txt - - requirements: requirements.txt + - method: pip + path: . + extra_requirements: + - docs diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 0d4539e..e48e6f1 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -142,7 +142,7 @@ Preparing your Fork 3. ``cd theproject`` 4. `Create and activate a virtual environment `__. -5. Install the development requirements: ``pip install -r dev-requirements.txt``. +5. Install the development requirements: ``pip install .[tests]``. 6. Create a branch: ``git checkout -b foo-the-bars 1.3``. Making your Changes diff --git a/MANIFEST.in b/MANIFEST.in index bb73d96..bb37a27 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1 @@ include *.rst -include requirements.txt diff --git a/cryptoparser/__setup__.py b/cryptoparser/__setup__.py index c7835d0..c0b18e8 100644 --- a/cryptoparser/__setup__.py +++ b/cryptoparser/__setup__.py @@ -1,10 +1,14 @@ # -*- coding: utf-8 -*- -__title__ = 'CryptoParser' +import importlib.metadata + +metadata = importlib.metadata.metadata('cryptoparser') + +__title__ = metadata['Name'] __technical_name__ = __title__.lower() -__version__ = '0.12.6' -__description__ = 'An analysis oriented security protocol parser and generator' -__author__ = 'Szilárd Pfeiffer' -__author_email__ = 'coroner@pfeifferszilard.hu' +__version__ = metadata['Version'] +__description__ = metadata['Summary'] +__author__ = metadata['Author'] +__author_email__ = metadata['Author-email'] __url__ = 'https://gitlab.com/coroner/' + __technical_name__ -__license__ = 'MPL-2.0' +__license__ = metadata['License'] diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index fb4977a..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -coverage -tox -pyfakefs diff --git a/docs-requirements.txt b/docs-requirements.txt deleted file mode 100644 index 8f31421..0000000 --- a/docs-requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -sphinx -sphinx-sitemap diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e6c4b67 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,107 @@ +[build-system] +requires = ['setuptools', 'setuptools-scm'] +build-backend = 'setuptools.build_meta' + +[project] +name = 'CryptoParser' +version = '0.12.6' +description = 'An analysis oriented security protocol parser and generator' +authors = [ + {name = 'Szilárd Pfeiffer', email = 'coroner@pfeifferszilard.hu'} +] +maintainers = [ + {name = 'Szilárd Pfeiffer', email = 'coroner@pfeifferszilard.hu'} +] +classifiers=[ + 'Development Status :: 4 - Beta', + 'Environment :: Console', + 'Framework :: tox', + 'Intended Audience :: Information Technology', + 'Intended Audience :: Science/Research', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)', + 'Natural Language :: English', + 'Operating System :: MacOS', + 'Operating System :: Microsoft :: Windows', + 'Operating System :: POSIX', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy', + 'Programming Language :: Python', + 'Topic :: Internet', + 'Topic :: Security', + 'Topic :: Security :: Cryptography', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Software Development :: Testing :: Traffic Generation', + 'Topic :: Software Development :: Testing', +] + +keywords=['ssl', 'tls', 'gost', 'ja3', 'ldap', 'rdp', 'ssh', 'hsts', 'dns'] +readme = {file = 'README.rst', content-type = 'text/x-rst'} +license = {text = 'MPL-2.0'} + +dependencies = [ + 'asn1crypto', + 'attrs', + 'cryptodatahub==0.12.6', + 'python-dateutil', + 'urllib3', +] + +[project.optional-dependencies] +tests = [ + 'pyfakefs', +] +docs = [ + 'sphinx', + 'sphinx-sitemap', +] + +[project.urls] +Homepage = 'https://gitlab.com/coroner/cryptoparser' +Changelog = 'https://cryptoparser.readthedocs.io/en/latest/changelog' +Documentation = 'https://cryptoparser.readthedocs.io/en/latest/' +Issues = 'https://gitlab.com/coroner/cryptoparser/-/issues' +Source = 'https://gitlab.com/coroner/cryptoparser' + +[tool.variables] +technical_name = 'cryptoparser' + +[tool.setuptools] +license-files = ['LICENSE.txt'] + +[tool.setuptools.packages.find] +exclude = ['submodules'] + +[tool.tox] +envlist = [ + 'pep8', + 'pylint', + 'pypy3', + 'py39', + 'py310', + 'py311', + 'py312', + 'py313', + 'pythonrc', +] + +[tool.tox.env_run_base] +deps = ['coverage', '.[tests]'] +commands = [ + ['coverage', 'erase'], + ['coverage', 'run', '-m', 'unittest', 'discover', '-v'], + ['coverage', 'report'] +] + +[tool.tox.env.pep8] +deps = ['flake8'] +commands = [['flake8', 'cryptoparser', 'docs', 'test']] + +[tool.tox.env.pylint] +deps = ['pylint', '.[tests]'] +commands = [['pylint', '--rcfile', '.pylintrc', 'cryptoparser', 'docs', 'test']] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 7103f40..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -asn1crypto -attrs -cryptodatahub==0.12.6 -python-dateutil -urllib3 diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 53c23c1..5ec1dfb --- a/setup.py +++ b/setup.py @@ -1,94 +1,5 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- -import codecs -import os -import unittest +import setuptools -from setuptools import setup - -from cryptoparser import __setup__ - - -this_directory = os.getenv('REQUIREMENTS_DIR', '') -with open(os.path.join(this_directory, 'requirements.txt')) as f: - install_requirements = f.read().splitlines() -this_directory = os.path.abspath(os.path.dirname(__file__)) -with codecs.open(os.path.join(this_directory, 'README.rst'), encoding='utf-8') as f: - long_description = f.read() - - -def test_discover(): - test_loader = unittest.TestLoader() - test_suite = test_loader.discover('test', pattern='test_*.py') - return test_suite - - -setup( - name=__setup__.__title__, - version=__setup__.__version__, - description=__setup__.__description__, - long_description=long_description, - long_description_content_type='text/x-rst', - author=__setup__.__author__, - author_email=__setup__.__author_email__, - maintainer=__setup__.__author__, - maintainer_email=__setup__.__author_email__, - license=__setup__.__license__, - license_files=['LICENSE.txt', ], - project_urls={ - 'Homepage': __setup__.__url__, - 'Changelog': 'https://' + __setup__.__technical_name__ + '.readthedocs.io/en/latest/changelog', - 'Documentation': 'https://' + __setup__.__technical_name__ + '.readthedocs.io/en/latest/', - 'Issues': __setup__.__url__ + '/-/issues', - 'Source': __setup__.__url__, - }, - keywords='ssl tls gost ja3 ldap rdp ssh hsts dns', - - install_requires=install_requirements, - extras_require={ - "test": ["coverage", ], - "pep8": ["flake8", ], - "pylint": ["pylint", ], - }, - - packages=[ - 'cryptoparser', - 'cryptoparser.common', - 'cryptoparser.dnsrec', - 'cryptoparser.httpx', - 'cryptoparser.ssh', - 'cryptoparser.tls', - ], - - test_suite='setup.test_discover', - - classifiers=[ - 'Development Status :: 4 - Beta', - 'Environment :: Console', - 'Framework :: tox', - 'Intended Audience :: Developers', - 'Intended Audience :: Information Technology', - 'Intended Audience :: Science/Research', - 'Intended Audience :: System Administrators', - 'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)', - 'Natural Language :: English', - 'Operating System :: MacOS', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Programming Language :: Python :: 3.13', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Programming Language :: Python', - 'Topic :: Internet', - 'Topic :: Security', - 'Topic :: Security :: Cryptography', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Software Development :: Testing :: Traffic Generation', - 'Topic :: Software Development :: Testing', - ], -) +setuptools.setup() diff --git a/submodules/cryptodatahub b/submodules/cryptodatahub index 5fe37d4..075ef48 160000 --- a/submodules/cryptodatahub +++ b/submodules/cryptodatahub @@ -1 +1 @@ -Subproject commit 5fe37d499fd1653d6740ff633c2e0c6cf73c356a +Subproject commit 075ef487638ee10dd80e9e09982343ace0bfa86b diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 925dfea..0000000 --- a/tox.ini +++ /dev/null @@ -1,38 +0,0 @@ -[metadata] -description-file = README.rst - -[tox] -envlist = - py{39,310,311,312,313} - pypy3 - pep8 - pylint - -[testenv] -extras = - test -setenv = - PYTHONPATH = {toxinidir}/submodules/cryptodatahub - REQUIREMENTS_DIR = {toxinidir} -commands = - coverage erase - coverage run -m unittest discover -v - coverage report -deps = - -rrequirements.txt - -rdev-requirements.txt - -[testenv:pep8] -extras = - pep8 -commands = - flake8 {posargs} cryptoparser docs test - -[testenv:pylint] -extras = - pylint -commands = - pylint -j0 -rn --rcfile=.pylintrc cryptoparser docs test - -[flake8] -max-line-length = 120