Should view description be excluded from OPTIONS response by default? #7836
Unanswered
dennisvang
asked this question in
Ideas & Suggestions
Replies: 1 comment 1 reply
-
Ideas, anyone? Also see e.g. https://medium.com/workindia-in/stop-django-rest-framework-from-leaking-your-docstrings-336c0df91656 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Checklist
master
branch of Django REST framework.Possibly related to #5999
Description
As a relatively new, and rather naive, user of DRF, I was a bit surprised to see that my view's docstrings are returned in the
"description"
field of the response to anOPTIONS
request.I understand how this can be a very useful feature. However, if you are not aware of the fact, it also introduces a potential security risk, as it may leak information that was intended for in-house developers' eyes only.
I guess there could be a long (or very short) discussion, at this point, about docstring best-practices, and, how, perhaps, sensitive notes should not be included in a docstring in the first place.
However, I think we can safely say there are two facts:
whether by accident or by intention, sensitive information will sometimes end up in a view's docstring
not all DRF users will be aware that, by default, the view's docstring is returned as part of an
OPTIONS
responseSure, the documentation provides an example of how to remove the docstring from the response, but that means you have to know about it first.
I think awareness is the key issue here.
For this reason I ask:
Shouldn't the inclusion of the view's docstring in the
OPTIONS
response be optional, instead of default?Steps to reproduce
Request
OPTIONS
from any DRF view that has a docstring.Expected behavior
I would expect the docstring NOT to be returned in the OPTIONS response, by default.
Actual behavior
The
OPTIONS
response includes the view docstring in the "description" field, by default. We have to disable this manually, as described, for example, in the documentation.Beta Was this translation helpful? Give feedback.
All reactions