Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pinned dependency versions #34

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"build": {
"dockerfile": "dev.Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"scheiblingco.code-pypack",
"scheiblingco.code-cmd-repeat"
]
}
}
}
5 changes: 2 additions & 3 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pylint pylint-report pylint-json2html
pip install -r requirements-test.txt

- name: Run tests
run: |
pylint src/sshkey_tools | tee | pylint-json2html -o report.html
python3 -m pylint src/sshkey_tools | tee | pylint_report -o report.html

- name: Upload report
uses: actions/upload-artifact@v1
Expand Down
6 changes: 5 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[MASTER]
load-plugins=pylint_report
extension-pkg-allow-list=cryptography.hazmat.bindings._rust

[REPORTS]
output-format=json
output-format=pylint_report.CustomJsonReporter
25 changes: 25 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
click = ">=7.1"
cryptography = ">=41.0"
bcrypt = ">=4.0"
enum34 = ">=1.1"
prettytable = ">=3.1"
pytimeparse2 = ">=1.4"

[dev-packages]
pylint-report = "*"
paramiko = "*"
coverage = "*"
black = "*"
pytest-cov = "*"
faker = "*"
cprint = "*"
pylint = "*"

[requires]
python_version = "3.9"
772 changes: 772 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM mcr.microsoft.com/devcontainers/universal:2

RUN curl https://pyenv.run | bash \
&& echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc \
&& echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc \
&& echo 'eval "$(pyenv init -)"' >> ~/.bashrc

4 changes: 3 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ coverage
black
pytest-cov
faker
cprint
cprint
pylint
pylint-report
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
click
cryptography
bcrypt
enum34
PrettyTable
pytimeparse2
click>=7.1
cryptography>=41.0
bcrypt>=4.0
enum34>=1.1
PrettyTable>=3.1
pytimeparse2>=1.4
2 changes: 1 addition & 1 deletion src/sshkey_tools/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# The version and build number
# Without specifying a unique number, you cannot overwrite packages in the PyPi repo
__version__ = os.getenv("RELEASE_NAME", "0.9-dev" + os.getenv("GITHUB_RUN_ID", ""))
__version__ = os.getenv("RELEASE_NAME", "0.10.2-dev" + os.getenv("GITHUB_RUN_ID", ""))

# Author and license information
__author__ = "Lars Scheibling"
Expand Down
7 changes: 4 additions & 3 deletions src/sshkey_tools/cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
_EX.NoPrivateKeyException: The certificate contains no private key
_EX.NotSignedException: The certificate is not signed and cannot be exported
"""
import warnings
from base64 import b64decode, b64encode
from dataclasses import dataclass
from typing import Tuple, Union
Expand Down Expand Up @@ -578,11 +577,13 @@ class RsaCertificate(SSHCertificate):

class DsaCertificate(SSHCertificate):
"""The DSA Certificate class (DEPRECATED)"""


# pylint: disable=super-init-not-called
def __init__(self, *args, **kwargs):
"""DEPRECATED CERTIFICATE CLASS"""
raise _EX.DeprecatedClassCalled(
"DSA certificates are deprecated and have been removed since version 0.10 of sshkey-tools"
"DSA certificates are deprecated and have been removed"
"since version 0.10 of sshkey-tools"
)


Expand Down
3 changes: 2 additions & 1 deletion src/sshkey_tools/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class InvalidClassCallException(ValueError):
Raised when trying to instantiate a parent class
"""


class DeprecatedClassCalled(ValueError):
"""
Raised when trying to instantiate a deprecated class
"""
"""
23 changes: 12 additions & 11 deletions src/sshkey_tools/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,10 @@ def parse_string_value(value: str) -> int:
"""
if value == "forever":
return MAX_INT64 - 1

if value == "always":
return 1

return int((datetime.now() + str_to_time_delta(value)).timestamp())

@staticmethod
Expand Down Expand Up @@ -516,7 +516,7 @@ def __validate_value__(self) -> Union[bool, Exception]:
check = self.value
if isinstance(check, str):
check = self.parse_string_value(check)

if isinstance(check, datetime):
check = int(check.timestamp())

Expand Down Expand Up @@ -1071,15 +1071,14 @@ def __validate_value__(self) -> Union[bool, Exception]:
)

super().__validate_value__()

check = self.value
if isinstance(check, str):
check = self.parse_string_value(check)

if isinstance(check, datetime):
check = int(check.timestamp())



if check < int(datetime.now().timestamp()):
return _EX.InvalidCertificateFieldException(
"The certificate validity period is invalid"
Expand Down Expand Up @@ -1479,13 +1478,14 @@ class DsaSignatureField(SignatureField):
Creates and contains the DSA signature from an DSA Private Key
"""

# pylint: disable=super-init-not-called
def __init__(self, *args, **kwargs) -> None:
raise _EX.DeprecatedClassCalled(
"DSA signatures are deprecated and have been removed"
)

@classmethod
def encode(cls, value = None):
def encode(cls, value=None):
"""
Encodes the signature to a byte string

Expand All @@ -1498,13 +1498,14 @@ def encode(cls, value = None):
cls()

@staticmethod
def decode(data = None):
DsaSignatureField()
def decode(data=None):
DsaSignatureField()

@classmethod
def from_decode(cls, data = None):
def from_decode(cls, data=None):
cls()


class EcdsaSignatureField(SignatureField):
"""
Creates and contains the ECDSA signature from an ECDSA Private Key
Expand Down
25 changes: 15 additions & 10 deletions src/sshkey_tools/keys.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Classes for handling SSH public/private keys
"""
import warnings
from base64 import b64decode
from enum import Enum
from struct import unpack
Expand Down Expand Up @@ -594,29 +593,34 @@ class DsaPublicKey(PublicKey):
Class for holding DSA public keys
"""

def __init__(self, key = None, comment = None, key_type = None, serialized = None):
# pylint: disable=super-init-not-called
def __init__(self, key=None, comment=None, key_type=None, serialized=None):
raise _EX.DeprecatedClassCalled(
"SSH DSA keys and certificates are deprecated and are removed since version 0.10 of sshkey-tools",
"SSH DSA keys and certificates are deprecated "
"and are removed since version 0.10 of sshkey-tools",
)

@classmethod
# pylint: disable=invalid-name
# pylint: disable=invalid-name,unused-argument
def from_numbers(cls, p: int, q: int, g: int, y: int) -> "DsaPublicKey":
"""Deprecated"""
return cls()


class DsaPrivateKey(PrivateKey):
"""
Class for holding DSA private keys
"""

def __init__(self, key = None):
# pylint: disable=super-init-not-called
def __init__(self, key=None):
raise _EX.DeprecatedClassCalled(
"SSH DSA keys and certificates are deprecated and are removed since version 0.10 of sshkey-tools",
"SSH DSA keys and certificates are deprecated "
"and are removed since version 0.10 of sshkey-tools",
)

@classmethod
# pylint: disable=invalid-name,too-many-arguments
# pylint: disable=invalid-name,too-many-arguments,unused-argument
def from_numbers(cls, p, q, g, y, x):
"""
Creates a new DsaPrivateKey object from parameters and public/private numbers
Expand All @@ -632,7 +636,7 @@ def from_numbers(cls, p, q, g, y, x):
_type_: _description_
"""
return cls()

@classmethod
def generate(cls) -> "DsaPrivateKey":
"""
Expand All @@ -644,6 +648,7 @@ def generate(cls) -> "DsaPrivateKey":
"""
return cls()


class EcdsaPublicKey(PublicKey):
"""
Class for holding ECDSA public keys
Expand Down