The following issues were found

certbot-nginx/certbot_nginx/_internal/configurator.py
36 issues
Unable to import 'acme'
Error

Line: 20 Column: 1

              import OpenSSL
import pkg_resources

from acme import challenges
from acme import crypto_util as acme_crypto_util
from certbot import crypto_util
from certbot import errors
from certbot import interfaces
from certbot import util

            

Reported by Pylint.

Unable to import 'acme'
Error

Line: 21 Column: 1

              import pkg_resources

from acme import challenges
from acme import crypto_util as acme_crypto_util
from certbot import crypto_util
from certbot import errors
from certbot import interfaces
from certbot import util
from certbot.display import util as display_util

            

Reported by Pylint.

Unable to import 'certbot'
Error

Line: 22 Column: 1

              
from acme import challenges
from acme import crypto_util as acme_crypto_util
from certbot import crypto_util
from certbot import errors
from certbot import interfaces
from certbot import util
from certbot.display import util as display_util
from certbot.compat import os

            

Reported by Pylint.

Unable to import 'certbot'
Error

Line: 23 Column: 1

              from acme import challenges
from acme import crypto_util as acme_crypto_util
from certbot import crypto_util
from certbot import errors
from certbot import interfaces
from certbot import util
from certbot.display import util as display_util
from certbot.compat import os
from certbot.plugins import common

            

Reported by Pylint.

Unable to import 'certbot'
Error

Line: 24 Column: 1

              from acme import crypto_util as acme_crypto_util
from certbot import crypto_util
from certbot import errors
from certbot import interfaces
from certbot import util
from certbot.display import util as display_util
from certbot.compat import os
from certbot.plugins import common
from certbot_nginx._internal import constants

            

Reported by Pylint.

Unable to import 'certbot'
Error

Line: 25 Column: 1

              from certbot import crypto_util
from certbot import errors
from certbot import interfaces
from certbot import util
from certbot.display import util as display_util
from certbot.compat import os
from certbot.plugins import common
from certbot_nginx._internal import constants
from certbot_nginx._internal import display_ops

            

Reported by Pylint.

Unable to import 'certbot.display'
Error

Line: 26 Column: 1

              from certbot import errors
from certbot import interfaces
from certbot import util
from certbot.display import util as display_util
from certbot.compat import os
from certbot.plugins import common
from certbot_nginx._internal import constants
from certbot_nginx._internal import display_ops
from certbot_nginx._internal import http_01

            

Reported by Pylint.

Unable to import 'certbot.compat'
Error

Line: 27 Column: 1

              from certbot import interfaces
from certbot import util
from certbot.display import util as display_util
from certbot.compat import os
from certbot.plugins import common
from certbot_nginx._internal import constants
from certbot_nginx._internal import display_ops
from certbot_nginx._internal import http_01
from certbot_nginx._internal import nginxparser

            

Reported by Pylint.

Unable to import 'certbot.plugins'
Error

Line: 28 Column: 1

              from certbot import util
