mirror of
https://github.com/jtesta/ssh-audit.git
synced 2024-12-22 05:55:22 +01:00
Improve PyPI packaging (#71)
* Move files for better setup.py packaging * Update setup.py and configs for src layout * Run tests on setup.py build In effect, this tests that the setup.py configuration is correct. coverage combine and coverage:paths are added to keep the displayed coverage paths as src/ssh_audit/*.py instead of .tox/$envname/**/site-packages/ssh_audit/*.py * Remove unnecessary encoding declarations Python 3 defaults to UTF-8 encoding. https://docs.python.org/3/reference/lexical_analysis.html#encoding-declarations * Remove shebang from colorama type stubs Shouldn't need to be an executable. Related: git has this file tracked as chmod -x.
This commit is contained in:
parent
1b0446344c
commit
b15664929f
23
.gitignore
vendored
23
.gitignore
vendored
@ -1,5 +1,5 @@
|
|||||||
*~
|
*~
|
||||||
*.pyc
|
*.py[cod]
|
||||||
*.exe
|
*.exe
|
||||||
*.asc
|
*.asc
|
||||||
venv*/
|
venv*/
|
||||||
@ -9,11 +9,16 @@ venv*/
|
|||||||
.coverage*
|
.coverage*
|
||||||
reports/
|
reports/
|
||||||
.scannerwork/
|
.scannerwork/
|
||||||
packages/sshaudit/LICENSE
|
|
||||||
packages/sshaudit/README.md
|
# PyPI packaging
|
||||||
packages/sshaudit/sshaudit.py
|
/build/
|
||||||
packages/parts/
|
/dist/
|
||||||
packages/prime/
|
*.egg-info/
|
||||||
packages/snap/
|
*.egg
|
||||||
packages/stage/
|
|
||||||
packages/ssh-audit_*.snap
|
# Snap packaging
|
||||||
|
/parts/
|
||||||
|
/prime/
|
||||||
|
/snap/
|
||||||
|
/stage/
|
||||||
|
/ssh-audit_*.snap
|
||||||
|
11
Makefile.pypi
Normal file
11
Makefile.pypi
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
all:
|
||||||
|
python3 setup.py sdist bdist_wheel
|
||||||
|
|
||||||
|
uploadtest:
|
||||||
|
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
|
||||||
|
|
||||||
|
uploadprod:
|
||||||
|
twine upload dist/*
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf build/ dist/ src/*.egg-info/
|
@ -7,7 +7,7 @@ $ virtualenv -p /usr/bin/python3 /tmp/pypi_upload
|
|||||||
$ cd /tmp/pypi_upload; source bin/activate
|
$ cd /tmp/pypi_upload; source bin/activate
|
||||||
$ pip3 install twine
|
$ pip3 install twine
|
||||||
$ cp -R path/to/ssh-audit .
|
$ cp -R path/to/ssh-audit .
|
||||||
$ cd ssh-audit/packages
|
$ cd ssh-audit
|
||||||
$ make -f Makefile.pypi
|
$ make -f Makefile.pypi
|
||||||
$ make -f Makefile.pypi uploadtest
|
$ make -f Makefile.pypi uploadtest
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ $ pip3 install --index-url https://test.pypi.org/simple ssh-audit
|
|||||||
To upload to production server:
|
To upload to production server:
|
||||||
|
|
||||||
$ cd /tmp/pypi_upload; source bin/activate
|
$ cd /tmp/pypi_upload; source bin/activate
|
||||||
$ cd ssh-audit/pypi
|
$ cd ssh-audit
|
||||||
$ make -f Makefile.pypi uploadprod
|
$ make -f Makefile.pypi uploadprod
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
include sshaudit/LICENSE
|
|
@ -1,14 +0,0 @@
|
|||||||
all:
|
|
||||||
cp ../ssh-audit.py sshaudit/sshaudit.py
|
|
||||||
cp ../LICENSE sshaudit/LICENSE
|
|
||||||
cp ../README.md sshaudit/README.md
|
|
||||||
python3 setup.py sdist bdist_wheel
|
|
||||||
|
|
||||||
uploadtest:
|
|
||||||
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
|
|
||||||
|
|
||||||
uploadprod:
|
|
||||||
twine upload dist/*
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf parts/ prime/ snap/ stage/ build/ dist/ *.egg-info/ sshaudit/sshaudit.py sshaudit/LICENSE sshaudit/README.md ssh-audit*.snap
|
|
@ -1,58 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
from setuptools import setup
|
|
||||||
|
|
||||||
print_warning = False
|
|
||||||
m = re.search(r'^VERSION\s*=\s*\'v(\d\.\d\.\d)\'', open('sshaudit/sshaudit.py').read(), re.M)
|
|
||||||
if m is None:
|
|
||||||
# If we failed to parse the stable version, see if this is the development version.
|
|
||||||
m = re.search(r'^VERSION\s*=\s*\'v(\d\.\d\.\d-dev)\'', open('sshaudit/sshaudit.py').read(), re.M)
|
|
||||||
if m is None:
|
|
||||||
print("Error: could not parse VERSION variable from ssh-audit.py.")
|
|
||||||
sys.exit(1)
|
|
||||||
else: # Continue with the development version, but print a warning later.
|
|
||||||
print_warning = True
|
|
||||||
|
|
||||||
version = m.group(1)
|
|
||||||
print("\n\nPackaging ssh-audit v%s...\n\n" % version)
|
|
||||||
|
|
||||||
with open("sshaudit/README.md", "rb") as f:
|
|
||||||
long_descr = f.read().decode("utf-8")
|
|
||||||
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name="ssh-audit",
|
|
||||||
packages=["sshaudit"],
|
|
||||||
license='MIT',
|
|
||||||
entry_points={
|
|
||||||
"console_scripts": ['ssh-audit = sshaudit.sshaudit:main']
|
|
||||||
},
|
|
||||||
version=version,
|
|
||||||
description="An SSH server & client configuration security auditing tool",
|
|
||||||
long_description=long_descr,
|
|
||||||
long_description_content_type="text/markdown",
|
|
||||||
author="Joe Testa",
|
|
||||||
author_email="jtesta@positronsecurity.com",
|
|
||||||
url="https://github.com/jtesta/ssh-audit",
|
|
||||||
classifiers=[
|
|
||||||
"Development Status :: 5 - Production/Stable",
|
|
||||||
"Intended Audience :: Information Technology",
|
|
||||||
"Intended Audience :: System Administrators",
|
|
||||||
"License :: OSI Approved :: MIT License",
|
|
||||||
"Operating System :: OS Independent",
|
|
||||||
"Programming Language :: Python :: 3",
|
|
||||||
"Programming Language :: Python :: 3.5",
|
|
||||||
"Programming Language :: Python :: 3.6",
|
|
||||||
"Programming Language :: Python :: 3.7",
|
|
||||||
"Programming Language :: Python :: 3.8",
|
|
||||||
"Programming Language :: Python :: Implementation :: CPython",
|
|
||||||
"Programming Language :: Python :: Implementation :: PyPy",
|
|
||||||
"Topic :: Security",
|
|
||||||
"Topic :: Security :: Cryptography"
|
|
||||||
])
|
|
||||||
|
|
||||||
if print_warning:
|
|
||||||
print("\n\n !!! WARNING: development version detected (%s). Are you sure you want to package this version? Probably not...\n" % version)
|
|
@ -1,4 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from .sshaudit import main
|
|
||||||
main()
|
|
7
pyproject.toml
Normal file
7
pyproject.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[build-system]
|
||||||
|
# https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
|
||||||
|
requires = [
|
||||||
|
"setuptools>=40.8.0",
|
||||||
|
"wheel"
|
||||||
|
]
|
||||||
|
build-backend = "setuptools.build_meta"
|
44
setup.cfg
Normal file
44
setup.cfg
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
[metadata]
|
||||||
|
name = ssh-audit
|
||||||
|
version = attr: ssh_audit.ssh_audit.VERSION
|
||||||
|
author = Joe Testa
|
||||||
|
author_email = jtesta@positronsecurity.com
|
||||||
|
description = An SSH server & client configuration security auditing tool
|
||||||
|
long_description = file: README.md
|
||||||
|
long_description_content_type = text/markdown
|
||||||
|
license_file = LICENSE
|
||||||
|
url = https://github.com/jtesta/ssh-audit
|
||||||
|
project_urls =
|
||||||
|
Source Code = https://github.com/jtesta/ssh-audit
|
||||||
|
Bug Tracker = https://github.com/jtesta/ssh-audit/issues
|
||||||
|
classifiers =
|
||||||
|
Development Status :: 5 - Production/Stable
|
||||||
|
Intended Audience :: Information Technology
|
||||||
|
Intended Audience :: System Administrators
|
||||||
|
License :: OSI Approved :: MIT License
|
||||||
|
Operating System :: OS Independent
|
||||||
|
Programming Language :: Python :: 3
|
||||||
|
Programming Language :: Python :: 3.5
|
||||||
|
Programming Language :: Python :: 3.6
|
||||||
|
Programming Language :: Python :: 3.7
|
||||||
|
Programming Language :: Python :: 3.8
|
||||||
|
Programming Language :: Python :: Implementation :: CPython
|
||||||
|
Programming Language :: Python :: Implementation :: PyPy
|
||||||
|
Topic :: Security
|
||||||
|
Topic :: Security :: Cryptography
|
||||||
|
|
||||||
|
[options]
|
||||||
|
packages = find:
|
||||||
|
package_dir =
|
||||||
|
= src
|
||||||
|
python_requires = >=3.5,<4
|
||||||
|
|
||||||
|
[options.packages.find]
|
||||||
|
where = src
|
||||||
|
|
||||||
|
[options.package_data]
|
||||||
|
ssh_audit = policies/*
|
||||||
|
|
||||||
|
[options.entry_points]
|
||||||
|
console_scripts =
|
||||||
|
ssh-audit = ssh_audit.ssh_audit:main
|
23
setup.py
Normal file
23
setup.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
print_warning = False
|
||||||
|
m = re.search(r'^VERSION\s*=\s*\'v(\d\.\d\.\d)\'', open('src/ssh_audit/ssh_audit.py').read(), re.M)
|
||||||
|
if m is None:
|
||||||
|
# If we failed to parse the stable version, see if this is the development version.
|
||||||
|
m = re.search(r'^VERSION\s*=\s*\'v(\d\.\d\.\d-dev)\'', open('src/ssh_audit/ssh_audit.py').read(), re.M)
|
||||||
|
if m is None:
|
||||||
|
print("Error: could not parse VERSION variable from ssh_audit.py.")
|
||||||
|
sys.exit(1)
|
||||||
|
else: # Continue with the development version, but print a warning later.
|
||||||
|
print_warning = True
|
||||||
|
|
||||||
|
version = m.group(1)
|
||||||
|
print("\n\nPackaging ssh-audit v%s...\n\n" % version)
|
||||||
|
|
||||||
|
# see setup.cfg
|
||||||
|
setup()
|
||||||
|
|
||||||
|
if print_warning:
|
||||||
|
print("\n\n !!! WARNING: development version detected (%s). Are you sure you want to package this version? Probably not...\n" % version)
|
2
src/ssh_audit/__main__.py
Normal file
2
src/ssh_audit/__main__.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
from ssh_audit.ssh_audit import main
|
||||||
|
main()
|
3912
src/ssh_audit/ssh_audit.py
Executable file
3912
src/ssh_audit/ssh_audit.py
Executable file
File diff suppressed because it is too large
Load Diff
3911
ssh-audit.py
3911
ssh-audit.py
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,3 @@
|
|||||||
import os
|
|
||||||
import io
|
import io
|
||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
@ -7,9 +6,8 @@ import pytest
|
|||||||
|
|
||||||
@pytest.fixture(scope='module')
|
@pytest.fixture(scope='module')
|
||||||
def ssh_audit():
|
def ssh_audit():
|
||||||
__rdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')
|
import ssh_audit.ssh_audit
|
||||||
sys.path.append(os.path.abspath(__rdir))
|
return ssh_audit.ssh_audit
|
||||||
return __import__('ssh-audit')
|
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=attribute-defined-outside-init
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
def init(autoreset: bool = False, convert: Optional[bool] = None, strip: Optional[bool] = None, wrap: bool = True) -> None: ...
|
def init(autoreset: bool = False, convert: Optional[bool] = None, strip: Optional[bool] = None, wrap: bool = True) -> None: ...
|
||||||
|
13
tox.ini
13
tox.ini
@ -3,7 +3,6 @@ envlist =
|
|||||||
py{py3}-{test,pylint,flake8,vulture}
|
py{py3}-{test,pylint,flake8,vulture}
|
||||||
py{35,36,37,38}-{test,mypy,pylint,flake8,vulture}
|
py{35,36,37,38}-{test,mypy,pylint,flake8,vulture}
|
||||||
cov
|
cov
|
||||||
skipsdist = true
|
|
||||||
skip_missing_interpreters = true
|
skip_missing_interpreters = true
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
@ -16,13 +15,14 @@ deps =
|
|||||||
py{py3,35,36,37,38}-{lint,flake8},lint: {[testenv:flake8]deps}
|
py{py3,35,36,37,38}-{lint,flake8},lint: {[testenv:flake8]deps}
|
||||||
py{py3,35,36,37,38}-{lint,vulture},lint: {[testenv:vulture]deps}
|
py{py3,35,36,37,38}-{lint,vulture},lint: {[testenv:vulture]deps}
|
||||||
setenv =
|
setenv =
|
||||||
SSHAUDIT = {toxinidir}/ssh-audit.py
|
SSHAUDIT = {toxinidir}/src
|
||||||
test: COVERAGE_FILE = {toxinidir}/.coverage.{envname}
|
test: COVERAGE_FILE = {toxinidir}/.coverage.{envname}
|
||||||
type,mypy: MYPYPATH = {toxinidir}/test/stubs
|
type,mypy: MYPYPATH = {toxinidir}/test/stubs
|
||||||
type,mypy: MYPYHTML = {toxinidir}/reports/html/mypy
|
type,mypy: MYPYHTML = {toxinidir}/reports/html/mypy
|
||||||
commands =
|
commands =
|
||||||
test: coverage run --source ssh-audit -m -- \
|
test: coverage run --source ssh_audit -m -p -- \
|
||||||
test: pytest -v --junitxml={toxinidir}/reports/junit.{envname}.xml {posargs:test}
|
test: pytest -v --junitxml={toxinidir}/reports/junit.{envname}.xml {posargs:test}
|
||||||
|
test: coverage combine
|
||||||
test: coverage report --show-missing
|
test: coverage report --show-missing
|
||||||
test: coverage html -d {toxinidir}/reports/html/coverage.{envname}
|
test: coverage html -d {toxinidir}/reports/html/coverage.{envname}
|
||||||
py{35,36,37,38}-{type,mypy}: {[testenv:mypy]commands}
|
py{35,36,37,38}-{type,mypy}: {[testenv:mypy]commands}
|
||||||
@ -73,7 +73,7 @@ commands =
|
|||||||
deps =
|
deps =
|
||||||
flake8
|
flake8
|
||||||
commands =
|
commands =
|
||||||
flake8 {posargs:{env:SSHAUDIT} {toxinidir}/packages/setup.py {toxinidir}/test} --statistics
|
flake8 {posargs:{env:SSHAUDIT} {toxinidir}/setup.py {toxinidir}/test {toxinidir}/ssh-audit.py} --statistics
|
||||||
|
|
||||||
[testenv:vulture]
|
[testenv:vulture]
|
||||||
deps =
|
deps =
|
||||||
@ -131,3 +131,8 @@ ignore =
|
|||||||
|
|
||||||
[pytest]
|
[pytest]
|
||||||
junit_family = xunit1
|
junit_family = xunit1
|
||||||
|
|
||||||
|
[coverage:paths]
|
||||||
|
source =
|
||||||
|
src
|
||||||
|
*/site-packages
|
||||||
|
@ -12,7 +12,9 @@ On a Windows machine, do the following:
|
|||||||
|
|
||||||
3.) Create the executable with:
|
3.) Create the executable with:
|
||||||
|
|
||||||
pyinstaller -D --icon packages\windows_icon.ico --add-data policies;policies ssh-audit.py
|
cd src\ssh_audit
|
||||||
|
rename ssh_audit.py ssh-audit.py
|
||||||
|
pyinstaller -D --icon ..\..\windows_icon.ico --add-data policies;policies ssh-audit.py
|
||||||
|
|
||||||
4.) Rename the "dist\ssh-audit\" folder to "dist\ssh-audit vX.X.X\"
|
4.) Rename the "dist\ssh-audit\" folder to "dist\ssh-audit vX.X.X\"
|
||||||
|
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Loading…
Reference in New Issue
Block a user