You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consistent documentation practices for security concerns and considerations #57724
This issue proposes that we adopt and apply some standard practices when documenting modules that have potential security implications and other cross-cutting errors that may affect multiple interfaces within the module.
Accordingly, the main target is the "Documenting Python" meta-docs, proposing the addition of a new subsection to the Style Guide, with an update to the subprocess module documentation serving as the exemplar of a new recommended style:
======================
2.6 Security Considerations (and Other Concerns)
------------------------------------------------
Some modules provided with Python are inherently exposed to security issues (e.g. shell injection vulnerabilities) due to the purpose of the module (e.g. subprocess invocation). Littering the documentation of these modules with red warning boxes for problems that are due to the task at hand, rather than specifically to Python's support for that task, doesn't make for a good reading experience.
Instead, these security concerns should be gathered into a dedicated "Security Considerations" section within the module's documentation, and cross-referenced from the documentation of affected interfaces with in-line text similar to "Please refer to the :ref:`security-considerations` section for important information on how to avoid common mistakes".
Similarly, if there is a common error that affects many interfaces in a module (e.g. OS level pipe buffers filling up and stalling child processes), these can be documented in a "Common Errors" section and cross-referenced rather than repeated for every affected interface.
======================
Grouping the common warnings in a "Security Considerations" section sounds OK, but the warnings should still be visible IMHO.
In my experience, people:
jump right to the doc for the function they are using;
read the example and try to figure out how it works;
if that fails, they read the text.
An inline text with a simple link might then pass unnoticed. OTOH littering the doc with red boxes is far too noticeable. Maybe we should use something in between (e.g. a "lighter" CSS for the warnings or a small warning icon).
While I acknowledge the point (it's the reason I *didn't* remove those warnings in my recent major update to the subprocess docs), Raymond's right that scattering warnings everywhere in the docs for modules like subprocess isn't the right answer either. For a lot of things people use those modules for (i.e. private scripts with no untrusted user input) the warnings are excessive.
There's only so much we can do to protect novice programmers being given tasks beyond their experience, and only so much readability we should sacrifice in the name of educating people about general programming issues that aren't specific to Python.
I think we are mixing a few different things here:
the content of the warning(s);
the position of the warning(s);
the style of the warning(s);
Duplicating the same content in each warning is bad, so a specific section that summarizes the problem is good.
Having at least a note with a link to the "Security consideration" section in each affected function is good too, because without them people won't notice it.
Having big red scary boxes is bad, because people are scared of big red things (especially scary ones), and our goal here is to warn, not to scare.
I think the problem with the subprocess doc is that there are many warnings and that they are big and red (and scary). IMHO changing the style of the warning would already be a step forward the "clean look" advocated by Raymond. Grouping redundant text and possibly rephrasing it a bit would do the rest.
Yep, using notes rather than simple inline links would also be fine with me. So, with "in-line text" changed to "a ReST note", what do people otherwise think about the proposed style guide addition?
Note sure about icon vs. text (“Warning:”) vs. colors. I think an icon would be as scary as the current big color boxes. I like Ezio’s change + Antoine’s indenting suggestion.
I don't really like the combination of the left bar and the background color. What about making the left bar thicker, and leaving out the background color?
Attached a patch that includes the section proposed by Nick in the first message. I also changed "in-line text" with "a note" as suggested in msg148720. I didn't specify a "ReST note" because I think that depending on the situation, an actual warning, a note, or even an in-line text might be acceptable.
Would it be appropriate to explicitly note that this is a relatively recent change of policy, so most of the stdlib docs don't actually follow it? (and patches to bring them into line would be reasonable)
Activity
ncoghlan commentedon Dec 1, 2011
This issue proposes that we adopt and apply some standard practices when documenting modules that have potential security implications and other cross-cutting errors that may affect multiple interfaces within the module.
Accordingly, the main target is the "Documenting Python" meta-docs, proposing the addition of a new subsection to the Style Guide, with an update to the subprocess module documentation serving as the exemplar of a new recommended style:
======================
2.6 Security Considerations (and Other Concerns)
------------------------------------------------
Some modules provided with Python are inherently exposed to security issues (e.g. shell injection vulnerabilities) due to the purpose of the module (e.g. subprocess invocation). Littering the documentation of these modules with red warning boxes for problems that are due to the task at hand, rather than specifically to Python's support for that task, doesn't make for a good reading experience.
Instead, these security concerns should be gathered into a dedicated "Security Considerations" section within the module's documentation, and cross-referenced from the documentation of affected interfaces with in-line text similar to "Please refer to the :ref:`security-considerations` section for important information on how to avoid common mistakes".
Similarly, if there is a common error that affects many interfaces in a module (e.g. OS level pipe buffers filling up and stalling child processes), these can be documented in a "Common Errors" section and cross-referenced rather than repeated for every affected interface.
======================
(based on the thread at http://mail.python.org/pipermail/python-dev/2011-December/114717.html)
ezio-melotti commentedon Dec 1, 2011
Grouping the common warnings in a "Security Considerations" section sounds OK, but the warnings should still be visible IMHO.
In my experience, people:
An inline text with a simple link might then pass unnoticed. OTOH littering the doc with red boxes is far too noticeable. Maybe we should use something in between (e.g. a "lighter" CSS for the warnings or a small warning icon).
ncoghlan commentedon Dec 1, 2011
While I acknowledge the point (it's the reason I *didn't* remove those warnings in my recent major update to the subprocess docs), Raymond's right that scattering warnings everywhere in the docs for modules like subprocess isn't the right answer either. For a lot of things people use those modules for (i.e. private scripts with no untrusted user input) the warnings are excessive.
There's only so much we can do to protect novice programmers being given tasks beyond their experience, and only so much readability we should sacrifice in the name of educating people about general programming issues that aren't specific to Python.
ezio-melotti commentedon Dec 1, 2011
I think we are mixing a few different things here:
Duplicating the same content in each warning is bad, so a specific section that summarizes the problem is good.
Having at least a note with a link to the "Security consideration" section in each affected function is good too, because without them people won't notice it.
Having big red scary boxes is bad, because people are scared of big red things (especially scary ones), and our goal here is to warn, not to scare.
I think the problem with the subprocess doc is that there are many warnings and that they are big and red (and scary). IMHO changing the style of the warning would already be a step forward the "clean look" advocated by Raymond. Grouping redundant text and possibly rephrasing it a bit would do the rest.
pitrou commentedon Dec 1, 2011
I agree 100% with Ezio here.
ncoghlan commentedon Dec 1, 2011
Yep, using notes rather than simple inline links would also be fine with me. So, with "in-line text" changed to "a ReST note", what do people otherwise think about the proposed style guide addition?
birkenfeld commentedon Dec 2, 2011
Please propose a concrete new styling for the warnings; I think that should be done regardless of the other points.
rhettinger commentedon Dec 2, 2011
Also consider writing a security howto guide so that the docs don't become littered with warnings.
pitrou commentedon Dec 3, 2011
For the record, the SSL module has a separate security considerations section:
http://docs.python.org/dev/library/ssl.html#security-considerations
ezio-melotti commentedon Dec 3, 2011
Attached a patch to make the CSS used for warnings and notes less evident by removing the red/gray background color.
pitrou commentedon Dec 3, 2011
This really years for an icon, IMO. A bit more indenting would be good,
too, so that it stands out clearly from the rest of the text.
merwok commentedon Dec 10, 2011
Note sure about icon vs. text (“Warning:”) vs. colors. I think an icon would be as scary as the current big color boxes. I like Ezio’s change + Antoine’s indenting suggestion.
ezio-melotti commentedon Dec 10, 2011
Georg, is the patch ok if I add a bit of indentation as suggested by Antoine?
1 remaining item
birkenfeld commentedon Dec 10, 2011
I don't really like the combination of the left bar and the background color. What about making the left bar thicker, and leaving out the background color?
ezio-melotti commentedon Jun 17, 2012
The new theme of the docs should solve the issue about the scary red boxes, but the original report is still valid.
ezio-melotti commentedon May 1, 2013
Attached a patch that includes the section proposed by Nick in the first message. I also changed "in-line text" with "a note" as suggested in msg148720. I didn't specify a "ReST note" because I think that depending on the situation, an actual warning, a note, or even an in-line text might be acceptable.
ncoghlan commentedon May 7, 2013
The new section looks good to me.
Would it be appropriate to explicitly note that this is a relatively recent change of policy, so most of the stdlib docs don't actually follow it? (and patches to bring them into line would be reasonable)
bitdancer commentedon May 7, 2013
Probably. Otherwise people are going to go look at the subprocess docs as an example...and they don't follow it.
pitrou commentedon May 7, 2013
Patch looks fine to me.
ezio-melotti commentedon May 7, 2013
We could use the SSL docs0 as example instead of subprocess.
python-dev commentedon Oct 21, 2013
New changeset 8bb5f4301e01 by Ezio Melotti in branch 'default':
bpo-13515: document security-related documentation practices.
http://hg.python.org/devguide/rev/8bb5f4301e01