mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-07 05:43: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:
@@ -328,12 +328,12 @@ def format_cert(cert: Certificate) -> str:
|
||||
def check_cycle(
|
||||
module: AnsibleModule,
|
||||
occured_certificates: set[cryptography.x509.Certificate],
|
||||
next: Certificate,
|
||||
next_certificate: Certificate,
|
||||
) -> None:
|
||||
"""
|
||||
Make sure that next is not in occured_certificates so far, and add it.
|
||||
Make sure that next_certificate is not in occured_certificates so far, and add it.
|
||||
"""
|
||||
next_cert = next.cert
|
||||
next_cert = next_certificate.cert
|
||||
if next_cert in occured_certificates:
|
||||
module.fail_json(msg="Found cycle while building certificate chain")
|
||||
occured_certificates.add(next_cert)
|
||||
@@ -341,11 +341,15 @@ def check_cycle(
|
||||
|
||||
def main() -> t.NoReturn:
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
input_chain=dict(type="str", required=True),
|
||||
root_certificates=dict(type="list", required=True, elements="path"),
|
||||
intermediate_certificates=dict(type="list", default=[], elements="path"),
|
||||
),
|
||||
argument_spec={
|
||||
"input_chain": {"type": "str", "required": True},
|
||||
"root_certificates": {"type": "list", "required": True, "elements": "path"},
|
||||
"intermediate_certificates": {
|
||||
"type": "list",
|
||||
"default": [],
|
||||
"elements": "path",
|
||||
},
|
||||
},
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
@@ -382,7 +386,7 @@ def main() -> t.NoReturn:
|
||||
# Try to complete chain
|
||||
current: Certificate | None = chain[-1]
|
||||
completed = []
|
||||
occured_certificates = set([cert.cert for cert in chain])
|
||||
occured_certificates = {cert.cert for cert in chain}
|
||||
if current and current.cert in roots.certificate_by_cert:
|
||||
# Do not try to complete the chain when it is already ending with a root certificate
|
||||
current = None
|
||||
|
||||
Reference in New Issue
Block a user