Replace show result with debug evaluate command
authorJeremy Stanley <fungi@yuggoth.org>
Sat, 3 Oct 2020 20:16:02 +0000 (20:16 +0000)
committerJeremy Stanley <fungi@yuggoth.org>
Wed, 7 Oct 2020 14:28:45 +0000 (14:28 +0000)
commitd1362ea83d4d7eae9dd786109c02224928b2bf01
tree72baa9a30743b24de34ab094545bc26bd69c0b1f
parent0ac91f791c2f9ff18ecd6a0390a78f5175cc3aa2
Replace show result with debug evaluate command

The show result subcommand was quite unsafe. Even though it limited
the globals for strings passed to the env() builtin, it was still
possible for admins to do things like call the exec() builtin and
then import other modules, or use open() to overwrite files
writeable by the user under which the engine was running.

Introduce a new evaluate command as a substitute and remove the show
result subcommand. Use the debugging framework to limit access to
evaluate so that it's only available if debug mode is enabled in the
configuration at the time the daemon is started. Further limit
evaluate to not have most of the normal builtins, and explicitly
reject any strings containing a double-underscore (__) so that base
attributes of other modules such as __builtins__ can't be called
into easily, or "lambda" so that lambda functions can't be used to
work around protections. Also add some selftests to make sure
evaluate can still use the expressions we previously tested with
show result, and that only administrators can use it, and that it's
only available to them when debug mode is enabled.

The evaluate command is still to be considered quite unsafe, and
debug mode should only be engaged when all administrators with
access to the service are trusted with the same permissions the
system account running the service also possesses.
doc/source/admin.rst
doc/source/coder.rst
mudpy/command.py
mudpy/tests/selftest.py
share/command.yaml