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

validate Key instances in constructor not in deserialization #559

Closed
lukpueh opened this issue Mar 31, 2023 · 0 comments · Fixed by #780
Closed

validate Key instances in constructor not in deserialization #559

lukpueh opened this issue Mar 31, 2023 · 0 comments · Fixed by #780
Labels
contribfest Issues for KubeCon EU contribfest good first issue

Comments

@lukpueh
Copy link
Member

lukpueh commented Mar 31, 2023

Description of issue or feature request:
Subclasses of Key implement a from_dict deserialization interface to load known keys e.g. from TUF metadata. Some of the current implementations do basic input validation too.

Unless it is directly related to deserialization, I think, input validation should happen in __init__, to also be effective on manually created objects.

Examples:

if "public" not in keyval or not isinstance(keyval["public"], str):
raise ValueError(f"public key string required for scheme {scheme}")

for content in ["identity", "issuer"]:
if content not in keyval or not isinstance(keyval[content], str):
raise ValueError(
f"{content} string required for scheme {scheme}"
)

Current behavior:
Key implementations validate inputs in from_dict

Expected behavior:
Key implementations validate inputs in __init__

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribfest Issues for KubeCon EU contribfest good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant