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

Internal Sinatra errors now extend Sinatra::Error #1519

Merged
merged 1 commit into from
Oct 4, 2021

Conversation

jkowens
Copy link
Member

@jkowens jkowens commented Feb 1, 2019

By extending Sinatra::Error, an error class can set the http status code on the response to a value other than 500. This commit fixes issues #1204 and #1518 where an error raised by a third party library that responded to http_status could set the status on the response. Any error outside of Sinatra errors will now always return a 500 status.

This fixes an issue where an exception could leak sensitive data in the message to the browser. Errors that have http_status code 400 or 404 use the message as the body of the response. This is why it is imperative that these errors extend Sinatra::Error so that this is an explicit decision.

@jkowens
Copy link
Member Author

jkowens commented Feb 1, 2019

@namusyaka, @mwpastore any thoughts on the impact of this change?

Copy link
Member

@dentarg dentarg left a comment

Choose a reason for hiding this comment

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

👍

@jkowens
Copy link
Member Author

jkowens commented Feb 1, 2019

This is an alternative solution to #1236.

@garybernhardt
Copy link

(I opened #1518.) I don't know Sinatra's internals, but from the diff this does seem to address exactly the issue I was reporting!

@mwpastore
Copy link
Member

I need to take a closer look at the implementation and consider unintended side effects, but at first blush this is a much better approach than what I've proposed in #1236.

By extending Sinatra::Error, an error class can set the http status
code on the response to a value other than 500. This commit fixes
issues sinatra#1204 and sinatra#1518 where an error raised by a third party library
that responded to http_status could set the status on the response.
Any error outside of Sinatra errors will now always return a 500 status.

This fixes an issue where an exception could leak sensitive data in
the message to the browser. Errors that have http_status code 400 or
404 use the message as the body of the response. This is why it is
imperative that these errors extend Sinatra::Error so that this is
an explicit decision.
@jkowens jkowens merged commit 514562f into sinatra:unstable Oct 4, 2021
matoro added a commit to matoro/gentoo that referenced this pull request Jun 14, 2022
matoro added a commit to matoro/gentoo that referenced this pull request Jun 15, 2022
matoro added a commit to matoro/gentoo that referenced this pull request Jun 15, 2022
matoro added a commit to matoro/gentoo that referenced this pull request Jun 18, 2022
matoro added a commit to matoro/gentoo that referenced this pull request Jun 20, 2022
matoro added a commit to matoro/gentoo that referenced this pull request Jun 25, 2022
matoro added a commit to matoro/gentoo that referenced this pull request Jul 11, 2022
matoro added a commit to matoro/gentoo that referenced this pull request Jul 13, 2022
See: sinatra/sinatra#1774
See: sinatra/sinatra#1519
Signed-off-by: matoro <matoro@users.noreply.github.com>
@dentarg
Copy link
Member

dentarg commented Jul 20, 2022

This is in master as bda8c29 (this was merged into the unstable branch that we don't use anymore so GitHub doesn't have the correct reference here)

@jkowens
Copy link
Member Author

jkowens commented Jul 20, 2022

@dentarg is there something that needs to be done here?

@dentarg
Copy link
Member

dentarg commented Jul 20, 2022

@jkowens No, just a note to myself mostly for more easily finding the commit again if I need :)

this will be part of the 3.0 release, and then we can close #1772

matoro added a commit to matoro/gentoo that referenced this pull request Sep 29, 2022
See: sinatra/sinatra#1774
See: sinatra/sinatra#1519
Signed-off-by: matoro <matoro@users.noreply.github.com>
matoro added a commit to matoro/gentoo that referenced this pull request Sep 29, 2022
Upstream determined this will go into 3.0.0 release, so it's still
required for 2.2.1.

See: sinatra/sinatra#1774
See: sinatra/sinatra#1519
Signed-off-by: Matoro Mahri <matoro@users.noreply.github.com>
gentoo-bot pushed a commit to gentoo/gentoo that referenced this pull request Oct 22, 2022
See: sinatra/sinatra#1774
See: sinatra/sinatra#1519
Signed-off-by: matoro <matoro@users.noreply.github.com>
Signed-off-by: Matt Turner <mattst88@gentoo.org>
gentoo-bot pushed a commit to gentoo/gentoo that referenced this pull request Oct 22, 2022
Upstream determined this will go into 3.0.0 release, so it's still
required for 2.2.1.

See: sinatra/sinatra#1774
See: sinatra/sinatra#1519
Signed-off-by: Matoro Mahri <matoro@users.noreply.github.com>
Signed-off-by: Matt Turner <mattst88@gentoo.org>
tadast added a commit to tadast/sequenceserver that referenced this pull request Feb 21, 2024
Upgrading Sinatra has broken HTTP status codes for some errors.

There was a Sinatra change sinatra/sinatra#1519
in V3 (SequenceServer has gone from v2 -> V4 recently) that made the
http status code setting from the exception class more explicit
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.

None yet

5 participants