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

feat: improve NetHSM API exception handling #445

Merged

Conversation

nponsard
Copy link
Contributor

This PR improves the handling of API errors in the nethsm commands.

Checklist

Make sure to run make check and make fix before creating a PR, otherwise the CI will fail.

  • tested with Python3.9
  • signed commits
  • updated documentation (e.g. parameter description, inline doc, docs.nitrokey)
  • added labels

Test Environment and Execution

  • OS: Arch
  • device's model: NetHSM docker
  • device's firmware version: 882a5a3

Copy link
Member

@robin-nitrokey robin-nitrokey left a comment

Choose a reason for hiding this comment

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

LGTM, just some comments.

Comment on lines 192 to 196
# 405 "Method Not Allowed" mostly happens when the UserID or KeyID contains a character
# - that ends the path of the URL like a question mark '?' :
# /api/v1/keys/?/cert will hit the keys listing endpoint instead of the key/{KeyID}/cert endpoint
# - that doesn't cound as a phath parameter like a slash '/' :
# /api/v1/keys///cert will be interpreted as /api/v1/keys/cert with cert as the KeyID
Copy link
Member

Choose a reason for hiding this comment

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

Is that something that we should validate before sending the request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be the best solution yes

Copy link
Member

Choose a reason for hiding this comment

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

Please create a ticket for it (or a PR ;)).

pynitrokey/nethsm/__init__.py Outdated Show resolved Hide resolved
pynitrokey/nethsm/__init__.py Outdated Show resolved Hide resolved
pynitrokey/nethsm/__init__.py Outdated Show resolved Hide resolved
pynitrokey/nethsm/__init__.py Outdated Show resolved Hide resolved
@nponsard nponsard force-pushed the pr/improve-api-exception-handling branch from d34c352 to bf6be1e Compare September 21, 2023 08:42
@robin-nitrokey robin-nitrokey merged commit 659b308 into Nitrokey:master Sep 21, 2023
5 checks passed
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