in reply to What restrictions are there on code execution when running perl in syntax check mode?
What code other than the BEGIN {} and CHECK {} blocks get executed
In Perl 5.10, add UNITCHECK.
Keep in mind that use has an implicit BEGIN.
Other language elements have compile-time effects (e.g. prototypes affect parsing, symbol names vivify entries in the symbol table), but I can't think of any other that will run code.
and under what conditions?
Unconditionally.
What restrictions are there on the kinds of code executed during the syntax check mode?
None.
How does taint mode behave?
Normally.
$ perl -c -Te'BEGIN { system "/bin/ls" }' Insecure $ENV{PATH} while running with -T switch at -e line 1. BEGIN failed--compilation aborted at -e line 1. $ perl -c -Te'BEGIN { $ENV{PATH}=""; system "/bin/ls" }' bin cdrom etc ... -e syntax OK
And if there are none, e.g. anything can be called, is this safe?
No more or less safe than calling it without -c.
What precautions do people use to make sure that code (especially someone else's code) is safe to syntax check?
Safe might help, but that's just a start.
Update: I meant to mention PPI. It might be a suitable alternative.
|
|---|