-
Notifications
You must be signed in to change notification settings - Fork 28
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
Update nethsm dependency #469
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,6 +218,14 @@ def provision( | |
used.""" | ||
if not system_time: | ||
system_time = datetime.datetime.now(datetime.timezone.utc) | ||
|
||
print( | ||
"Warning: The unlock passphrase cannot be reset without knowing the current value. If the " | ||
"unlock passphrase is lost, neither can it be reset to a new value nor can the NetHSM be " | ||
"unlocked.", | ||
file=sys.stderr, | ||
) | ||
|
||
with connect(ctx, require_auth=False) as nethsm: | ||
nethsm.provision(unlock_passphrase, admin_passphrase, system_time) | ||
print(f"NetHSM {nethsm.host} provisioned") | ||
|
@@ -824,9 +832,15 @@ def get_config(ctx: Context, **kwargs: bool) -> None: | |
"--current-passphrase", | ||
help="The current backup passphrase (or an empty string if not set)", | ||
) | ||
@click.option( | ||
"-f", | ||
"--force", | ||
is_flag=True, | ||
help="Do not ask for confirmation before changing the passphrase", | ||
) | ||
@click.pass_context | ||
def set_backup_passphrase( | ||
ctx: Context, new_passphrase: str, current_passphrase: Optional[str] | ||
ctx: Context, new_passphrase: str, current_passphrase: Optional[str], force: bool | ||
) -> None: | ||
"""Set the backup passphrase of a NetHSM. | ||
|
||
|
@@ -835,6 +849,18 @@ def set_backup_passphrase( | |
|
||
This command requires authentication as a user with the Administrator | ||
role.""" | ||
|
||
print( | ||
"Warning: The backup passphrase cannot be reset without knowing the current value. If the " | ||
"backup passphrase is lost, neither can it be reset to a new value nor can the created " | ||
"backups be restored.", | ||
file=sys.stderr, | ||
) | ||
|
||
confirmed = force or click.confirm("Do you want to continue?") | ||
if not confirmed: | ||
raise click.Abort() | ||
|
||
if not current_passphrase: | ||
current_passphrase = prompt_str( | ||
"The current backup passphrase (or an empty string if not set)", | ||
|
@@ -864,16 +890,34 @@ def set_backup_passphrase( | |
prompt=True, | ||
help="The current unlock passphrase", | ||
) | ||
@click.option( | ||
"-f", | ||
"--force", | ||
is_flag=True, | ||
help="Do not ask for confirmation before changing the passphrase", | ||
) | ||
@click.pass_context | ||
def set_unlock_passphrase( | ||
ctx: Context, new_passphrase: str, current_passphrase: str | ||
ctx: Context, new_passphrase: str, current_passphrase: str, force: bool | ||
) -> None: | ||
"""Set the unlock passphrase of a NetHSM. | ||
|
||
Changing the unlock passphrase requires the current passphrase. | ||
|
||
This command requires authentication as a user with the Administrator | ||
role.""" | ||
|
||
print( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion this warning should only be printed if the force flag is false. But may this is more a matter of taste. |
||
"Warning: The unlock passphrase cannot be reset without knowing the current value. If the " | ||
"unlock passphrase is lost, neither can it be reset to a new value nor can the NetHSM be " | ||
"unlocked.", | ||
file=sys.stderr, | ||
) | ||
|
||
confirmed = force or click.confirm("Do you want to continue?") | ||
if not confirmed: | ||
raise click.Abort() | ||
|
||
with connect(ctx) as nethsm: | ||
nethsm.set_unlock_passphrase( | ||
new_passphrase=new_passphrase, current_passphrase=current_passphrase | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion this warning should only be printed if the force flag is false. But may this is more a matter of taste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be conservative here: Always printing the warning doesn’t cost us anything, but it could still help to prevent mistakes.