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

Remove insecure mode #468

Merged
merged 1 commit into from
Sep 13, 2016
Merged

Remove insecure mode #468

merged 1 commit into from
Sep 13, 2016

Conversation

coltonlw
Copy link
Contributor

@coltonlw coltonlw commented Sep 6, 2016

This removes insecure mode

Fixes: #410

@nagem
Copy link
Contributor

nagem commented Sep 6, 2016

LGTM.

message = traceback.format_exc()
else:
message = 'Internal Server Error'
util.send_json_http_exception(response, message, 500)
Copy link
Contributor

@kofalt kofalt Sep 6, 2016

Choose a reason for hiding this comment

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

Is this entire diff related to the purpose of the PR?

I feel like catching the base class is a good idea here rather than letting it go up the stack.
Suggest leaving the catch but remove the inner if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kofalt I added a ref to issue #451, which could be addressed as a separate change but since this except branch was clearly added to facilitate debug mode I removed it. I chose to let it go up the stack because without debug mode, the behavior would always be "log the error and send a message saying 'Internal Server Error'" to the client, which we can do just by letting the exception bubble up. Also it seems to me having 500's return JSON is not a good idea because other times we may not catch an error and thus the body may or may not be JSON encoded, which could cause issues for the requester. Status code 500 defined as "A generic error message, given when an unexpected condition was encountered and no more specific message is suitable"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess whether or not 500's should be JSON is debatable, from description of 5xx status codes: "Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation" I think in the case of 500 specifically JSON should not be included since this is the code used for an uncaught exception, compared to other more specific 5xx codes purposefully generated by the server.

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as there is there is defined behaviour for Exception bubbling up I'm fine with it 👍

Copy link
Contributor Author

@coltonlw coltonlw Sep 6, 2016

Choose a reason for hiding this comment

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

webapp2 doesn't define a default handler for any error codes, so it will call WSGIApplication._internal_error which logs to the root logger with level error, however it only logs the exception and not a traceback. I'm going to remove #451 from the list of issues this PR fixes, and update it to include an action item for adding a 500 handler to log the traceback.

@kofalt
Copy link
Contributor

kofalt commented Sep 6, 2016

This looks great 👍 lots of branches removed.

@ryansanford Can you confirm we don't need insecure & debug for anything anymore? I don't use it...

@gsfr
Copy link
Member

gsfr commented Sep 6, 2016

It was my understanding that we were going to remove insecure mode and debug links, but not debug mode, which prints stack traces, IIRC.

I strongly suggest that we keep this PR limited to the first two items and discuss the last one separately.

Just adding a couple of comments on what's mentioned above:

  • Given that we are open source, printing a stack trace in prod, doesn't reveal any secrets. Whether it's good form or not is debatable. It certainly makes debugging easier.
  • I vote that the API never ever returns anything but JSON.

@coltonlw
Copy link
Contributor Author

coltonlw commented Sep 7, 2016

@gsfr I agree leaving 500 errors JSON for the sake of consistency makes sense. Right now we may have some 500's which are not json-encoded, #451 will address that in addition to logging the traceback. Thus, I reverted my changes to that try-except block

I also restored debug mode, I know other frameworks have had security issues where debug mode has a remote code execution vulnerability and thus having a way to enable it in production carries some risk. That's definitely not what this PR was about so I've reverted that change as well.

@coltonlw coltonlw force-pushed the remove-insecure-mode branch 2 times, most recently from 2fb5d5a to a77b64e Compare September 7, 2016 14:51
@gsfr
Copy link
Member

gsfr commented Sep 9, 2016

Per offline discussion, revert change in api/api.py and then we should be good to go.

@coltonlw coltonlw force-pushed the remove-insecure-mode branch 3 times, most recently from 3e5d2ae to 077edbd Compare September 12, 2016 16:32
@coltonlw coltonlw force-pushed the remove-insecure-mode branch from 077edbd to 11efd4e Compare September 12, 2016 16:37
@coltonlw coltonlw assigned gsfr and nagem and unassigned gsfr, nagem and ryansanford Sep 12, 2016
@coltonlw
Copy link
Contributor Author

@gsfr @nagem Can I get a once over and final sign-off from you two before I merge this?

@gsfr
Copy link
Member

gsfr commented Sep 13, 2016

Thanks, @coltonlw. LGTM, but untested.

@nagem
Copy link
Contributor

nagem commented Sep 13, 2016

I can test tomorrow but just looking it over it LGTM2.

@coltonlw coltonlw merged commit 02708de into master Sep 13, 2016
@coltonlw coltonlw deleted the remove-insecure-mode branch September 13, 2016 14:28
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.

5 participants