1
0
mirror of https://github.com/php/doc-en.git synced 2026-04-25 08:18:10 +02:00
Files

122 lines
4.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="reference.luasandbox.differences">
<title>Differences from Standard Lua</title>
<simpara>
LuaSandbox provides a sandboxed environment which differs in some ways from standard Lua 5.1.
</simpara>
<simplesect xml:id="reference.luasandbox.differences.unavailable">
<title>Features that are not available</title>
<itemizedlist>
<listitem>
<simpara>
<literal>dofile()</literal>, <literal>loadfile()</literal>, and the <literal>io</literal> package, as they allow direct filesystem access. If needed, filesystem access should be done via PHP callbacks.
</simpara>
</listitem>
<listitem>
<simpara>
The <literal>package</literal> package, including <literal>require()</literal> and <literal>module()</literal>, as it depends heavily on direct filesystem access. A pure-Lua rewrite such as that used in the MediaWiki Scribunto extension may be used instead.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>load()</literal> and <literal>loadstring()</literal>, to allow for static analysis of Lua code.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>print()</literal>, since it outputs to standard output. If needed, output should be done via PHP callbacks.
</simpara>
</listitem>
<listitem>
<simpara>
Most of the <literal>os</literal> package, as it allows manipulation of the process and executing of other processes.
</simpara>
<itemizedlist>
<listitem>
<simpara>
<literal>os.clock()</literal>, <literal>os.date()</literal>, <literal>os.difftime()</literal>, and <literal>os.time()</literal> remain available.
</simpara>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<simpara>
Most of the <literal>debug</literal> package, as it allows manipulation of Lua state and metadata in ways that can break sandboxing.
</simpara>
<itemizedlist>
<listitem>
<simpara>
<literal>debug.traceback()</literal> remains available.
</simpara>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<simpara>
<literal>string.dump()</literal>, as it may expose internal data.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>collectgarbage()</literal>, <literal>gcinfo()</literal>, and the <literal>coroutine</literal> package have not been reviewed for security.
</simpara>
</listitem>
</itemizedlist>
</simplesect>
<simplesect xml:id="reference.luasandbox.differences.modified">
<title>Features that have been modified</title>
<itemizedlist>
<listitem>
<simpara>
<literal>pcall()</literal> and <literal>xpcall()</literal> cannot catch certain errors, particularly timeout errors.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>tostring()</literal> does not include pointer addresses.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>string.match()</literal> has been patched to limit the recursion depth and to periodically check for a timeout.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>math.random()</literal> and <literal>math.randomseed()</literal> are replaced with versions that don't share state with PHP's <literal>rand()</literal>.
</simpara>
</listitem>
<listitem>
<simpara>
The Lua 5.2 <literal>__pairs</literal> and <literal>__ipairs</literal> metamethods are supported by <literal>pairs()</literal> and <literal>ipairs()</literal>.
</simpara>
</listitem>
</itemizedlist>
</simplesect>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->