From ad699a927aa2ffd8760ea86aebe715e5da5e2fad Mon Sep 17 00:00:00 2001 From: Julian Rother <julian@jrother.eu> Date: Wed, 28 Jul 2021 21:40:05 +0200 Subject: [PATCH] Fixed last remaining linter errors --- .gitlab-ci.yml | 6 +++--- ldapserver/dn.py | 1 - ldapserver/ldap.py | 12 +++++++----- ldapserver/server.py | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dcc97c3..9504898 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,9 +3,9 @@ linter: image: python:3.7 script: - pip install pylint-gitlab - - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabCodeClimateReporter ldapserver > codeclimate.json || true - - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabPagesHtmlReporter ldapserver > pylint.html || true - - python3 -m pylint --rcfile .pylintrc --output-format=text ldapserver || true + - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabCodeClimateReporter ldapserver > codeclimate.json + - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabPagesHtmlReporter ldapserver > pylint.html + - python3 -m pylint --rcfile .pylintrc --output-format=text ldapserver artifacts: when: always paths: diff --git a/ldapserver/dn.py b/ldapserver/dn.py index 690fa32..0ede9a1 100644 --- a/ldapserver/dn.py +++ b/ldapserver/dn.py @@ -39,7 +39,6 @@ def parse_assertion(expr, case_ignore_attrs=None): value = tokens[1] if not name or not value: raise ValueError('Invalid assertion in RDN: "%s"'%expr) - # TODO: handle hex strings if name in case_ignore_attrs: value = value.lower() return (name, value) diff --git a/ldapserver/ldap.py b/ldapserver/ldap.py index a1c9f51..9a1e24d 100644 --- a/ldapserver/ldap.py +++ b/ldapserver/ldap.py @@ -1,6 +1,3 @@ -# Enums/constants/attributes are mostly named after RFCs -# No-members is raised for all the dynamically populated attributes -# pylint: disable=invalid-name import typing from abc import ABC, abstractmethod import enum @@ -31,10 +28,10 @@ class AttributeValueAssertion(asn1.Sequence): attributeDesc: str assertionValue: bytes -def escape_filter_assertionvalue(s): +def escape_filter_assertionvalue(value): allowed_bytes = b'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'+,-./:;<=>?@[\\]^_`{|}~ ' res = [] - for byte in s: + for byte in value: if byte not in allowed_bytes: res += b'\\%02X'%byte else: @@ -192,6 +189,7 @@ class FilterExtensibleMatch(asn1.Sequence, Filter): class SearchScope(enum.Enum): ''':any:`enum.Enum` of `scope` values in SEARCH operations''' + # pylint: disable=invalid-name #: Search is constrained to the base object baseObject = 0 #: Search is constrained to the immediate subordinates of the base object @@ -200,12 +198,14 @@ class SearchScope(enum.Enum): wholeSubtree = 2 class DerefAliases(enum.Enum): + # pylint: disable=invalid-name neverDerefAliases = 0 derefInSearching = 1 derefFindingBaseObj = 2 derefAlways = 3 class LDAPResultCode(enum.Enum): + # pylint: disable=invalid-name success = 0 operationsError = 1 protocolError = 2 @@ -360,6 +360,7 @@ class SearchResultDone(LDAPResult, ProtocolOp): BER_TAG = (1, True, 5) class ModifyOperation(enum.Enum): + # pylint: disable=invalid-name add = 0 delete = 1 replace = 2 @@ -474,6 +475,7 @@ class LDAPMessage(asn1.Sequence): class ShallowLDAPMessage(asn1.BERType): BER_TAG = (0, True, 16) + # pylint: disable=invalid-name def __init__(self, messageID=None, protocolOpType=None, data=None): self.messageID = messageID diff --git a/ldapserver/server.py b/ldapserver/server.py index afe2687..e59ef2c 100644 --- a/ldapserver/server.py +++ b/ldapserver/server.py @@ -227,7 +227,7 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): self.bind_sasl_state = (mechanism, iterator) except StopIteration as e: resp_code = ldap.LDAPResultCode.success - self.bind_object, resp = e.value + self.bind_object, resp = e.value # pylint: disable=unpacking-non-sequence yield ldap.BindResponse(resp_code, serverSaslCreds=resp) return # If auth type or SASL method changed, abort SASL dialog @@ -248,7 +248,7 @@ class SimpleLDAPRequestHandler(BaseLDAPRequestHandler): self.bind_sasl_state = (auth.mechanism, iterator) except StopIteration as e: resp_code = ldap.LDAPResultCode.success - self.bind_object, resp = e.value + self.bind_object, resp = e.value # pylint: disable=unpacking-non-sequence yield ldap.BindResponse(resp_code, serverSaslCreds=resp) else: yield from super().handle_bind(op, controls) -- GitLab