Skip to content

Remove schema checks in securesystemslib.gpg #775

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

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

lukpueh
Copy link
Member

@lukpueh lukpueh commented Apr 10, 2024

  • addresses part of #731
  • blocks on #772 (commits are included in this PR)

In preparation for the removal of schema.py (#183), this patch removes schema checks in the following modules of the securesystemslib.gpg subpackage:

  • internal modules rsa, dsa, eddsa, common. These checks are redundant with schema checks that are already performed in the calling functions of the functions module.

  • in previously public functions module:

    • keyid in create_signature and export_pubkey functions
    • public key and signature dict in verify_signature function

This is okay for two reasons:

  1. the preferred way of interacting with securesystemslib.gpg.functions is via GPGSigner, which controls the format of the passed arguments to some extent

  2. securesystemslib.gpg still raises meaningful and even more consistent errors for invalid arguments anyway, than it did before. E.g. a keyid passed to export_pubkey that doesn't conform to the previously checked hex schema, now raises a KeyNotFoundError.

Other changes include:

  • move string literal GPG_HASH_ALGORITHM_STRING from securesystemslib.schema to the better suited secureystemslib.gpg.constants module.
  • remove mentions of schema definitions in docstrings
  • adopt changes in tests

In preparation for the removal of schema.py (secure-systems-lab#183), this patch removes
schema checks in the following modules of the `securesystemslib.gpg`
subpackage:

* internal modules `rsa`, `dsa`, `eddsa`, `common`. These checks are
  redundant with schema checks that are already performed in the calling
  functions of the `functions` module.

* in previously public `functions` module: * keyid in `create_signature`
  and `export_pubkey` functions * public key and signature dict in
  `verify_signature` function

This is okay for two reasons:

1. the preferred way of interacting with
   `securesystemslib.gpg.functions` is via `GPGSigner`, which controls
   the format of the passed arguments to some extent

2. securesystemslib.gpg still raises meaningful and even more consistent
   errors for invalid arguments anyway, than it did before. E.g. a keyid
   passed to `export_pubkey` that doesn't conform to the previously
   checked hex schema, now raises a `KeyNotFoundError`.

Other changes include:

* move string literal `GPG_HASH_ALGORITHM_STRING` from
  `securesystemslib.schema` to the better suited
  `secureystemslib.gpg.constants` module.
* remove mentions of schema definitions in docstrings
* adopt changes in tests

Signed-off-by: Lukas Puehringer <[email protected]>
@lukpueh lukpueh force-pushed the rm-gpg-schema-check branch from d5585d1 to 7d4c336 Compare April 15, 2024 13:49
@lukpueh lukpueh marked this pull request as ready for review April 15, 2024 13:49
@lukpueh lukpueh requested a review from jku April 15, 2024 13:49
Copy link
Collaborator

@jku jku left a comment

Choose a reason for hiding this comment

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

this is not a part of the code I'm familiar with but seems correct...

@lukpueh lukpueh merged commit 37089c5 into secure-systems-lab:main Apr 16, 2024
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.

2 participants