A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-September/141467.html below:

[Python-Dev] PEP 501 Shell Command Examples

[Python-Dev] PEP 501 Shell Command ExamplesNikolaus Rath Nikolaus at rath.org
Sat Sep 5 19:54:20 CEST 2015
On Sep 05 2015, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On 5 September 2015 at 12:36, Nikolaus Rath <Nikolaus at rath.org> wrote:
>> Hi Nick,
>>
>> You are giving
>>
>>   runcommand(sh(i"cat {filename}"))
>>
>> as an example that avoids injection attacks. While this is true, I think
>> this is still a terrible anti-pattern[1] that should not be entombed in
>> a PEP as a positive example.
>>
>> Could you consider removing it?
>>
>> (It doubly wastes resources by pointlessly calling a shell, and then by
>> parsing & quoting the argument only for the shell to do the same in
>> reverse).
>
> Any reasonable implementation of that pattern wouldn't actually call a
> system shell, it would invoke something like Julia's command system.

That's obvious to someone like you who thinks about this in terms of the
best implementation.

To someone less experienced, or just coming at from a different angle,
this example just says "writing a shell command is a good way to start
an external program, as long as I take care of quoting".


Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4