The following issues were found

acme/tests/magic_typing_test.py
4 issues
Unable to import 'acme.magic_typing'
Error

Line: 23 Column: 13

                          del sys.modules['acme.magic_typing']  # pragma: no cover
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            from acme.magic_typing import Text
        self.assertEqual(Text, text_mock)
        del sys.modules['acme.magic_typing']
        sys.modules['typing'] = temp_typing



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 5

              
class MagicTypingTest(unittest.TestCase):
    """Tests for acme.magic_typing."""
    def test_import_success(self):
        try:
            import typing as temp_typing
        except ImportError:  # pragma: no cover
            temp_typing = None  # pragma: no cover
        typing_class_mock = mock.MagicMock()

            

Reported by Pylint.

Import outside toplevel (typing)
Error

Line: 12 Column: 13

                  """Tests for acme.magic_typing."""
    def test_import_success(self):
        try:
            import typing as temp_typing
        except ImportError:  # pragma: no cover
            temp_typing = None  # pragma: no cover
        typing_class_mock = mock.MagicMock()
        text_mock = mock.MagicMock()
        typing_class_mock.Text = text_mock

            

Reported by Pylint.

Import outside toplevel (acme.magic_typing.Text)
Error

Line: 23 Column: 13

                          del sys.modules['acme.magic_typing']  # pragma: no cover
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            from acme.magic_typing import Text
        self.assertEqual(Text, text_mock)
        del sys.modules['acme.magic_typing']
        sys.modules['typing'] = temp_typing



            

Reported by Pylint.

certbot-ci/certbot_integration_tests/nginx_tests/test_main.py
4 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              import ssl
from typing import List

import pytest

from certbot_integration_tests.nginx_tests import context as nginx_context


@pytest.fixture(name='context')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 1

              

@pytest.fixture(name='context')
def test_context(request):
    # Fixture request is a built-in pytest fixture describing current test request.
    integration_test_context = nginx_context.IntegrationTestsContext(request)
    try:
        yield integration_test_context
    finally:

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 52
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  ) as file:
        certbot_cert = file.read()

    assert server_cert == certbot_cert

    context.certbot_test_nginx(['rollback', '--checkpoints', '1'])

    with open(context.nginx_config_path, 'r') as file_h:
        current_nginx_config = file_h.read()

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 59
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  with open(context.nginx_config_path, 'r') as file_h:
        current_nginx_config = file_h.read()

    assert context.nginx_config == current_nginx_config

            

Reported by Bandit.

certbot-ci/certbot_integration_tests/rfc2136_tests/context.py
3 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              import tempfile

from pkg_resources import resource_filename
from pytest import skip

from certbot_integration_tests.certbot_tests import context as certbot_context
from certbot_integration_tests.utils import certbot_call



            

Reported by Pylint.

Variable name "f" doesn't conform to snake_case naming style
Error

Line: 48 Column: 37

                                                   'assets/bind-config/rfc2136-credentials-{}.ini.tpl'
                                     .format(label))

        with open(src_file, 'r') as f:
            contents = f.read().format(
                server_address=self._dns_xdist['address'],
                server_port=self._dns_xdist['port']
            )


            

Reported by Pylint.

Variable name "fp" doesn't conform to snake_case naming style
Error

Line: 55 Column: 80

                          )

        with tempfile.NamedTemporaryFile('w+', prefix='rfc2136-creds-{}'.format(label),
                                         suffix='.ini', dir=self.workspace) as fp:
            fp.write(contents)
            fp.flush()
            yield fp.name

    def skip_if_no_bind9_server(self):

            

Reported by Pylint.

certbot-compatibility-test/certbot_compatibility_test/util.py
3 issues
Unable to import 'josepy'
Error

Line: 9 Column: 1

              import shutil
import tarfile

import josepy as jose

from certbot._internal import constants
from certbot.tests import util as test_util
from certbot_compatibility_test import errors


            

Reported by Pylint.

Unable to import 'certbot._internal'
Error

Line: 11 Column: 1

              
import josepy as jose

from certbot._internal import constants
from certbot.tests import util as test_util
from certbot_compatibility_test import errors

