Skip to content

Change securesystemslib.dsse.Envelope.signatures to dict upstream#743

Merged
lukpueh merged 4 commits intosecure-systems-lab:mainfrom
NicholasTanz:ChangeSignaturestoDictUpstream
Apr 3, 2024
Merged

Change securesystemslib.dsse.Envelope.signatures to dict upstream#743
lukpueh merged 4 commits intosecure-systems-lab:mainfrom
NicholasTanz:ChangeSignaturestoDictUpstream

Conversation

@NicholasTanz
Copy link
Copy Markdown
Contributor

@NicholasTanz NicholasTanz commented Mar 9, 2024

Fixes: theupdateframework/python-tuf#2564

Description of the changes being introduced by the pull request:

Please verify and check that the pull request fulfils the following requirements:

  • The code follows the Code Style Guidelines
  • Tests have been added for the bug fix or new feature
  • Docs have been added for the bug fix or new feature

@NicholasTanz NicholasTanz marked this pull request as draft March 9, 2024 18:00
Comment thread securesystemslib/dsse.py
@@ -26,7 +26,7 @@ def __init__(
):
Copy link
Copy Markdown
Contributor Author

@NicholasTanz NicholasTanz Mar 9, 2024

Choose a reason for hiding this comment

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

I wasn't sure if I should change the last param from signatures: List[Signature] to signatures: Dict[str, Signature] or if it is fine to leave it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good question! Please do change the constructor argument to Dict[str, Signature] and implement the translation in from_dict and to_dict. This is also what we do with python-tuf Metadata.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I also just saw that we raise, if there are duplicate (by keyid) signatures there. I suggest to do the same in Envelope.from_dict.

@NicholasTanz NicholasTanz marked this pull request as ready for review March 9, 2024 18:08
@NicholasTanz
Copy link
Copy Markdown
Contributor Author

Hey @lukpueh , I was wondering if you could take a look at this pr when you get a chance? thanks

lukpueh pushed a commit to lukpueh/tuf that referenced this pull request Mar 12, 2024
lukpueh pushed a commit to lukpueh/in-toto that referenced this pull request Mar 12, 2024
Copy link
Copy Markdown
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

Thanks for the clean patch! I replied to your question inline. Please address and we can merge this. FYI I already tried out what changes this will need in tuf and in-toto, and it looks reasonable (see referenced commits above).

Comment thread securesystemslib/dsse.py
@@ -26,7 +26,7 @@ def __init__(
):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good question! Please do change the constructor argument to Dict[str, Signature] and implement the translation in from_dict and to_dict. This is also what we do with python-tuf Metadata.

Comment thread securesystemslib/dsse.py
@@ -26,7 +26,7 @@ def __init__(
):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I also just saw that we raise, if there are duplicate (by keyid) signatures there. I suggest to do the same in Envelope.from_dict.

Comment thread securesystemslib/dsse.py
if signature.keyid in signatures:
raise ValueError(
f"Multiple signatures found for keyid {signature.keyid}"
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the check. Would you mind adding a small test?

Comment thread securesystemslib/dsse.py Outdated

signatures = []
for signature in self.signatures:
for signature in list(self.signatures.values()):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a reason to convert to list? You could iterate directly over dict_values. Same comment applies below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ah no - I just followed the format here comment . Will change to just iterating over dict_values

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, that PR has a few such conversions for type checking reasons.

Signed-off-by: E3E <[email protected]>
Copy link
Copy Markdown
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

LGTM!

@lukpueh lukpueh merged commit e73758b into secure-systems-lab:main Apr 3, 2024
lukpueh pushed a commit to lukpueh/tuf that referenced this pull request Apr 3, 2024
Adopt `securesystemslib.dsse.Envelope.signatures` type change
from list to dict (secure-systems-lab/securesystemslib/pull/743)
in `tuf.api.dsse.SimpleEnvelope` subclass.

fixes theupdateframework#2564

Signed-off-by: Lukas Puehringer <[email protected]>
lukpueh pushed a commit to lukpueh/in-toto that referenced this pull request Apr 3, 2024
Adopt `securesystemslib.dsse.Envelope.signatures` type change
from list to dict (secure-systems-lab/securesystemslib/pull/743)
in `in_toto.models.metadata.Envelope` subclass.

Signed-off-by: Lukas Puehringer <[email protected]>
lukpueh pushed a commit to lukpueh/in-toto that referenced this pull request Apr 3, 2024
Adopt `securesystemslib.dsse.Envelope.signatures` type change
from list to dict (secure-systems-lab/securesystemslib/pull/743)
in `in_toto.models.metadata.Envelope` subclass.

Signed-off-by: Lukas Puehringer <[email protected]>
lukpueh pushed a commit to lukpueh/in-toto that referenced this pull request Apr 29, 2024
Adopt `securesystemslib.dsse.Envelope.signatures` type change
from list to dict (secure-systems-lab/securesystemslib/pull/743)
in `in_toto.models.metadata.Envelope` subclass.

Signed-off-by: Lukas Puehringer <[email protected]>
lukpueh pushed a commit to lukpueh/in-toto that referenced this pull request Apr 30, 2024
Adopt `securesystemslib.dsse.Envelope.signatures` type change
from list to dict (secure-systems-lab/securesystemslib/pull/743)
in `in_toto.models.metadata.Envelope` subclass.

Signed-off-by: Lukas Puehringer <[email protected]>
lukpueh pushed a commit to lukpueh/in-toto that referenced this pull request May 2, 2024
Adopt `securesystemslib.dsse.Envelope.signatures` type change
from list to dict (secure-systems-lab/securesystemslib/pull/743)
in `in_toto.models.metadata.Envelope` subclass.

Signed-off-by: Lukas Puehringer <[email protected]>
lukpueh pushed a commit to lukpueh/in-toto that referenced this pull request May 9, 2024
Adopt `securesystemslib.dsse.Envelope.signatures` type change
from list to dict (secure-systems-lab/securesystemslib/pull/743)
in `in_toto.models.metadata.Envelope` subclass.

Signed-off-by: Lukas Puehringer <[email protected]>
@NicholasTanz NicholasTanz deleted the ChangeSignaturestoDictUpstream branch February 24, 2025 13:43
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.

Change securesystemslib.dsse.Envelope.signatures to dict upstream

2 participants