Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #4708, adds sdconfig prompt for v2/v3 services #4710

Merged
merged 4 commits into from
Aug 30, 2019

Conversation

kushaldas
Copy link
Contributor

@kushaldas kushaldas commented Aug 27, 2019

Now it asks if the admin wants to enable v2 or v3 services.
It will not let you to disable v3 if you already disabled v2.

Status

Work in progress

Description of Changes

Fixes #4708

./securedrop-admin sdconfig now asks for admin input to set to enable v2 and v3 onion services.

Testing

A few scenarios.

  • Already installed system, enable v2 and answer no for v3_onion_services
  • Already installed system, try to answer no to both v2, and v3. It will not let do v3 as no if you already disabled v2
  • Fresh system (by just deleting/moving install_files/ansible-base/group_vars/all/site-specific file), by default v2_onion_services should ask as no and v3_onion_services should give yes as default value.

Note: I could not write/upgrade integration tests for this yet.

Checklist

If you made changes to the server application code:

  • Linting (make lint) and tests (make -C securedrop test) pass in the development container

If you made changes to securedrop-admin:

  • Linting and tests (make -C admin test) pass in the admin development container

If you made changes to the system configuration:

If you made non-trivial code changes:

  • I have written a test plan and validated it for this PR

If you made changes to documentation:

  • Doc linting (make docs-lint) passed locally

@kushaldas kushaldas force-pushed the ask_all_questions branch 2 times, most recently from 392b413 to e68c745 Compare August 28, 2019 16:52
@kushaldas kushaldas marked this pull request as ready for review August 28, 2019 17:02
@kushaldas kushaldas force-pushed the ask_all_questions branch 3 times, most recently from c52d918 to eebe892 Compare August 28, 2019 18:56
@codecov-io
Copy link

codecov-io commented Aug 28, 2019

Codecov Report

Merging #4710 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #4710   +/-   ##
========================================
  Coverage    81.61%   81.61%           
========================================
  Files           49       49           
  Lines         3416     3416           
  Branches       391      391           
========================================
  Hits          2788     2788           
  Misses         535      535           
  Partials        93       93

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3d3ab7...36ea430. Read the comment docs.

Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good - a few comments/questions inline

lambda x: x.lower() == 'yes',
lambda config: True],
['v3_onion_services', self.check_for_v3_onion, bool,
u'Do you want to enable new v3 onion services?',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to enable new v3 onion services? -> Do you want to enable v3 onion services (recommended)?

@@ -403,6 +422,16 @@ def __init__(self, args):
SiteConfig.ValidateLocales(self.args.app_path),
string.split,
lambda config: True],
['v2_onion_services', self.check_for_v2_onion(), bool,
u'Do you want to enable v2 onion services?',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to enable v2 onion services? -> Do you want to enable v2 onion services (recommended only for SecureDrop instances installed before 1.0.0)?

# is already disabled.
if text == 'no' and \
not self.caller._config.get("v2_onion_services"):
raise ValidationError(message="Must be yes as you disabled v2")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be yes as you disabled v2 -> Since you disabled v2 onion services, you must enable v3 onion services.


def user_prompt_config(self):
config = {}
self._config = {}
for desc in self.desc:
(var, default, type, prompt, validator, transform,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is not in the diff but the variable names here are uninformative (since not in the diff, not requesting changing, just noting), e.g. var, desc, condition in particular

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the old code :) I am trying not to modify anything which does not require for this issue. We can do code cleanup, but, in a future PR.

SiteConfig.ValidateYesNo(),
lambda x: x.lower() == 'yes',
lambda config: True],
['v3_onion_services', self.check_for_v3_onion, bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm do we need the check_for_v3_onion method? It seems like we could remove the method and just have this be True?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@redshiftzero This dynamic function checks if the user input for v2_onion_services was no, and then v3_onion_services is must to yes. But, if v2_onion_servies was set to yes, and previously the admin set v3_onion_service to no, then it will show no as default value.

@conorsch
Copy link
Contributor

Have not given a full review here yet, but I see @redshiftzero was kind enough to stop by with a few requests. Please address @redshiftzero's comments when you log in, @kushaldas, and I can follow up with another round when you're satisfied.

@@ -261,6 +278,8 @@ def validate(self, document):
def __init__(self, args):
self.args = args
self.config = {}
# This is to hold runtime configuration before save
self._config = {}
Copy link
Contributor

@redshiftzero redshiftzero Aug 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should rename this before merge to something more expressive

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime_config ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable; I was going to suggest _config_in_progress.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pick one and change every where (including tests). I don't want to do it at 1:30AM :)

@conorsch
Copy link
Contributor

Functionally, works as described. Will push up a small change to make variable names more explicit, as discussed above.

conorsch
conorsch previously approved these changes Aug 29, 2019
Copy link
Contributor

@conorsch conorsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for merge. Confirmed the following:

  • running sdconfig with no site-specific config (i.e. fresh install) defaults to no-v2, yes-v3
  • running sdconfig with existing site-specific config (i.e. existing install) defaults to yes-v2, yes-v2
  • running sdconfig and setting "no" to both v2 & v3 raises a blocking error, preventing broken config

Added a single dev-oriented commit, fine to merge after tests pass.

@conorsch
Copy link
Contributor

Seeing a rather perplexing CI error in the lint step: https://circleci.com/gh/freedomofpress/securedrop/32939 Will try to reproduce locally.

Now it asks if the admin wants to enable v2 or v3 services.
It will not let you to disable v3 if you already disabled v2.
We now have two more integration tests to verify that
we can have "enabled v2 and disabled v3" and both versions
enabled at the same time.
@conorsch
Copy link
Contributor

Rebased on top of latest develop (d3d3ab7) to resolve CI woes. Hat tip to @rmol for pointing out the drift.

There's already a `.config` attribute in the sdconfig flow, so let's
rename `._config` -> `._config_in_progress` to make the intended use
case explicit to future maintainers. The contents of the
_config_in_progress dict are consulted during validation steps as part
of `sdconfig`.
@conorsch conorsch dismissed redshiftzero’s stale review August 30, 2019 00:30

Changes requested by @redshiftzero have been implemented

@conorsch conorsch self-requested a review August 30, 2019 00:30
Copy link
Contributor

@conorsch conorsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reapproving now that CI is passing. 😎

@conorsch conorsch merged commit 549a056 into develop Aug 30, 2019
@conorsch conorsch deleted the ask_all_questions branch August 30, 2019 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

./securedrop-admin sdconfig does not ask if we should enable v3 or not
4 participants