Skip to content

Commit

Permalink
manual: deprecate --manual-public-ip-logging-ok (#8381)
Browse files Browse the repository at this point in the history
* manual: deprecate --manual-public-ip-logging-ok

* remove unused cli.report_config_interaction code

Co-authored-by: ohemorange <ebportnoy@gmail.com>
  • Loading branch information
alexzorin and ohemorange committed Oct 22, 2020
1 parent cb916a0 commit 4eb0b56
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 104 deletions.
1 change: 0 additions & 1 deletion certbot-ci/certbot_integration_tests/utils/certbot_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def _prepare_args_env(certbot_args, directory_url, http_01_port, tls_alpn_01_por
'--no-verify-ssl',
'--http-01-port', str(http_01_port),
'--https-port', str(tls_alpn_01_port),
'--manual-public-ip-logging-ok',
'--config-dir', config_dir,
'--work-dir', os.path.join(workspace, 'work'),
'--logs-dir', os.path.join(workspace, 'logs'),
Expand Down
3 changes: 3 additions & 0 deletions certbot/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Certbot adheres to [Semantic Versioning](https://semver.org/).
### Changed

* certbot-auto was deprecated on Debian based systems.
* CLI flag `--manual-public-ip-logging-ok` is now a no-op, generates a
deprecation warning, and will be removed in a future release.
*

### Fixed

Expand Down
1 change: 0 additions & 1 deletion certbot/certbot/_internal/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
)

# These imports depend on cli_constants and cli_utils.
from certbot._internal.cli.report_config_interaction import report_config_interaction
from certbot._internal.cli.verb_help import VERB_HELP, VERB_HELP_MAP
from certbot._internal.cli.group_adder import _add_all_groups
from certbot._internal.cli.subparsers import _create_subparsers
Expand Down
27 changes: 0 additions & 27 deletions certbot/certbot/_internal/cli/report_config_interaction.py

This file was deleted.

19 changes: 1 addition & 18 deletions certbot/certbot/_internal/plugins/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ def add_parser_arguments(cls, add):
help='Path or command to execute for the authentication script')
add('cleanup-hook',
help='Path or command to execute for the cleanup script')
add('public-ip-logging-ok', action='store_true',
help='Automatically allows public IP logging (default: Ask)')
util.add_deprecated_argument(add, 'public-ip-logging-ok', 0)

def prepare(self): # pylint: disable=missing-function-docstring
if self.config.noninteractive_mode and not self.conf('auth-hook'):
Expand Down Expand Up @@ -114,8 +113,6 @@ def get_chall_pref(self, domain):
return [challenges.HTTP01, challenges.DNS01]

def perform(self, achalls): # pylint: disable=missing-function-docstring
self._verify_ip_logging_ok()

responses = []
for achall in achalls:
if self.conf('auth-hook'):
Expand All @@ -125,20 +122,6 @@ def perform(self, achalls): # pylint: disable=missing-function-docstring
responses.append(achall.response(achall.account_key))
return responses

def _verify_ip_logging_ok(self):
if not self.conf('public-ip-logging-ok'):
cli_flag = '--{0}'.format(self.option_name('public-ip-logging-ok'))
msg = ('NOTE: The IP of this machine will be publicly logged as '
"having requested this certificate. If you're running "
'certbot in manual mode on a machine that is not your '
"server, please ensure you're okay with that.\n\n"
'Are you OK with your IP being logged?')
display = zope.component.getUtility(interfaces.IDisplay)
if display.yesno(msg, cli_flag=cli_flag, force_interactive=True):
setattr(self.config, self.dest('public-ip-logging-ok'), True)
else:
raise errors.PluginError('Must agree to IP logging to proceed')

def _perform_achall_with_script(self, achall, achalls):
env = dict(CERTBOT_DOMAIN=achall.domain,
CERTBOT_VALIDATION=achall.validation(achall.account_key),
Expand Down
4 changes: 0 additions & 4 deletions certbot/certbot/plugins/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ def __init__(self, config, name):
def add_parser_arguments(cls, add):
"""Add plugin arguments to the CLI argument parser.
NOTE: If some of your flags interact with others, you can
use cli.report_config_interaction to register this to ensure
values are correctly saved/overridable during renewal.
:param callable add: Function that proxies calls to
`argparse.ArgumentParser.add_argument` prepending options
with unique plugin name prefix.
Expand Down
37 changes: 0 additions & 37 deletions certbot/tests/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,43 +505,6 @@ def test_webroot_map(self):
verb = 'renew'
self.assertTrue(_call_set_by_cli('webroot_map', args, verb))

def test_report_config_interaction_str(self):
cli.report_config_interaction('manual_public_ip_logging_ok',
'manual_auth_hook')
cli.report_config_interaction('manual_auth_hook', 'manual')

self._test_report_config_interaction_common()

def test_report_config_interaction_iterable(self):
cli.report_config_interaction(('manual_public_ip_logging_ok',),
('manual_auth_hook',))
cli.report_config_interaction(('manual_auth_hook',), ('manual',))

self._test_report_config_interaction_common()

def _test_report_config_interaction_common(self):
"""Tests implied interaction between manual flags.
--manual implies --manual-auth-hook which implies
--manual-public-ip-logging-ok. These interactions don't actually
exist in the client, but are used here for testing purposes.
"""

args = ['--manual']
verb = 'renew'
for v in ('manual', 'manual_auth_hook', 'manual_public_ip_logging_ok'):
self.assertTrue(_call_set_by_cli(v, args, verb))

# https://github.com/python/mypy/issues/2087
cli.set_by_cli.detector = None # type: ignore

args = ['--manual-auth-hook', 'command']
for v in ('manual_auth_hook', 'manual_public_ip_logging_ok'):
self.assertTrue(_call_set_by_cli(v, args, verb))

self.assertFalse(_call_set_by_cli('manual', args, verb))


def _call_set_by_cli(var, args, verb):
with mock.patch('certbot._internal.cli.helpful_parser') as mock_parser:
Expand Down
17 changes: 1 addition & 16 deletions certbot/tests/plugins/manual_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def setUp(self):
# initialization.
self.config = mock.MagicMock(
http01_port=0, manual_auth_hook=None, manual_cleanup_hook=None,
manual_public_ip_logging_ok=False, noninteractive_mode=False,
validate_hooks=False,
noninteractive_mode=False, validate_hooks=False,
config_dir=os.path.join(self.tempdir, "config_dir"),
work_dir=os.path.join(self.tempdir, "work_dir"),
backup_dir=os.path.join(self.tempdir, "backup_dir"),
Expand All @@ -60,19 +59,7 @@ def test_get_chall_pref(self):
self.assertEqual(self.auth.get_chall_pref('example.org'),
[challenges.HTTP01, challenges.DNS01])

@test_util.patch_get_utility()
def test_ip_logging_not_ok(self, mock_get_utility):
mock_get_utility().yesno.return_value = False
self.assertRaises(errors.PluginError, self.auth.perform, [])

@test_util.patch_get_utility()
def test_ip_logging_ok(self, mock_get_utility):
mock_get_utility().yesno.return_value = True
self.auth.perform([])
self.assertTrue(self.config.manual_public_ip_logging_ok)

def test_script_perform(self):
self.config.manual_public_ip_logging_ok = True
self.config.manual_auth_hook = (
'{0} -c "from __future__ import print_function;'
'from certbot.compat import os;'
Expand Down Expand Up @@ -105,7 +92,6 @@ def test_script_perform(self):

@test_util.patch_get_utility()
def test_manual_perform(self, mock_get_utility):
self.config.manual_public_ip_logging_ok = True
self.assertEqual(
self.auth.perform(self.achalls),
[achall.response(achall.account_key) for achall in self.achalls])
Expand All @@ -116,7 +102,6 @@ def test_manual_perform(self, mock_get_utility):
self.assertFalse(kwargs['wrap'])

def test_cleanup(self):
self.config.manual_public_ip_logging_ok = True
self.config.manual_auth_hook = ('{0} -c "import sys; sys.stdout.write(\'foo\')"'
.format(sys.executable))
self.config.manual_cleanup_hook = '# cleanup'
Expand Down

0 comments on commit 4eb0b56

Please sign in to comment.