from certbot.display import util as display_util
from certbot.compat import os
from certbot.plugins import common
from certbot_nginx._internal import constants
from certbot_nginx._internal import display_ops
from certbot_nginx._internal import http_01
from certbot_nginx._internal import nginxparser
from certbot_nginx._internal import obj  # pylint: disable=unused-import

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 211 Column: 13

                          util.lock_dir_until_exit(self.conf('server-root'))
        except (OSError, errors.LockError):
            logger.debug('Encountered error:', exc_info=True)
            raise errors.PluginError('Unable to lock {0}'.format(self.conf('server-root')))

    # Entry point in main.py for installing cert
    def deploy_cert(self, domain, cert_path, key_path,
                    chain_path=None, fullchain_path=None):
        """Deploys certificate to specified virtual host.

            

Reported by Pylint.

certbot-dns-cloudflare/tests/dns_cloudflare_test.py
35 issues
Unable to import 'CloudFlare'
Error

Line: 5 Column: 1

              
import unittest

import CloudFlare
try:
    import mock
except ImportError: # pragma: no cover
    from unittest import mock # type: ignore


            

Reported by Pylint.

Unable to import 'certbot'
Error

Line: 11 Column: 1

              except ImportError: # pragma: no cover
    from unittest import mock # type: ignore

from certbot import errors
from certbot.compat import os
from certbot.plugins import dns_test_common
from certbot.plugins.dns_test_common import DOMAIN
from certbot.tests import util as test_util


            

Reported by Pylint.

Unable to import 'certbot.compat'
Error

Line: 12 Column: 1

                  from unittest import mock # type: ignore

from certbot import errors
from certbot.compat import os
from certbot.plugins import dns_test_common
from certbot.plugins.dns_test_common import DOMAIN
from certbot.tests import util as test_util

API_ERROR = CloudFlare.exceptions.CloudFlareAPIError(1000, '', '')

            

Reported by Pylint.

Unable to import 'certbot.plugins'
Error

Line: 13 Column: 1

              
from certbot import errors
from certbot.compat import os
from certbot.plugins import dns_test_common
from certbot.plugins.dns_test_common import DOMAIN
from certbot.tests import util as test_util

API_ERROR = CloudFlare.exceptions.CloudFlareAPIError(1000, '', '')


            

Reported by Pylint.

Unable to import 'certbot.plugins.dns_test_common'
Error

Line: 14 Column: 1

              from certbot import errors
from certbot.compat import os
from certbot.plugins import dns_test_common
from certbot.plugins.dns_test_common import DOMAIN
from certbot.tests import util as test_util

API_ERROR = CloudFlare.exceptions.CloudFlareAPIError(1000, '', '')

API_TOKEN = 'an-api-token'

            

Reported by Pylint.

Unable to import 'certbot.tests'
Error

Line: 15 Column: 1

              from certbot.compat import os
from certbot.plugins import dns_test_common
from certbot.plugins.dns_test_common import DOMAIN
from certbot.tests import util as test_util

API_ERROR = CloudFlare.exceptions.CloudFlareAPIError(1000, '', '')

API_TOKEN = 'an-api-token'


            

Reported by Pylint.

Unable to import 'certbot_dns_cloudflare._internal.dns_cloudflare'
Error

Line: 28 Column: 9

              class AuthenticatorTest(test_util.TempDirTestCase, dns_test_common.BaseAuthenticatorTest):

    def setUp(self):
        from certbot_dns_cloudflare._internal.dns_cloudflare import Authenticator

        super().setUp()

        path = os.path.join(self.tempdir, 'file.ini')
        dns_test_common.write({"cloudflare_email": EMAIL, "cloudflare_api_key": API_KEY}, path)

            

Reported by Pylint.

Unable to import 'certbot_dns_cloudflare._internal.dns_cloudflare'
Error

Line: 113 Column: 9

                  record_id = 2

    def setUp(self):
        from certbot_dns_cloudflare._internal.dns_cloudflare import _CloudflareClient

        self.cloudflare_client = _CloudflareClient(EMAIL, API_KEY)

        self.cf = mock.MagicMock()
        self.cloudflare_client.cf = self.cf

            

Reported by Pylint.

Possible hardcoded password: 'an-api-token'
Security

Line: 19
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b105_hardcoded_password_string.html

              
API_ERROR = CloudFlare.exceptions.CloudFlareAPIError(1000, '', '')

API_TOKEN = 'an-api-token'

API_KEY = 'an-api-key'
EMAIL = 'example@example.com'



            

Reported by Bandit.

Missing class docstring
Error

Line: 25 Column: 1

              EMAIL = 'example@example.com'


class AuthenticatorTest(test_util.TempDirTestCase, dns_test_common.BaseAuthenticatorTest):

    def setUp(self):
        from certbot_dns_cloudflare._internal.dns_cloudflare import Authenticator

        super().setUp()

            

Reported by Pylint.

certbot/tests/display/util_test.py
35 issues
Unable to import 'certbot'
Error

Line: 7 Column: 1

              import tempfile
import unittest

from certbot import errors
import certbot.tests.util as test_util

try:
    import mock
except ImportError:  # pragma: no cover

            

Reported by Pylint.

Unable to import 'certbot.tests.util'
Error

Line: 8 Column: 1

              import unittest

from certbot import errors
import certbot.tests.util as test_util

try:
    import mock
except ImportError:  # pragma: no cover
    from unittest import mock

            

Reported by Pylint.

Unable to import 'certbot.display.util'
Error

Line: 21 Column: 9

              
    @test_util.patch_display_util()
    def test_notify(self, mock_util):
        from certbot.display.util import notify
        notify("Hello World")
        mock_util().notification.assert_called_with(
            "Hello World", pause=False, decorate=False, wrap=False
        )


            

Reported by Pylint.

Unable to import 'certbot.display.util'
Error

Line: 33 Column: 9

              
    @test_util.patch_display_util()
    def test_notification(self, mock_util):
        from certbot.display.util import notification
        notification("Hello World")
        mock_util().notification.assert_called_with(
            "Hello World", pause=True, decorate=True, wrap=True, force_interactive=False
        )


            

Reported by Pylint.

Unable to import 'certbot.display.util'
Error

Line: 45 Column: 9

              
    @test_util.patch_display_util()
    def test_menu(self, mock_util):
        from certbot.display.util import menu
        menu("Hello World", ["one", "two"], default=0)
        mock_util().menu.assert_called_with(
            "Hello World", ["one", "two"], default=0, cli_flag=None, force_interactive=False
        )


            

Reported by Pylint.

Unable to import 'certbot.display.util'
Error

Line: 57 Column: 9

              
    @test_util.patch_display_util()
    def test_input_text(self, mock_util):
        from certbot.display.util import input_text
        input_text("Hello World", default="something")
        mock_util().input.assert_called_with(
            "Hello World", default='something', cli_flag=None, force_interactive=False
        )


            

Reported by Pylint.

Unable to import 'certbot.display.util'
Error

Line: 69 Column: 9

              
    @test_util.patch_display_util()
    def test_yesno(self, mock_util):
        from certbot.display.util import yesno
        yesno("Hello World", default=True)
        mock_util().yesno.assert_called_with(
            "Hello World", yes_label='Yes', no_label='No', default=True, cli_flag=None,
            force_interactive=False
        )

            

Reported by Pylint.

Unable to import 'certbot.display.util'
Error

Line: 82 Column: 9

              
    @test_util.patch_display_util()
    def test_checklist(self, mock_util):
        from certbot.display.util import checklist
        checklist("Hello World", ["one", "two"], default="one")
        mock_util().checklist.assert_called_with(
            "Hello World", ['one', 'two'], default='one', cli_flag=None, force_interactive=False
        )


            

Reported by Pylint.

Unable to import 'certbot.display.util'
Error

Line: 94 Column: 9

              
    @test_util.patch_display_util()
    def test_directory_select(self, mock_util):
        from certbot.display.util import directory_select
        directory_select("Hello World", default="something")
        mock_util().directory_select.assert_called_with(
            "Hello World", default='something', cli_flag=None, force_interactive=False
        )


            

Reported by Pylint.

Unused import io
Error

Line: 2 Column: 1

              """Test :mod:`certbot.display.util`."""
import io
import socket
import tempfile
import unittest

from certbot import errors
import certbot.tests.util as test_util


            

Reported by Pylint.

acme/acme/client.py
34 issues
Unable to import 'josepy'
Error

Line: 19 Column: 1

              from typing import Union
import warnings

import josepy as jose
import OpenSSL
import requests
from requests.adapters import HTTPAdapter
from requests.utils import parse_header_links
from requests_toolbelt.adapters.source import SourceAddressAdapter

            

Reported by Pylint.

Unable to import 'requests_toolbelt.adapters.source'
Error

Line: 24 Column: 1

              import requests
from requests.adapters import HTTPAdapter
from requests.utils import parse_header_links
from requests_toolbelt.adapters.source import SourceAddressAdapter

from acme import crypto_util
from acme import errors
from acme import jws
from acme import messages

            

Reported by Pylint.

TODO: Boulder returns httplib.ACCEPTED
Error

Line: 70 Column: 3

                  def _send_recv_regr(self, regr, body):
        response = self._post(regr.uri, body)

        # TODO: Boulder returns httplib.ACCEPTED
        #assert response.status_code == httplib.OK

        # TODO: Boulder does not set Location or Link on update
        # (c.f. acme-spec #94)


            

Reported by Pylint.

TODO: Boulder does not set Location or Link on update
Error

Line: 73 Column: 3

                      # TODO: Boulder returns httplib.ACCEPTED
        #assert response.status_code == httplib.OK

        # TODO: Boulder does not set Location or Link on update
        # (c.f. acme-spec #94)

        return self._regr_from_response(
            response, uri=regr.uri,
            terms_of_service=regr.terms_of_service)

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 162 Column: 13

                      try:
            authzr_uri = response.links['up']['url']
        except KeyError:
            raise errors.ClientError('"up" Link header missing')
        challr = messages.ChallengeResource(
            authzr_uri=authzr_uri,
            body=messages.ChallengeBody.from_json(response.json()))
        # TODO: check that challr.uri == response.headers['Location']?
        if challr.uri != challb.uri:

            

Reported by Pylint.

TODO: check that challr.uri == response.headers['Location']?
Error

Line: 166 Column: 3

                      challr = messages.ChallengeResource(
            authzr_uri=authzr_uri,
            body=messages.ChallengeBody.from_json(response.json()))
        # TODO: check that challr.uri == response.headers['Location']?
        if challr.uri != challb.uri:
            raise errors.UnexpectedUpdate(challr.uri)
        return challr

    @classmethod

            

Reported by Pylint.

TODO: handle errors
Error

Line: 276 Column: 3

                      """
        new_reg = messages.NewRegistration() if new_reg is None else new_reg
        response = self._post(self.directory[new_reg], new_reg)
        # TODO: handle errors
        assert response.status_code == http_client.CREATED

        # "Instance of 'Field' has no key/contact member" bug:
        return self._regr_from_response(response)


            