_KEY_BASE = "rsa2048_key.pem"
KEY_PATH = test_util.vector_path(_KEY_BASE)

            

Reported by Pylint.

Unable to import 'certbot.tests'
Error

Line: 12 Column: 1

              import josepy as jose

from certbot._internal import constants
from certbot.tests import util as test_util
from certbot_compatibility_test import errors

_KEY_BASE = "rsa2048_key.pem"
KEY_PATH = test_util.vector_path(_KEY_BASE)
KEY = test_util.load_pyopenssl_private_key(_KEY_BASE)

            

Reported by Pylint.

certbot-ci/windows_installer_integration_tests/conftest.py
3 issues
Line too long (112/100)
Error

Line: 24 Column: 1

                                   default=os.path.join(ROOT_PATH, 'windows-installer', 'build',
                                          'nsis', 'certbot-beta-installer-win32.exe'),
                     help='set the path of the windows installer to use, default to '
                          'CERTBOT_ROOT_PATH\\windows-installer\\build\\nsis\\certbot-beta-installer-win32.exe')
    parser.addoption('--allow-persistent-changes', action='store_true',
                     help='needs to be set, and confirm that the test will make persistent changes on this machine')


def pytest_configure(config):

            

Reported by Pylint.

Line too long (116/100)
Error

Line: 26 Column: 1

                                   help='set the path of the windows installer to use, default to '
                          'CERTBOT_ROOT_PATH\\windows-installer\\build\\nsis\\certbot-beta-installer-win32.exe')
    parser.addoption('--allow-persistent-changes', action='store_true',
                     help='needs to be set, and confirm that the test will make persistent changes on this machine')


def pytest_configure(config):
    """
    Standard pytest hook used to add a configuration logic for each node of a pytest run.

            

Reported by Pylint.

Line too long (112/100)
Error

Line: 36 Column: 1

                  """
    if not config.option.allow_persistent_changes:
        raise RuntimeError('This integration test would install Certbot on your machine. '
                           'Please run it again with the `--allow-persistent-changes` flag set to acknowledge.')

            

Reported by Pylint.

certbot-ci/snap_integration_tests/conftest.py
3 issues
Line too long (116/100)
Error

Line: 23 Column: 1

                  parser.addoption('--snap-arch', default='amd64',
                    help='set the architecture do test (default: amd64)')
    parser.addoption('--allow-persistent-changes', action='store_true',
                     help='needs to be set, and confirm that the test will make persistent changes on this machine')


def pytest_configure(config):
    """
    Standard pytest hook used to add a configuration logic for each node of a pytest run.

            

Reported by Pylint.

Line too long (112/100)
Error

Line: 33 Column: 1

                  """
    if not config.option.allow_persistent_changes:
        raise RuntimeError('This integration test would install the Certbot snap on your machine. '
                           'Please run it again with the `--allow-persistent-changes` flag set to acknowledge.')


