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

Handle Bad Encryption IDs #5058

Merged
merged 2 commits into from
Jan 15, 2025
Merged

Conversation

dtgreiner
Copy link
Contributor

Merging this PR

  • use the squash-merge strategy for PRs targeting a release-X branch
  • use a merge-commit or rebase strategy for PRs targeting the stable branch

Description

Handle bad encrypted id values by allowing the controllers to respond as if a record with a matching value was not found (404) instead of throwing an OpenSSL::Cipher::CipherError as that could be confusing to users.

The cipher error is still sent to Sentry.

Type of change

Bug fix

Checklist before requesting review

  • I have performed a self-review of my code
  • I have run the code that is being changed under ideal conditions, and it doesn't fail
  • If adding a new endpoint / exposing data in a new way, I have:
    • ensured the API can't leak data from other data sources
    • ensured this does not introduce N+1s
    • ensured permissions and visibility checks are performed in the right places
  • Any major architectural changes are supported by an approved ADR (Architectural Decision Record)
  • I have updated the documentation (or not applicable)
  • I have added spec tests (or not applicable)
  • I have provided testing instructions in this PR or the related issue (or not applicable)

//: # NOTE: system tests may fail if there is no branch on the hmis-frontend that matches the Source or Target branch of this PR. This is expected

@dtgreiner dtgreiner requested review from ttoomey and eanders January 15, 2025 16:56
Copy link
Contributor

@eanders eanders left a comment

Choose a reason for hiding this comment

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

That looks good to me, thank you!

end
decoded_key = true if value != params[key]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this raise a NotFound error if the value and params[key] match? Or where is that handled?

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 should be the same as if the PROTECTED_IDS setting is not being used and an invalid key is passed. Unless the controller is specifically handling it differently (e.g. client controller) , it should be throwing an ActiveRecord::RecordNotFound error on the controller which responds as a 404.

Example from local environment for Data Source Controller.
Screenshot 2025-01-15 at 1 07 12 PM

Non dev environments should show the 404 page.
Screenshot 2025-01-15 at 1 10 32 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! Just wanted to make sure.

@eanders eanders merged commit 20069e8 into release-148 Jan 15, 2025
54 checks passed
@eanders eanders deleted the dg/cipher_error_exception-7043 branch January 15, 2025 18:44
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