-
Notifications
You must be signed in to change notification settings - Fork 11
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 tuf version #115
Closed
Closed
Update tuf version #115
Changes from all commits
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
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
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
from tempfile import TemporaryDirectory | ||
|
||
import click | ||
from tuf.api.metadata import Key, VerificationResult | ||
|
||
from tuf_on_ci._repository import CIRepository | ||
|
||
|
@@ -87,20 +88,25 @@ def _find_changed_target_roles( | |
|
||
|
||
def _role_status(repo: CIRepository, role: str, event_name) -> bool: | ||
status, prev_status = repo.status(role) | ||
role_is_valid = status.valid | ||
sig_counts = f"{len(status.signed)}/{status.threshold}" | ||
signed = status.signed | ||
missing = status.missing | ||
|
||
# Handle the additional status for the possible previous, known good root version: | ||
if prev_status: | ||
role_is_valid = role_is_valid and prev_status.valid | ||
sig_counts = f"{len(prev_status.signed)}/{prev_status.threshold} ({sig_counts})" | ||
signed = signed | prev_status.signed | ||
missing = missing | prev_status.missing | ||
|
||
if role_is_valid and not status.invites: | ||
def signer(key: Key) -> str: | ||
return key.unrecognized_fields["x-tuf-on-ci-keyowner"] | ||
|
||
status = repo.status(role) | ||
vr = status.verification_result | ||
|
||
# Build the signature count description string: | ||
if isinstance(vr, VerificationResult): | ||
sig_counts = f"{len(vr.signed)}/{vr.threshold}" | ||
else: | ||
sig_counts = ( | ||
f"{len(vr.first.signed)}/{vr.first.threshold} " | ||
+ f"({len(vr.second.signed)}/{vr.second.threshold})" | ||
) | ||
# build strings of signed and unsigned signer names | ||
signed = ", ".join([signer(key) for key in vr.signed.values()]) | ||
unsigned = ", ".join([signer(key) for key in vr.unsigned.values()]) | ||
|
||
if status.valid: | ||
emoji = "white_check_mark" | ||
else: | ||
emoji = "x" | ||
|
@@ -113,29 +119,28 @@ def _role_status(repo: CIRepository, role: str, event_name) -> bool: | |
"Invitees can accept the invitations by running " | ||
f"`tuf-on-ci-sign {event_name}`" | ||
) | ||
|
||
if not status.invites: | ||
else: | ||
if status.target_changes: | ||
click.echo(f"Role `{role}` contains following artifact changes:") | ||
for target_state in status.target_changes: | ||
click.echo(f" * {target_state}") | ||
click.echo("") | ||
|
||
if role_is_valid: | ||
if status.valid: | ||
click.echo( | ||
f"Role `{role}` is verified and signed by {sig_counts} signers " | ||
f"({', '.join(signed)})." | ||
f"({signed})." | ||
) | ||
elif signed: | ||
elif vr.signed: | ||
click.echo( | ||
f"Role `{role}` is not yet verified. It is signed by {sig_counts} " | ||
f"signers ({', '.join(signed)})." | ||
f"signers ({signed})." | ||
) | ||
else: | ||
click.echo(f"Role `{role}` is unsigned and not yet verified") | ||
|
||
if missing: | ||
click.echo(f"Still missing signatures from {', '.join(missing)}") | ||
if vr.unsigned: | ||
click.echo(f"Still missing signatures from {unsigned}") | ||
click.echo( | ||
"Signers can sign these changes by running " | ||
f"`tuf-on-ci-sign {event_name}`" | ||
|
@@ -144,7 +149,7 @@ def _role_status(repo: CIRepository, role: str, event_name) -> bool: | |
if status.message: | ||
click.echo(f"**Error**: {status.message}") | ||
|
||
return role_is_valid and not status.invites | ||
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. SigningStatus makes sure it is not valid if there are invites so this is safe |
||
return status.valid | ||
|
||
|
||
@click.command() # type: ignore[arg-type] | ||
|
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
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.
This check is handled by
Root.get_root_verification_result()