def pytest_generate_tests(metafunc):
    """
    Generate (multiple) parametrized calls to a test function.

            

Reported by Pylint.

Trailing whitespace
Error

Line: 43 Column: 65

                  if "dns_snap_path" in metafunc.fixturenames:
        snap_arch = metafunc.config.getoption('snap_arch')
        snap_folder = metafunc.config.getoption('snap_folder')
        snap_dns_path_list = glob.glob(os.path.join(snap_folder, 
                                                    'certbot-dns-*_{0}.snap'.format(snap_arch)))
        metafunc.parametrize("dns_snap_path", snap_dns_path_list)

            

Reported by Pylint.

certbot-ci/setup.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              from distutils.version import LooseVersion

from setuptools import __version__ as setuptools_version
from setuptools import find_packages
from setuptools import setup

version = '0.32.0.dev0'

# setuptools 36.2+ is needed for support for environment markers

            

Reported by Pylint.

Constant name "version" doesn't conform to UPPER_CASE naming style
Error

Line: 7 Column: 1

              from setuptools import find_packages
from setuptools import setup

version = '0.32.0.dev0'

# setuptools 36.2+ is needed for support for environment markers
min_setuptools_version='36.2'
# This conditional isn't necessary, but it provides better error messages to
# people who try to install this package with older versions of setuptools.

            

Reported by Pylint.

Constant name "min_setuptools_version" doesn't conform to UPPER_CASE naming style
Error

Line: 10 Column: 1

              version = '0.32.0.dev0'

# setuptools 36.2+ is needed for support for environment markers
min_setuptools_version='36.2'
# This conditional isn't necessary, but it provides better error messages to
# people who try to install this package with older versions of setuptools.
if LooseVersion(setuptools_version) < LooseVersion(min_setuptools_version):
    raise RuntimeError(f'setuptools {min_setuptools_version}+ is required')


            

Reported by Pylint.

certbot-apache/tests/parsernode_configurator_test.py
3 issues
Unused import apacheconfig
Error

Line: 12 Column: 5

              import util

try:
    import apacheconfig
    HAS_APACHECONFIG = True
except ImportError:  # pragma: no cover
    HAS_APACHECONFIG = False



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 5

                      self.vh_truth = util.get_vh_truth(
            self.temp_dir, "debian_apache_2_4/multiple_vhosts")

    def test_parsernode_get_vhosts(self):
        self.config.USE_PARSERNODE = True
        vhosts = self.config.get_virtual_hosts()
        # Legacy get_virtual_hosts() do not set the node
        self.assertTrue(vhosts[0].node is not None)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 37 Column: 5

                      # Legacy get_virtual_hosts() do not set the node
        self.assertTrue(vhosts[0].node is not None)

    def test_parsernode_get_vhosts_mismatch(self):
        vhosts = self.config.get_virtual_hosts_v2()
        # One of the returned VirtualHost objects differs
        vhosts[0].name = "IdidntExpectThat"
        self.config.get_virtual_hosts_v2 = mock.MagicMock(return_value=vhosts)
        with self.assertRaises(AssertionError):

            

Reported by Pylint.

certbot/certbot/_internal/display/util.py
3 issues
TODO: check if above is still true when M2Crypto is gone ^
Error

Line: 81 Column: 3

                  """
    no_commas = input_.replace(",", " ")
    # Each string is naturally unicode, this causes problems with M2Crypto SANs
    # TODO: check if above is still true when M2Crypto is gone ^
    return [str(string) for string in no_commas.split()]


def summarize_domain_list(domains: List[str]) -> str:
    """Summarizes a list of domains in the format of:

            

Reported by Pylint.

Variable name "l" doesn't conform to snake_case naming style
Error

Line: 100 Column: 5

                  if not domains:
        return ""

    l = len(domains)
    if l == 1:
        return domains[0]
    elif l == 2:
        return " and ".join(domains)
    else:

            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 101 Column: 5

                      return ""

    l = len(domains)
    if l == 1:
        return domains[0]
    elif l == 2:
        return " and ".join(domains)
    else:
        return "{0} and {1} more domains".format(domains[0], l-1)

            

Reported by Pylint.

certbot/certbot/_internal/plugins/manual.py
3 issues
Unable to import 'acme'
Error

Line: 5 Column: 1

              import logging
from typing import Dict

from acme import challenges
from certbot import achallenges
from certbot import errors
from certbot import interfaces
from certbot import reverter
from certbot import util

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 140 Column: 9

                      }
        resources = ' and '.join(sorted([v for k, v in resource_names.items() if has_chall(k)]))

        if self.conf('auth-hook'):
            return (
                'The Certificate Authority failed to verify the {resources} created by the '
                '--manual-auth-hook. Ensure that this hook is functioning correctly{dns_hint}. '
                'Refer to "{certbot} --help manual" and the Certbot User Guide.'
                .format(

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 205
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                              port=self.config.http01_port,
                uri=achall.chall.uri(achall.domain), validation=validation)
        else:
            assert isinstance(achall.chall, challenges.DNS01)
            msg = self._DNS_INSTRUCTIONS.format(
                domain=achall.validation_domain_name(achall.domain),
                validation=validation)
        if isinstance(achall.chall, challenges.DNS01):
            if self.subsequent_dns_challenge:

            

Reported by Bandit.