Reported by Pylint.

TODO: handle errors
Error

Line: 328 Column: 3

              
        new_authz = messages.NewAuthorization(identifier=identifier)
        response = self._post(self.directory.new_authz, new_authz)
        # TODO: handle errors
        assert response.status_code == http_client.CREATED
        return self._authzr_from_response(response, identifier)

    def request_domain_challenges(self, domain, new_authzr_uri=None):
        """Request challenges for domain names.

            

Reported by Pylint.

TODO: assert len(authzrs) == number of SANs
Error

Line: 367 Column: 3

                      assert authzrs, "Authorizations list is empty"
        logger.debug("Requesting issuance...")

        # TODO: assert len(authzrs) == number of SANs
        req = messages.CertificateRequest(csr=csr)

        content_type = DER_CONTENT_TYPE  # TODO: add 'cert_type 'argument
        response = self._post(
            self.directory.new_cert,

            

Reported by Pylint.

TODO: add 'cert_type 'argument
Error

Line: 370 Column: 3

                      # TODO: assert len(authzrs) == number of SANs
        req = messages.CertificateRequest(csr=csr)

        content_type = DER_CONTENT_TYPE  # TODO: add 'cert_type 'argument
        response = self._post(
            self.directory.new_cert,
            req,
            content_type=content_type,
            headers={'Accept': content_type})

            

Reported by Pylint.

certbot/tests/eff_test.py
33 issues
Unable to import 'josepy'
Error

Line: 9 Column: 1

                  import mock
except ImportError:  # pragma: no cover
    from unittest import mock
import josepy
import pytz
import requests

from acme import messages
from certbot._internal import account

            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 10 Column: 1

              except ImportError:  # pragma: no cover
    from unittest import mock
import josepy
import pytz
import requests

from acme import messages
from certbot._internal import account
from certbot._internal import constants

            

Reported by Pylint.

Unable to import 'acme'
Error

Line: 13 Column: 1

              import pytz
import requests

from acme import messages
from certbot._internal import account
from certbot._internal import constants
import certbot.tests.util as test_util



            

Reported by Pylint.

Unable to import 'certbot._internal'
Error

Line: 14 Column: 1

              import requests

from acme import messages
from certbot._internal import account
from certbot._internal import constants
import certbot.tests.util as test_util


_KEY = josepy.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))

            

Reported by Pylint.

Unable to import 'certbot._internal'
Error

Line: 15 Column: 1

              
from acme import messages
from certbot._internal import account
from certbot._internal import constants
import certbot.tests.util as test_util


_KEY = josepy.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))


            

Reported by Pylint.

Unable to import 'certbot.tests.util'
Error

Line: 16 Column: 1

              from acme import messages
from certbot._internal import account
from certbot._internal import constants
import certbot.tests.util as test_util


_KEY = josepy.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))



            

Reported by Pylint.

Unable to import 'certbot._internal.eff'
Error

Line: 42 Column: 9

              class PrepareSubscriptionTest(SubscriptionTest):
    """Tests for certbot._internal.eff.prepare_subscription."""
    def _call(self):
        from certbot._internal.eff import prepare_subscription
        prepare_subscription(self.config, self.account)

    @test_util.patch_display_util()
    @mock.patch("certbot._internal.eff.display_util.notify")
    def test_failure(self, mock_notify, mock_get_utility):

            

Reported by Pylint.

Unable to import 'certbot._internal.eff'
Error

Line: 102 Column: 9

              class HandleSubscriptionTest(SubscriptionTest):
    """Tests for certbot._internal.eff.handle_subscription."""
    def _call(self):
        from certbot._internal.eff import handle_subscription
        handle_subscription(self.config, self.account)

    @mock.patch('certbot._internal.eff.subscribe')
    def test_no_subscribe(self, mock_subscribe):
        self._call()

            

Reported by Pylint.

Unable to import 'certbot._internal.eff'
Error

Line: 133 Column: 9

                  def _call(self, mock_post):
        mock_post.return_value = self.response

        from certbot._internal.eff import subscribe
        subscribe(self.email)
        self._check_post_call(mock_post)

    def _check_post_call(self, mock_post):
        self.assertEqual(mock_post.call_count, 1)

            

Reported by Pylint.

No value for argument 'mock_post' in method call
Error

Line: 148 Column: 9

              
    def test_bad_status(self):
        self.json['status'] = False
        self._call()
        actual = self._get_reported_message()
        expected_part = 'because your e-mail address appears to be invalid.'
        self.assertIn(expected_part, actual)

    def test_not_ok(self):

            

Reported by Pylint.

certbot-dns-rfc2136/tests/dns_rfc2136_test.py
33 issues
Unable to import 'dns.flags'
Error

Line: 5 Column: 1

              
import unittest

import dns.flags
import dns.rcode
import dns.tsig
try:
    import mock
except ImportError: # pragma: no cover

            

Reported by Pylint.

Unable to import 'dns.rcode'
Error

Line: 6 Column: 1

              import unittest

import dns.flags
import dns.rcode
import dns.tsig
try:
    import mock
except ImportError: # pragma: no cover
    from unittest import mock # type: ignore

            

Reported by Pylint.

Unable to import 'dns.tsig'
Error

Line: 7 Column: 1

              
import dns.flags
import dns.rcode
import dns.tsig
try:
    import mock
except ImportError: # pragma: no cover
    from unittest import mock # type: ignore


            

Reported by Pylint.

Unable to import 'certbot'
Error

Line: 13 Column: 1

              except ImportError: # pragma: no cover
    from unittest import mock # type: ignore

from certbot import errors
from certbot.compat import os
from certbot.plugins import dns_test_common
from certbot.plugins.dns_test_common import DOMAIN
from certbot.tests import util as test_util


            

Reported by Pylint.

Unable to import 'certbot.compat'
Error

Line: 14 Column: 1

                  from unittest import mock # type: ignore

from certbot import errors
from certbot.compat import os
from certbot.plugins import dns_test_common
from certbot.plugins.dns_test_common import DOMAIN
from certbot.tests import util as test_util

SERVER = '192.0.2.1'

            

Reported by Pylint.

Unable to import 'certbot.plugins'
Error

Line: 15 Column: 1

              
from certbot import errors
from certbot.compat import os
from certbot.plugins import dns_test_common
from certbot.plugins.dns_test_common import DOMAIN
from certbot.tests import util as test_util

SERVER = '192.0.2.1'
PORT = 53

            

Reported by Pylint.

Unable to import 'certbot.plugins.dns_test_common'
Error

Line: 16 Column: 1

              from certbot import errors
from certbot.compat import os
from certbot.plugins import dns_test_common
from certbot.plugins.dns_test_common import DOMAIN
from certbot.tests import util as test_util

SERVER = '192.0.2.1'
PORT = 53
NAME = 'a-tsig-key.'

            

Reported by Pylint.

Unable to import 'certbot.tests'
Error

Line: 17 Column: 1

              from certbot.compat import os
from certbot.plugins import dns_test_common
from certbot.plugins.dns_test_common import DOMAIN
from certbot.tests import util as test_util

SERVER = '192.0.2.1'
PORT = 53
NAME = 'a-tsig-key.'
SECRET = 'SSB3b25kZXIgd2hvIHdpbGwgYm90aGVyIHRvIGRlY29kZSB0aGlzIHRleHQK'

            

Reported by Pylint.

Unable to import 'certbot_dns_rfc2136._internal.dns_rfc2136'
Error

Line: 29 Column: 9

              class AuthenticatorTest(test_util.TempDirTestCase, dns_test_common.BaseAuthenticatorTest):

    def setUp(self):
        from certbot_dns_rfc2136._internal.dns_rfc2136 import Authenticator

        super().setUp()

        path = os.path.join(self.tempdir, 'file.ini')
        dns_test_common.write(VALID_CONFIG, path)

            

Reported by Pylint.

Unable to import 'certbot_dns_rfc2136._internal.dns_rfc2136'
Error

Line: 81 Column: 9

              class RFC2136ClientTest(unittest.TestCase):

    def setUp(self):
        from certbot_dns_rfc2136._internal.dns_rfc2136 import _RFC2136Client

        self.rfc2136_client = _RFC2136Client(SERVER, PORT, NAME, SECRET, dns.tsig.HMAC_MD5,
        TIMEOUT)

    @mock.patch("dns.query.tcp")

            

Reported by Pylint.

certbot-nginx/tests/obj_test.py
33 issues
Unable to import 'certbot_nginx._internal.obj'
Error

Line: 9 Column: 9

              class AddrTest(unittest.TestCase):
    """Test the Addr class."""
    def setUp(self):
        from certbot_nginx._internal.obj import Addr
        self.addr1 = Addr.fromstring("192.168.1.1")
        self.addr2 = Addr.fromstring("192.168.1.1:* ssl")
        self.addr3 = Addr.fromstring("192.168.1.1:80")
        self.addr4 = Addr.fromstring("*:80 default_server ssl")
        self.addr5 = Addr.fromstring("myhost")

            

Reported by Pylint.

Unable to import 'certbot_nginx._internal.obj'
Error

Line: 74 Column: 9

                      self.assertEqual(self.addr6.to_string(include_default=False), "80")

    def test_eq(self):
        from certbot_nginx._internal.obj import Addr
        new_addr1 = Addr.fromstring("192.168.1.1 spdy")
        self.assertEqual(self.addr1, new_addr1)
        self.assertNotEqual(self.addr1, self.addr2)
        self.assertNotEqual(self.addr1, 3333)


            

Reported by Pylint.

Unable to import 'certbot_nginx._internal.obj'
Error

Line: 81 Column: 9

                      self.assertNotEqual(self.addr1, 3333)

    def test_equivalent_any_addresses(self):
        from certbot_nginx._internal.obj import Addr
        any_addresses = ("0.0.0.0:80 default_server ssl",
                         "80 default_server ssl",
                         "*:80 default_server ssl",
                         "80 default ssl")
        for first, second in itertools.combinations(any_addresses, 2):

            

Reported by Pylint.

Unable to import 'certbot_nginx._internal.obj'
Error

Line: 100 Column: 9

                              Addr.fromstring(any_address))

    def test_set_inclusion(self):
        from certbot_nginx._internal.obj import Addr
        set_a = {self.addr1, self.addr2}
        addr1b = Addr.fromstring("192.168.1.1")
        addr2b = Addr.fromstring("192.168.1.1:* ssl")
        set_b = {addr1b, addr2b}


            

Reported by Pylint.

Unable to import 'certbot_nginx._internal.obj'
Error

Line: 112 Column: 9

              class VirtualHostTest(unittest.TestCase):
    """Test the VirtualHost class."""
    def setUp(self):
        from certbot_nginx._internal.obj import VirtualHost
        from certbot_nginx._internal.obj import Addr
        raw1 = [
            ['listen', '69.50.225.155:9000'],
            [['if', '($scheme', '!=', '"https") '],
                [['return', '301', 'https://$host$request_uri']]

            

Reported by Pylint.

Unable to import 'certbot_nginx._internal.obj'
Error

Line: 113 Column: 9

                  """Test the VirtualHost class."""
    def setUp(self):
        from certbot_nginx._internal.obj import VirtualHost
        from certbot_nginx._internal.obj import Addr
        raw1 = [
            ['listen', '69.50.225.155:9000'],
            [['if', '($scheme', '!=', '"https") '],
                [['return', '301', 'https://$host$request_uri']]
            ],

            

Reported by Pylint.

Unable to import 'certbot_nginx._internal.obj'
Error

Line: 162 Column: 9

                          {'localhost'}, raw_has_hsts, [])

    def test_eq(self):
        from certbot_nginx._internal.obj import Addr
        from certbot_nginx._internal.obj import VirtualHost
        vhost1b = VirtualHost(
            "filep",
            {Addr.fromstring("localhost blah")}, False, False,
            {'localhost'}, [], [])

            

Reported by Pylint.

Unable to import 'certbot_nginx._internal.obj'
Error

Line: 163 Column: 9

              
    def test_eq(self):
        from certbot_nginx._internal.obj import Addr
        from certbot_nginx._internal.obj import VirtualHost
        vhost1b = VirtualHost(
            "filep",
            {Addr.fromstring("localhost blah")}, False, False,
            {'localhost'}, [], [])


            

Reported by Pylint.

Unable to import 'certbot_nginx._internal.obj'
Error

Line: 186 Column: 9

                      self.assertFalse(self.vhost1.has_header('Bogus-Header'))

    def test_contains_list(self):
        from certbot_nginx._internal.obj import VirtualHost
        from certbot_nginx._internal.obj import Addr
        from certbot_nginx._internal.configurator import _test_block_from_block
        test_block = [
            ['\n    ', 'return', ' ', '301', ' ', 'https://$host$request_uri'],
            ['\n']

            

Reported by Pylint.

Unable to import 'certbot_nginx._internal.obj'
Error

Line: 187 Column: 9

              
    def test_contains_list(self):
        from certbot_nginx._internal.obj import VirtualHost
        from certbot_nginx._internal.obj import Addr
        from certbot_nginx._internal.configurator import _test_block_from_block
        test_block = [
            ['\n    ', 'return', ' ', '301', ' ', 'https://$host$request_uri'],
            ['\n']
        ]

            

Reported by Pylint.

certbot/tests/display/internal_util_test.py
30 issues
Unable to import 'certbot'
Error

Line: 7 Column: 1

              import tempfile
import unittest

from certbot import errors

try:
    import mock
except ImportError:  # pragma: no cover
    from unittest import mock

            

Reported by Pylint.

Unable to import 'certbot._internal.display.util'
Error

Line: 17 Column: 9

              
class WrapLinesTest(unittest.TestCase):
    def test_wrap_lines(self):
        from certbot._internal.display.util import wrap_lines
        msg = ("This is just a weak test{0}"
               "This function is only meant to be for easy viewing{0}"
               "Test a really really really really really really really really "
               "really really really really long line...".format('\n'))
        text = wrap_lines(msg)

            

Reported by Pylint.

Unable to import 'certbot._internal.display.util'
Error

Line: 30 Column: 9

              class PlaceParensTest(unittest.TestCase):
    @classmethod
    def _call(cls, label):
        from certbot._internal.display.util import parens_around_char
        return parens_around_char(label)

    def test_single_letter(self):
        self.assertEqual("(a)", self._call("a"))


            

Reported by Pylint.

Unable to import 'certbot._internal.display.util'
Error

Line: 45 Column: 9

                  """Tests for certbot._internal.display.util.input_with_timeout."""
    @classmethod
    def _call(cls, *args, **kwargs):
        from certbot._internal.display.util import input_with_timeout
        return input_with_timeout(*args, **kwargs)

    def test_eof(self):
        with tempfile.TemporaryFile("r+") as f:
            with mock.patch("certbot._internal.display.util.sys.stdin", new=f):

            

Reported by Pylint.

Unable to import 'certbot._internal.display.util'
Error

Line: 83 Column: 9

              
    @classmethod
    def _call(cls, input_):
        from certbot._internal.display.util import separate_list_input
        return separate_list_input(input_)

    def test_commas(self):
        self.assertEqual(self._call("a,b,c,test"), self.exp)


            

Reported by Pylint.

Unable to import 'certbot._internal.display.util'
Error

Line: 109 Column: 9

              class SummarizeDomainListTest(unittest.TestCase):
    @classmethod
    def _call(cls, domains):
        from certbot._internal.display.util import summarize_domain_list
        return summarize_domain_list(domains)

    def test_single_domain(self):
        self.assertEqual("example.com", self._call(["example.com"]))


            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

                  from unittest import mock


class WrapLinesTest(unittest.TestCase):
    def test_wrap_lines(self):
        from certbot._internal.display.util import wrap_lines
        msg = ("This is just a weak test{0}"
               "This function is only meant to be for easy viewing{0}"
               "Test a really really really really really really really really "

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

              

class WrapLinesTest(unittest.TestCase):
    def test_wrap_lines(self):
        from certbot._internal.display.util import wrap_lines
        msg = ("This is just a weak test{0}"
               "This function is only meant to be for easy viewing{0}"
               "Test a really really really really really really really really "
               "really really really really long line...".format('\n'))

            

Reported by Pylint.

Import outside toplevel (certbot._internal.display.util.wrap_lines)
Error

Line: 17 Column: 9

              
class WrapLinesTest(unittest.TestCase):
    def test_wrap_lines(self):
        from certbot._internal.display.util import wrap_lines
        msg = ("This is just a weak test{0}"
               "This function is only meant to be for easy viewing{0}"
               "Test a really really really really really really really really "
               "really really really really long line...".format('\n'))
        text = wrap_lines(msg)

            

Reported by Pylint.

Missing class docstring
Error

Line: 27 Column: 1

                      self.assertEqual(text.count('\n'), 3)


class PlaceParensTest(unittest.TestCase):
    @classmethod
    def _call(cls, label):
        from certbot._internal.display.util import parens_around_char
        return parens_around_char(label)


            

Reported by Pylint.

certbot-ci/snap_integration_tests/dns_tests/test_main.py
30 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              import re
import subprocess

import pytest


@pytest.fixture(autouse=True, scope="module")
def install_certbot_snap(request):
    with pytest.raises(Exception):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python3
import glob
import os
import re
import subprocess

import pytest



            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 5
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              import glob
import os
import re
import subprocess

import pytest


@pytest.fixture(autouse=True, scope="module")

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 11 Column: 1

              

@pytest.fixture(autouse=True, scope="module")
def install_certbot_snap(request):
    with pytest.raises(Exception):
        subprocess.check_call(['certbot', '--version'])
    try:
        snap_folder = request.config.getoption("snap_folder")
        snap_arch = request.config.getoption("snap_arch")

            

Reported by Pylint.

subprocess call - check for execution of untrusted input.
Security injection

Line: 13
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

              @pytest.fixture(autouse=True, scope="module")
def install_certbot_snap(request):
    with pytest.raises(Exception):
        subprocess.check_call(['certbot', '--version'])
    try:
        snap_folder = request.config.getoption("snap_folder")
        snap_arch = request.config.getoption("snap_arch")
        snap_path = glob.glob(os.path.join(snap_folder, 'certbot_*_{0}.snap'.format(snap_arch)))[0]
        subprocess.check_call(['snap', 'install', '--classic', '--dangerous', snap_path])

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 13
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

              @pytest.fixture(autouse=True, scope="module")
def install_certbot_snap(request):
    with pytest.raises(Exception):
        subprocess.check_call(['certbot', '--version'])
    try:
        snap_folder = request.config.getoption("snap_folder")
        snap_arch = request.config.getoption("snap_arch")
        snap_path = glob.glob(os.path.join(snap_folder, 'certbot_*_{0}.snap'.format(snap_arch)))[0]
        subprocess.check_call(['snap', 'install', '--classic', '--dangerous', snap_path])

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 18
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                      snap_folder = request.config.getoption("snap_folder")
        snap_arch = request.config.getoption("snap_arch")
        snap_path = glob.glob(os.path.join(snap_folder, 'certbot_*_{0}.snap'.format(snap_arch)))[0]
        subprocess.check_call(['snap', 'install', '--classic', '--dangerous', snap_path])
        subprocess.check_call(['certbot', '--version'])
        yield
    finally:
        subprocess.call(['snap', 'remove', 'certbot'])


            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 18
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

                      snap_folder = request.config.getoption("snap_folder")
        snap_arch = request.config.getoption("snap_arch")
        snap_path = glob.glob(os.path.join(snap_folder, 'certbot_*_{0}.snap'.format(snap_arch)))[0]
        subprocess.check_call(['snap', 'install', '--classic', '--dangerous', snap_path])
        subprocess.check_call(['certbot', '--version'])
        yield
    finally:
        subprocess.call(['snap', 'remove', 'certbot'])


            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 19
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                      snap_arch = request.config.getoption("snap_arch")
        snap_path = glob.glob(os.path.join(snap_folder, 'certbot_*_{0}.snap'.format(snap_arch)))[0]
        subprocess.check_call(['snap', 'install', '--classic', '--dangerous', snap_path])
        subprocess.check_call(['certbot', '--version'])
        yield
    finally:
        subprocess.call(['snap', 'remove', 'certbot'])



            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 19
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

                      snap_arch = request.config.getoption("snap_arch")
        snap_path = glob.glob(os.path.join(snap_folder, 'certbot_*_{0}.snap'.format(snap_arch)))[0]
        subprocess.check_call(['snap', 'install', '--classic', '--dangerous', snap_path])
        subprocess.check_call(['certbot', '--version'])
        yield
    finally:
        subprocess.call(['snap', 'remove', 'certbot'])



            

Reported by Bandit.

acme/acme/messages.py
29 issues
Unable to import 'josepy'
Error

Line: 8 Column: 1

              from typing import Dict
from typing import Type

import josepy as jose

from acme import challenges
from acme import errors
from acme import fields
from acme import jws

            

Reported by Pylint.

Value 'cls.POSSIBLE_NAMES' is unsubscriptable
Error

Line: 147 Column: 16

                      if jobj not in cls.POSSIBLE_NAMES:  # pylint: disable=unsupported-membership-test
            raise jose.DeserializationError(
                '{0} not recognized'.format(cls.__name__))
        return cls.POSSIBLE_NAMES[jobj]

    def __repr__(self):
        return '{0}({1})'.format(self.__class__.__name__, self.name)

    def __eq__(self, other):

            

Reported by Pylint.

TODO: check that everything is an absolute URL; acme-spec is
Error

Line: 235 Column: 3

              
    def __init__(self, jobj):
        canon_jobj = util.map_keys(jobj, self._canon_key)
        # TODO: check that everything is an absolute URL; acme-spec is
        # not clear on that
        self._jobj = canon_jobj

    def __getattr__(self, name):
        try:

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 243 Column: 13

                      try:
            return self[name.replace('_', '-')]
        except KeyError as error:
            raise AttributeError(str(error))

    def __getitem__(self, name):
        try:
            return self._jobj[self._canon_key(name)]
        except KeyError:

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 249 Column: 13

                      try:
            return self._jobj[self._canon_key(name)]
        except KeyError:
            raise KeyError('Directory field "' + self._canon_key(name) + '" not found')

    def to_partial_json(self):
        return self._jobj

    @classmethod

            

Reported by Pylint.

TODO: 'expires' is allowed for Authorization Resources in
Error

Line: 529 Column: 3

                  combinations = jose.Field('combinations', omitempty=True)

    status = jose.Field('status', omitempty=True, decoder=Status.from_json)
    # TODO: 'expires' is allowed for Authorization Resources in
    # general, but for Key Authorization '[t]he "expires" field MUST
    # be absent'... then acme-spec gives example with 'expires'
    # present... That's confusing!
    expires = fields.RFC3339Field('expires', omitempty=True)
    wildcard = jose.Field('wildcard', omitempty=True)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 139 Column: 5

                      self.POSSIBLE_NAMES[name] = self  # pylint: disable=unsupported-assignment-operation
        self.name = name

    def to_partial_json(self):
        return self.name

    @classmethod
    def from_json(cls, jobj):
        if jobj not in cls.POSSIBLE_NAMES:  # pylint: disable=unsupported-membership-test

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 143 Column: 5

                      return self.name

    @classmethod
    def from_json(cls, jobj):
        if jobj not in cls.POSSIBLE_NAMES:  # pylint: disable=unsupported-membership-test
            raise jose.DeserializationError(
                '{0} not recognized'.format(cls.__name__))
        return cls.POSSIBLE_NAMES[jobj]


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 178 Column: 1

              IDENTIFIER_FQDN = IdentifierType('dns')  # IdentifierDNS in Boulder


class Identifier(jose.JSONObjectWithFields):
    """ACME identifier.

    :ivar IdentifierType typ:
    :ivar unicode value:


            

Reported by Pylint.

Method could be a function
Error

Line: 217 Column: 9

                          for name in super().__iter__():
                yield name[1:] if name == '_terms_of_service' else name

        def _internal_name(self, name):
            return '_' + name if name == 'terms_of_service' else name


    @classmethod
    def _canon_key(cls, key):

            

Reported by Pylint.