Skip to content

Commit

Permalink
Updating python code to best practices.
Browse files Browse the repository at this point in the history
  • Loading branch information
Git committed Jan 7, 2024
1 parent ad2bcd1 commit 605e4b7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions certificate/CertificateDecoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from cryptography.hazmat.backends import default_backend
from typing import Tuple, Optional, Union


class CertificateDecoder:
def __init__(self):
self.CLASS_VERSION = "0.01"
CLASS_VERSION = "0.01"

def decode(self, der_cert_bytes: bytes) -> dict:
cert = x509.load_der_x509_certificate(der_cert_bytes, default_backend())
Expand All @@ -24,7 +24,7 @@ def decode(self, der_cert_bytes: bytes) -> dict:
def _parse_name(self, name: x509.Name) -> Tuple[Tuple[Tuple[str, str], ...], ...]:
return tuple(
tuple((attr.oid._name, attr.value) for attr in rdn)
for rdn in name.rdns # Use .rdns to iterate over RDNs in the Name
for rdn in name.rdns # Use .rdns to iterate over RDNs in the Name
)

def _get_extension_value(self, cert: x509.Certificate, ext_type, method: Optional[str] = None) -> Union[Tuple[str, ...], None]:
Expand Down
1 change: 1 addition & 0 deletions certificate/CertificateStatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from . import CertificateTimeFormat


class CertificateStatistics:
"""This class is responsible for helping with calculations of meta data."""
CLASS_VERSION = "0.01"
Expand Down
1 change: 1 addition & 0 deletions certificate/DisplayCertificate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
from . import CertificateStatistics


class DisplayCertificate:
"""This class is responsible for displaying the certificate Meta Data."""
CLASS_VERSION = "0.01"
Expand Down
2 changes: 2 additions & 0 deletions certificate/FileOperations.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import os
from typing import Union


class FileOperations:
"""
A class to write the contents of a variable to a file in binary form.

Attributes:
file_path (str): The path to the file where the binary data will be written.
"""
CLASS_VERSION = "0.01"

def __init__(self, file_path: str):
"""
Expand Down
2 changes: 1 addition & 1 deletion certificate/certificateModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def getCertificate(self, __hostinfo: dict) -> dict:

# Check to see if unsafe_legacy is defined
if self.contextVariables.get("unsafe_legacy") == 1:
__ctx.options |= 0x4 # OP_LEGACY_SERVER_CONNECT
__ctx.options |= 0x4 # OP_LEGACY_SERVER_CONNECT

else:
__ctx.check_hostname = False
Expand Down
1 change: 1 addition & 0 deletions mongo/mongo_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from . import mongo_data
from . import MongoDBKeyTransformer


class mongo_connection:
"""mongo_connection class"""

Expand Down

0 comments on commit 605e4b7

Please sign in to comment.