mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-07 13:53:06 +00:00
Work on issues found by pylint (#896)
* Look at possibly-used-before-assignment. * Use latest beta releases of ansible-core 2.19 for mypy and pylint. * Look at unsupported-*. * Look at unknown-option-value. * Look at redefined-builtin. * Look at superfluous-parens. * Look at unspecified-encoding. * Adjust to new cryptography version and to ansible-core 2.17's pylint. * Look at super-with-arguments. * Look at no-else-*. * Look at try-except-raise. * Look at inconsistent-return-statements. * Look at redefined-outer-name. * Look at redefined-argument-from-local. * Look at attribute-defined-outside-init. * Look at unused-variable. * Look at protected-access. * Look at raise-missing-from. * Look at arguments-differ. * Look at useless-suppression and use-symbolic-message-instead. * Look at consider-using-dict-items. * Look at consider-using-in. * Look at consider-using-set-comprehension. * Look at consider-using-with. * Look at use-dict-literal.
This commit is contained in:
@@ -67,18 +67,18 @@ class CRLInfoRetrieval:
|
||||
self.name_encoding = module.params.get("name_encoding", "ignore")
|
||||
|
||||
def get_info(self) -> dict[str, t.Any]:
|
||||
self.crl_pem = identify_pem_format(self.content)
|
||||
crl_pem = identify_pem_format(self.content)
|
||||
try:
|
||||
if self.crl_pem:
|
||||
self.crl = x509.load_pem_x509_crl(self.content)
|
||||
if crl_pem:
|
||||
crl = x509.load_pem_x509_crl(self.content)
|
||||
else:
|
||||
self.crl = x509.load_der_x509_crl(self.content)
|
||||
crl = x509.load_der_x509_crl(self.content)
|
||||
except ValueError as e:
|
||||
self.module.fail_json(msg=f"Error while decoding CRL: {e}")
|
||||
|
||||
result: dict[str, t.Any] = {
|
||||
"changed": False,
|
||||
"format": "pem" if self.crl_pem else "der",
|
||||
"format": "pem" if crl_pem else "der",
|
||||
"last_update": None,
|
||||
"next_update": None,
|
||||
"digest": None,
|
||||
@@ -86,25 +86,24 @@ class CRLInfoRetrieval:
|
||||
"issuer": None,
|
||||
}
|
||||
|
||||
result["last_update"] = self.crl.last_update.strftime(TIMESTAMP_FORMAT)
|
||||
result["last_update"] = crl.last_update.strftime(TIMESTAMP_FORMAT)
|
||||
result["next_update"] = (
|
||||
self.crl.next_update.strftime(TIMESTAMP_FORMAT)
|
||||
if self.crl.next_update
|
||||
else None
|
||||
crl.next_update.strftime(TIMESTAMP_FORMAT) if crl.next_update else None
|
||||
)
|
||||
result["digest"] = cryptography_oid_to_name(
|
||||
cryptography_get_signature_algorithm_oid_from_crl(self.crl)
|
||||
cryptography_get_signature_algorithm_oid_from_crl(crl)
|
||||
)
|
||||
issuer = []
|
||||
for attribute in self.crl.issuer:
|
||||
for attribute in crl.issuer:
|
||||
issuer.append([cryptography_oid_to_name(attribute.oid), attribute.value])
|
||||
result["issuer_ordered"] = issuer
|
||||
result["issuer"] = {}
|
||||
issuer_dict = {}
|
||||
for k, v in issuer:
|
||||
result["issuer"][k] = v
|
||||
issuer_dict[k] = v
|
||||
result["issuer"] = issuer_dict
|
||||
if self.list_revoked_certificates:
|
||||
result["revoked_certificates"] = []
|
||||
for cert in self.crl:
|
||||
for cert in crl:
|
||||
entry = cryptography_decode_revoked_certificate(cert)
|
||||
result["revoked_certificates"].append(
|
||||
cryptography_dump_revoked(entry, idn_rewrite=self.name_encoding)
|
||||
|
||||
Reference in New Issue
Block a user