Jeremy Stanley [Sat, 23 Oct 2021 17:07:58 +0000 (17:07 +0000)]
Switch back to normal PyYAML releases
Now that PyYAML 6.0.0 exists without the deprecated license_file
metadata, we can go back to consuming regular releases of that
package without breaking Python 3.11 testing.
Jeremy Stanley [Sat, 9 Oct 2021 17:03:32 +0000 (17:03 +0000)]
Add preliminary support for Python 3.11
Now that Python 3.10 is officially released and 3.11 is receiving
alpha versions, indicate that we're testing with 3.11 by updating
the trove classifiers for the Python package.
Because PyYAML is not yet building manylinux wheels for 3.11, re-add
the PYTHONWARNINGS exclusion for its Cython language_version
ambiguity (hopefully targeted for a fix soon in v6). Also pin our
minimum PyYAML requirement to the initial v6 beta version in order
to avoid needing to reintroduce the license_file DeprecationWarning
exclusion.
Jeremy Stanley [Sat, 9 Oct 2021 16:57:22 +0000 (16:57 +0000)]
Strip specifiers in dependency version strings
When comparing installed module names with the package dependencies,
chop off the version specifiers included with the requirements
strings in order to ease matching them.
Jeremy Stanley [Tue, 5 Oct 2021 01:44:37 +0000 (01:44 +0000)]
Adjust warning exclusions for Python 3.10
Drop some PYTHONWARNINGS ignore entries for exceptions which have
been fixed in dependencies, and add a new one for flake8's plugin
manager.
Jeremy Stanley [Thu, 23 Sep 2021 18:01:14 +0000 (18:01 +0000)]
Drop redundant license_files package metadata
As of wheel 0.32.0, with the introduction of the license_files meta
directive, the default is already to include any files matching the
glob patterns 'LICEN[CS]E*', 'COPYING*', 'NOTICE*', or 'AUTHORS*'
which covers our LICENSE and AUTHORS files well, so let's simplify
and clean it up.
Jeremy Stanley [Sun, 15 Aug 2021 20:08:37 +0000 (20:08 +0000)]
Update the copyright year in the LICENSE file
The copyright statement in the LICENSE file is intended to cover all
the files in the repository, so it should have the same end year as
the most recently edited files.
Jeremy Stanley [Sun, 15 Aug 2021 15:16:07 +0000 (15:16 +0000)]
Fail selftest if anything is written to stderr
The new ResourceWarning exceptions in Python 3.8 are ignored since
they're raised during garbage collection, which makes them easy to
miss even with PYTHONWARNINGS=error in our testing. Luckily, their
tracebacks are written to stderr, and we normally expect nothing
will be written to stderr on successful runs of the selftest script.
As a simple solution to avoid similar situations in the future,
cause the selftest run to fail if anything at all gets written to
the service's stderr.
Jeremy Stanley [Sun, 15 Aug 2021 15:13:32 +0000 (15:13 +0000)]
Close included files after reading
Use a context block where raw files are included by our macro
replacement routine, so that we'll close the file descriptors once
we're finished reading them in.
Jeremy Stanley [Sun, 15 Aug 2021 15:10:18 +0000 (15:10 +0000)]
Close data files after reading
Starting with Python 3.8, the interpreter raises a ResourceWarning
exception during garbage collection if it finds an unclosed file
descriptor. Because of where this exception gets raised, it's
ignored (but a warning is emitted on stderr).
Use a typical context block in our loop to load data files, so that
this condition won't occur.
Jeremy Stanley [Sun, 15 Aug 2021 13:51:58 +0000 (13:51 +0000)]
Adjust Telnet echo state on connection replacement
When a new connection authenticates for the same account as an
established one, we jump straight from the password entry state to
whatever state the old connection was in. Because password entry
disables local echo in order to hide the user's input from the
screen, we need to make sure that the new connection's Telnet
options are copied to the user object and then inject a negotiation
to cause the Telnet stack to normalize to the echo setting for the
new state.
Jeremy Stanley [Tue, 20 Jul 2021 15:09:29 +0000 (15:09 +0000)]
Ignore warnings building PyYAML wheels on 3.10.0b4
Recent versions of pip and wheel are raising DeprecationWarning when
trying to build wheels of PyYAML due to deprecated license_file
metadata, solved once https://github.com/yaml/pyyaml/pull/536 lands
and is included in a new release.
Recent Cython is raising a FutureWarning when trying to build wheels
of PyYAML due to a missing language_version option, solved once
https://github.com/yaml/pyyaml/pull/539 lands and is included in a
new release.
Jeremy Stanley [Mon, 5 Jul 2021 16:32:19 +0000 (16:32 +0000)]
Update copyright year in built documentation
We've made changes to documentation this year, but neglected to
update the copyright year in the footer of built docs, so do that
now.
Jeremy Stanley [Mon, 5 Jul 2021 13:03:44 +0000 (13:03 +0000)]
Use build instead of setup.py
Start transitioning into the PEP517 future of Python packaging by
switching from explicitly calling setup.py to using the build
module. Move install requirements into setup.cfg and update the
install docs to refer to the new location. Get rid of the separate
documentation build requirements file by moving into tox.ini deps
for the docs testenv. While we're there, add some commentary in the
tox.ini about some of the more opaque choices we've made for docs
builds and testing YAML style.
Jeremy Stanley [Sat, 5 Jun 2021 00:16:56 +0000 (00:16 +0000)]
Update test warnings for Python 3.10.0b2
Switch our PYTHONWARNINGS in tox.ini to use a string match on some
warnings which have become increasingly common for more modules
under Python 3.10.0b2. For those which can't be covered effectively
by matching their messages, get more specific by adding the
exception names to the current module exclusions. Hopefully this
will allow for fairly narrow warning filters while minimizing the
need for future additions, at least to the extent that's possible.
Jeremy Stanley [Sun, 9 May 2021 16:18:30 +0000 (16:18 +0000)]
Update test warnings for Python 3.9.5 and 3.10.0b1
Adjust our PYTHONWARNINGS in tox.ini to add some new exclusions for
warnings appearing in Python 3.10.0b1, and also clean up some which
were resolved by it and by Python 3.9.5. Adjust the code comments
documenting these accordingly.
Jeremy Stanley [Sun, 2 May 2021 19:07:34 +0000 (19:07 +0000)]
Alphabetize entries in command data file
The refactoring which led to the evaluate debug command left it out
of alpha order in share/command.yaml, so correct that now.
Jeremy Stanley [Mon, 26 Apr 2021 01:21:45 +0000 (01:21 +0000)]
Be more robust with elapsed time counter
Stress testing identified a rare startup race if a user connected
before the elapsed time counter was initialized. The odds of
encountering this in the wild are close to nonexistent, but it was
introducing occasional test failures.
Solve the race by reordering the actions taken on each pulse, so
that the counter is initialized before the listening socket is
created. Also force all access to the counter through setter/getter
methods and wrap in try/except to always return a value and properly
create the counter and containing element if it doesn't yet exist.
Jeremy Stanley [Sat, 17 Apr 2021 16:07:33 +0000 (16:07 +0000)]
Retry client connections in selftest
Replace a hard-coded delay after process start with a dynamic client
connection retry, which attempts to connect up to five times with
the first being immediate while subsequent connections observe an
exponential backoff over a three-second period before giving up.
This improves both speed and stability of test runs.
Also combine the ConnectionResetError and EOFError conditions which
could be raised later once the socket is in use, as the end result
of either is effectively the same.
Jeremy Stanley [Sat, 17 Apr 2021 16:05:03 +0000 (16:05 +0000)]
Don't wait during selftest process cleanup
Remove an unconditional one-second delay after executing kill during
process cleanup. Subsequent torture tests indicate this was likely
unnecessary, but it slowed down testing considerably.
Jeremy Stanley [Sat, 17 Apr 2021 15:59:18 +0000 (15:59 +0000)]
Don't leave dangling file descriptor in selftest
Use context management when opening the configuration file in
selftests so that its file descriptor will be cleaned up as soon as
loading completes.
Jeremy Stanley [Sat, 17 Apr 2021 15:47:18 +0000 (15:47 +0000)]
Make dist checking directory-agnostic
Use the toxindir replacement macro in tox.ini to properly anchor the
base directory for dist building and checking. This ensures it will
run successfully even if the current working directory is not the
top level directory of the source tree.
Jeremy Stanley [Sat, 17 Apr 2021 15:44:36 +0000 (15:44 +0000)]
Get more granular with Python warnings in tests
Apparently, the PYTHONWARNINGS envvar has a rather flexible grammar
which can do things like exclude specific modules. Take advantage of
this to temporarily whitelist persistent problems in dependencies
(particularly packaging ecosystem tools/libraries) until they're
solved by their respective upstreams.
Jeremy Stanley [Sat, 17 Apr 2021 15:42:21 +0000 (15:42 +0000)]
Use consistent spacing in tox variables and lists
Tox is fine with spaces between list elements and variable
assignment operators. We used more readable spacing in some parts of
tox.ini, so make the rest of the file consistent.
Jeremy Stanley [Sat, 17 Apr 2021 15:38:47 +0000 (15:38 +0000)]
Stop setting a default install command for tox
The install command we've been setting for tox is effectively
equivalent to its internal default. Just drop it.
Jeremy Stanley [Sat, 17 Apr 2021 15:34:30 +0000 (15:34 +0000)]
Don't check spelling in data directory
The selftest can write some fairly random strings into ephemeral
files in the data directory, which get left behind and might trigger
false positives for codespell. None of what appears in this
directory is committed into source control, so we really don't care.
Just skip checking it.
Jeremy Stanley [Sat, 6 Mar 2021 02:38:00 +0000 (02:38 +0000)]
Lint autogenerated YAML
Run the selftest before calling yamllint, so that we can confirm the
YAML files generated by the data module follow the same format as
those shipped in the repository.
Jeremy Stanley [Sat, 6 Mar 2021 02:34:40 +0000 (02:34 +0000)]
Use twine's strict mode
Twine has added a --strict option, and for now it succeeds testing
our build artifacts, so start using it.
Jeremy Stanley [Sat, 6 Mar 2021 02:28:42 +0000 (02:28 +0000)]
Stop trying to use PYTHONWARNINGS=error for now
Additional deprecations in Setuptools have made trying to treat them
as errors basically insurmountable, and will likely remain that way
in some of the older Python interpreters we still support. Update
the comments in tox.ini in an attempt to track the latest blockers.
Jeremy Stanley [Sat, 6 Mar 2021 02:18:42 +0000 (02:18 +0000)]
Add descriptions to tox testenvs
Include a one-line description for each testenv in the tox.ini file,
useful for generally documenting what they're for, and displayed by
the `tox -lv` command.
Jeremy Stanley [Sat, 6 Mar 2021 02:05:50 +0000 (02:05 +0000)]
Stop using the tox-venv plugin
The tox-venv plugin is deprecated, now that tox can call the venv
module directly in place of virtualenv. Drop it, stop recommending
it in the documentation, and configure tox to use venv explicitly
instead.
Jeremy Stanley [Mon, 22 Feb 2021 07:43:12 +0000 (07:43 +0000)]
Correct package metadata
The platforms and classifiers parameters in setup.cfg are supposed
to be plural, their singular forms are deprecated. Update them
accordingly.
Jeremy Stanley [Sat, 30 Jan 2021 01:06:16 +0000 (01:06 +0000)]
Bind to loopback interface by default
Adjust the fallback behavior for otherwise unconfigured address
binding to match the safe posture adopted in the sample
configuration.
Jeremy Stanley [Thu, 3 Dec 2020 19:31:58 +0000 (19:31 +0000)]
Use released codespell
Now that codespell has cut a release supporting in-repo
configuration, simplify our tox testenv for it accordingly. Also
update the status on the deprecation warnings situation, as the
latest blockers now lie with Setuptools rather than PBR.
Jeremy Stanley [Sun, 1 Nov 2020 16:52:07 +0000 (16:52 +0000)]
Switch the selftest dialogue to a normal dict
Starting with Python 3.6, dicts are implicitly ordered (albeit as a
side effect in 3.6, 3.7 is consistent with 3.6 and guarantees
ordering in interpreter versions from that point on). We no longer
need to use collections.OrderedDict for the selftest dialogue as a
result, so use a regular dict there now to simplify it.
Jeremy Stanley [Sun, 1 Nov 2020 16:48:25 +0000 (16:48 +0000)]
Use PosixPath arguments with os.remove()
Starting with Python 3.6, it's possible to pass a PosixPath to the
os.remove function instead of having to use the .name attribute.
Jeremy Stanley [Sun, 1 Nov 2020 16:46:44 +0000 (16:46 +0000)]
Always use ModuleNotFoundError
Now that we no longer support Python 3.5, we can assume
ModuleNotFoundError is always available and drop our
backward-compatible workaround for it in version.py.
Jeremy Stanley [Sun, 1 Nov 2020 16:10:17 +0000 (16:10 +0000)]
Drop support for Python 3.5
It's been a couple of months since Python 3.5 officially reached end
of life, so stop advertising support in preparation for beginning to
use features only available in Python 3.6 and later.
Jeremy Stanley [Fri, 9 Oct 2020 16:55:20 +0000 (16:55 +0000)]
Move debug warning from setup to load
Relocate the warning logged about debug mode from the misc.setup()
function to the Universe class load() method. This way, if debug
mode is enabled in configuration during a live reload event, it will
be logged. Also update the admin documentation to reflect that
enabling or disabling debug can be done with a reload, not only a
restart. Correct a minor spacing error in the configuration docs
too.
Jeremy Stanley [Fri, 9 Oct 2020 16:42:04 +0000 (16:42 +0000)]
Incorporate pending logs from load during reloads
The load() method for Universe class objects accumulates potential
log entries because it can be called when logging hasn't been set up
yet (for example, early at service start). When called during a
reload, these messages were previously discarded. Instead, add them
to the loglines attribute of the new universe so they will get
properly logged.
Jeremy Stanley [Fri, 9 Oct 2020 16:35:46 +0000 (16:35 +0000)]
Reorder loglines fields
Switch the Universe.loglines attribute's structure to place the log
message first and the log level value second, so that it's
consistent with the order in which those parameters are supplied by
the misc.log() function. While we're adjusting this in the
misc.get_loglines() function, switch the output construction from
concatenation to format strings for improved manageability.
Jeremy Stanley [Wed, 7 Oct 2020 15:54:20 +0000 (15:54 +0000)]
Recast is_restricted() to a bool
When returning from the is_restricted function, just coerce the
lookups to a boolean type rather than forcing False defaults for
each facet.
Jeremy Stanley [Wed, 7 Oct 2020 15:51:01 +0000 (15:51 +0000)]
The del and return statements aren't functions
Correct a number of uses of del and return which had superfluous
parentheses. These are statement keywords, not function names, so
don't require parentheses around their expressions.
Jeremy Stanley [Wed, 7 Oct 2020 15:34:02 +0000 (15:34 +0000)]
Support Python 3.10
Update the package's trove metadata to indicate support for Python
3.10 now that 3.10.0a1 has been tagged.
Jeremy Stanley [Wed, 7 Oct 2020 15:27:33 +0000 (15:27 +0000)]
Don't fail dist or docs builds on deprecations
The current deprecation issues in dependencies raise warnings for
the dist and docs tox environments when run with Python 3.9 as the
default python3 interpreter. Use the same exclusions in the base
testenv definition for them now, until the maintainers of those
dependencies release updates.
Jeremy Stanley [Sat, 3 Oct 2020 20:16:02 +0000 (20:16 +0000)]
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.
Jeremy Stanley [Sat, 3 Oct 2020 19:04:58 +0000 (19:04 +0000)]
Run different selftests when debug mode is engaged
Add two skiplist tuples to the selftest framework, one for tests to
remove when debug mode is on, another for tests to remove when debug
mode is off. This is not used yet, so the tuples are initially
empty. Also enable debug mode in the daemon config fixture so that
debug functionality can be tested in the normal selftest run. The
default example config (tested with tox -e selftest_config) covers
the debug disabled case.
Jeremy Stanley [Sun, 4 Oct 2020 15:11:58 +0000 (15:11 +0000)]
Add warnings about debugging mode
Debugging mode is intended to enable administrative commands which
are especially unsafe and could even be used to run arbitrary shell
commands or alter files accessible to the user under which the
service runs. Log a warning about it at startup if the option has
been set, and insert some comments to that effect in the sample
configuration so that hopefully no one will turn it on without due
forethought. Also add a mention about its risks in the config doc.
Jeremy Stanley [Sat, 3 Oct 2020 18:09:10 +0000 (18:09 +0000)]
Add restricted debug mode
Create a new configuration flag, .mudpy.limit.debug, which indicates
unsafe debugging options will be available in the running engine.
This is unused, but lays the groundwork for future unsafe commands
to be toggled at start in base configuration.
Jeremy Stanley [Sat, 3 Oct 2020 17:45:47 +0000 (17:45 +0000)]
Make selftest dialogue mutable
In order to support future selectivity of test sets, replace the
immutable tuple of all tests with a dict keyed by test object.
Iterate over a copy of it so that the original is not altered when
tests are eventually removed during runtime. For Python 3.5 and
earlier, use OrderedDict so that test order is explicitly preserved.
Jeremy Stanley [Sat, 3 Oct 2020 17:32:56 +0000 (17:32 +0000)]
Skip spellcheck on logfiles
Add any filenames ending with .log to the skiplist for codespell
testing.
Jeremy Stanley [Fri, 2 Oct 2020 19:59:45 +0000 (19:59 +0000)]
Add is_restricted boolean check for commands
In preparation for adding additional command restriction indicators,
add a simple Element class method to return whether a command
element is flagged as administrative.
Jeremy Stanley [Wed, 30 Sep 2020 19:57:13 +0000 (19:57 +0000)]
Add is_admin method to Element and User classes
For clarity and convenience, create an is_admin() boolean check for
whether a User's account or an actor Element's owner's account is
flagged as an administrator. Put them to use in places where the
administrator facet was previously checked directly. This allows us
to do a little additional safety checking to avoid hitting corner
cases where we try to check some object which may or may not have an
owner.
Jeremy Stanley [Wed, 30 Sep 2020 18:07:46 +0000 (18:07 +0000)]
Streamline can_run access control method
Minor rework of can_run() to replace the chain of elifs with simple
short-circuiting conditions each with its own return() so that it's
clearer this operates in a "first match" model.
Jeremy Stanley [Sat, 19 Sep 2020 14:34:43 +0000 (14:34 +0000)]
Check for warnings in the to dist env
Some deprecated Setuptools operations were removed in a recent PBR
release, allowing us to now build sdist and wheel artifacts with
warnings as errors. There are still a couple more outstanding
deprecation fixes needed for other envs, so update the comment in
tox.ini accordingly.
Jeremy Stanley [Sat, 19 Sep 2020 14:32:11 +0000 (14:32 +0000)]
Explicitly close files opened by selftest
Newer Python interpreters emit a warning during cleanup if open
files are not closed prior to termination. Our selftest opens the
pidfile for reading in a couple of places, as well as logfiles to
capture stdout/stderr. Open them in context blocks so they will be
closed on return rather than remaining open until the process ends.
Jeremy Stanley [Sat, 19 Sep 2020 14:29:59 +0000 (14:29 +0000)]
Handle early wrapping in test_show_result
When showing a Python module object, the included file path can
easily be long enough to wrap to the next line. Allow for line
breaks immediately before it in the test_show_result test where it
sometimes surfaces.
Jeremy Stanley [Sat, 19 Sep 2020 14:28:11 +0000 (14:28 +0000)]
Drop redundant master_doc setting from Sphinx conf
The master_doc option to Sphinx already defaults to looking for a
document named "index" so it's unnecessary to set explicitly in our
case. Clean it up.
Jeremy Stanley [Wed, 16 Sep 2020 22:38:28 +0000 (22:38 +0000)]
Switch tox to use allowlist_externals
The whitelist_externals option in tox in deprecated in favor of
allowlist_externals. Update this and also bump our tox minversion to
the earliest version which supports this new syntax. While we're at
it, update a few code comments about bandit "nosec" exceptions to
refer to allowing instead of whitelisting.
Jeremy Stanley [Wed, 16 Sep 2020 22:24:02 +0000 (22:24 +0000)]
Start checking codebase with the codespell tool
Use master branch tip of codespell for now, until it supports
configuration in the included .codespellrc in a released version.
Also correct things its default dictionary selection identified as
misspellings, with the exception of intentional misspellings in the
sample spelling correction config and selftest which exercises it.
Jeremy Stanley [Sun, 23 Aug 2020 21:38:37 +0000 (21:38 +0000)]
Revert "No longer run setup.py in docs builds"
Turns out, PBR won't generate the ChangeLog without an explicit
install/build after all, or at least not in the way which tox is
handling it. This slipped through testing due to not running in a
clean tree.
This reverts commit
70381626690da47866363ef51ef8a37a4831dffa.
Jeremy Stanley [Sun, 23 Aug 2020 21:14:43 +0000 (21:14 +0000)]
Ratchet down Python warnings in tox
Where possible, have tox envs treat any Python warning as an error.
This is not currently possible for any envs which invoke certain PBR
functionality, since it has a couple of outstanding fixes under
review to make it cease calling into deprecated code on newer Python
releases. Eventually this should be set in the global testenv when
possible, and only rolled back in case of dependency regressions or
new errors introduced by future interpreter versions.
Jeremy Stanley [Wed, 12 Aug 2020 09:56:24 +0000 (09:56 +0000)]
No longer run setup.py in docs builds
Since we don't skip sdist generation for our documentation builds in
tox, the separate setup.py install step is unnecessary as PBR will
already generate a current ChangeLog when the sdist is built.
Jeremy Stanley [Mon, 3 Aug 2020 10:35:10 +0000 (10:35 +0000)]
Set python_requires
Newer versions of pip will check PyPI for python_requires metadata,
helping to determine prior to package download if the local version
of the interpreter is sufficiently new to support a given package
version. Set ours to >= 3.5 for now. This should be increased any
time support for an old interpreter release is dropped from the list
in our trove classifiers.
Jeremy Stanley [Tue, 7 Jul 2020 10:50:19 +0000 (10:50 +0000)]
Correct package metadata
Use the more correct metadata fields recognized by
Setuptools/distutils rather in lieu of some used only by PBR.
Jeremy Stanley [Tue, 2 Jun 2020 23:12:45 +0000 (23:12 +0000)]
Report if service does not start under selftest
Output a useful error and stop the selftest script immediately if
the service it tries to start does not actually start, to make
debugging some classes of errors slightly faster.
Jeremy Stanley [Sat, 23 May 2020 20:11:18 +0000 (20:11 +0000)]
Prefer importlib over pkg_resources
Since Setuptools pkg_resources library is effectively deprecated in
newer releases, try to use the equivalent importlib.metadata
features and exceptions when they're available.
Jeremy Stanley [Wed, 22 Apr 2020 19:54:54 +0000 (19:54 +0000)]
Record the reported rows from NAWS negotiation
In preparation for future pagination support, get the rows included
in NAWS responses and record that as an integer in the User.rows
attribute, similar to the existing User.columns value used for line
wrapping.
Jeremy Stanley [Sun, 12 Apr 2020 20:17:57 +0000 (20:17 +0000)]
Obtain terminal type (RFC 1091)
Implement rudimentary support for determining the terminal type
reported by RFC 1091 TTYPE compatible clients, and store any initial
value returned in the User.ttype attribute. This implementation does
not iterate over SEND TTYPE commands until UNKNOWN is returned, it
only takes the first value returned and assumes this is the default
terminal type for the user's current connection.
Jeremy Stanley [Sat, 21 Mar 2020 03:25:14 +0000 (03:25 +0000)]
Overhaul coder guide, add commands and misc
Brush up the quality of the coder guide, using relevant autodoc
references and clearer markup, as well as improving some wording.
Add a section on custom commands, and another for miscellaneous
design discussions taken from various recent E-mail threads.
Jeremy Stanley [Fri, 7 Feb 2020 08:12:17 +0000 (08:12 +0000)]
Start the install guide
Create a stub document with some installation and configuration
tips, to be expanded into something more useful over time.
Jeremy Stanley [Sun, 12 Jan 2020 08:04:54 +0000 (08:04 +0000)]
Add the beginnings of an admin guide
Some initial prose to seed the admin guide, taken from various
E-mails to users in recent months.
Jeremy Stanley [Wed, 8 Jan 2020 23:29:54 +0000 (23:29 +0000)]
Collapse redundant exceptions
In User.enqueue_input() combine a redundant match on BlockingIOError
and OSError since the former is a subclass of the latter. This was
caught by the B014 check introduced in flake8-bugbear 20.1.1.
Jeremy Stanley [Tue, 7 Jan 2020 00:45:35 +0000 (00:45 +0000)]
Indicate support for Python 3.9
Python 3.9 is well into its second alpha, is a recognized trove
classifier on PyPI, and all mudpy changes are being successfully
tested against it. Add the classifier to our package metadata to
reflect this.
Jeremy Stanley [Tue, 7 Jan 2020 00:43:14 +0000 (00:43 +0000)]
Link the ChangeLog from package metadata
Users of PyPI are going to want to know where to find the ChangeLog
without going to the project homepage/docs and hunting around. Add a
flexible redirect URL for it so we can move it easily later.
Jeremy Stanley [Tue, 7 Jan 2020 00:38:14 +0000 (00:38 +0000)]
Drop section numbering from documentation builds
Sphinx section numbering leads to confusing output, particularly for
the rendered ChangeLog. Remove it.
Update copyright year in the LICENSE as this is the first change of
the new year, and similarly update it in rendered documentation
footers as this is the first documentation change of the year.
Jeremy Stanley [Mon, 30 Dec 2019 17:52:01 +0000 (17:52 +0000)]
Make sure all command functions return True
Because recent adjustments to handler_active() rely on the
call_handler_function() return value to determine whether something
went wrong, we need command functions to return something which
evaluates boolean True if they ran to completion and didn't raise an
exception. Just return True from all of them for now, but they may
see more dynamic result handling in the future.
Jeremy Stanley [Mon, 30 Dec 2019 15:41:34 +0000 (15:41 +0000)]
Increase timer resolution in test config
Significantly speed up the timer in the test config (by a factor of
1000). On fast machines with cached tox envs, this results in an
order of magnitude improvement in test runtime. Related timer values
are lengthened to avoid test failures due to timeouts, and some
others are shortened for consistency.
This is obviously not suitable for normal operation, so the sample
configuration remains untouched and thus the tox selftest_config
testenv does not benefit from it.
Jeremy Stanley [Mon, 30 Dec 2019 15:18:52 +0000 (15:18 +0000)]
Use call_hook_function() in handler_active()
Simplify mudpy.misc.handler_active() by making it a wrapper around
the more general mudpy.misc.call_hook_function() which was
originally derived from it.
Jeremy Stanley [Mon, 30 Dec 2019 01:49:32 +0000 (01:49 +0000)]
Preserve loglines on reload
When a reload occurs, prepend the new universe's loglines with those
from the old universe so they are not lost. This may temporarily
bloat the loglines list slightly over the limit, but it will be
adjusted downward the next time anything new gets logged. Also
adjust the `show log` selftests to handle linewraps in a new place
when the total loglines count is higher.
Jeremy Stanley [Sun, 29 Dec 2019 14:25:17 +0000 (14:25 +0000)]
Set bandit to error on risks of any severity
Now that the last of the low-level risks has been reviewed and
whitelisted, remove the severity filter from the bandit command so
that incorporation of any unexpected risks it can spot will be
blocked for future commits.
Jeremy Stanley [Sun, 29 Dec 2019 14:19:57 +0000 (14:19 +0000)]
Whitelist uses of stdlib random module for bandit
There are currently two uses of random.randrange() and one of
random.choice() for non-security/non-crypto purposes. Mark them as
whitelisted for bandit checks and add comments explaining why.
Jeremy Stanley [Sun, 29 Dec 2019 12:31:36 +0000 (12:31 +0000)]
Clean up function names in menu definitions
Now that the functions called from menus are filtered and resolved
safely rather than being directly executed, the explicit mudpy
package name and the user parameter passing are no longer necessary.
Remove them from the function names in menu definitions and also
drop the old compatibility code which trims them.
Jeremy Stanley [Sun, 29 Dec 2019 12:23:44 +0000 (12:23 +0000)]
Ratchet bandit checking down to medium severity
Now that the last of the medium-severity risks have been eliminated,
adjust the bandit command line so that it will prevent addition of
any new instances.
Jeremy Stanley [Sat, 28 Dec 2019 21:01:32 +0000 (21:01 +0000)]
Replace eval() and exec() use for menu functions
Add a new misc.call_hook_function() routine based on the existing
command execution in misc.handler_active() to eliminate all use of
eval() and exec() built-ins in menu operations.
Jeremy Stanley [Thu, 26 Dec 2019 02:45:25 +0000 (02:45 +0000)]
Relocate main_utility menu functions
Move the action and demand logic for the main_utility state from
their respective facets to the menu module, hiding them behind
consistently-named entry points.
Jeremy Stanley [Wed, 25 Dec 2019 22:49:48 +0000 (22:49 +0000)]
Relocate delete_avatar menu functions
Move the action and create logic for the delete_avatar state from
their respective facets to the menu module, hiding them behind
consistently-named entry points.
Jeremy Stanley [Wed, 25 Dec 2019 22:23:08 +0000 (22:23 +0000)]
Relocate delete_account menu function
Move the action logic for the delete_account state from its
corresponding facet to the menu module, hiding it behind a
consistently-named entry point.
Jeremy Stanley [Wed, 25 Dec 2019 22:13:16 +0000 (22:13 +0000)]
Relocate choose_name menu functions
Move the action and create logic for the choose_name state from
their respective facets to the menu module, hiding them behind
consistently-named entry points.
Jeremy Stanley [Wed, 25 Dec 2019 21:52:02 +0000 (21:52 +0000)]
Relocate choose_gender menu function
Move the action logic for the choose_gender state from its
corresponding facet to the menu module, hiding it behind a
consistently-named entry point.
Jeremy Stanley [Wed, 25 Dec 2019 21:45:45 +0000 (21:45 +0000)]
Relocate checking_new_account_name menu functions
Move the action logic for the checking_new_account_name state from
its respective facets to the menu module, hiding them behind
consistently-named entry points.
Jeremy Stanley [Wed, 25 Dec 2019 20:02:41 +0000 (20:02 +0000)]
Relocate activate_avatar menu functions
Move the action and create logic for the activate_avatar state from
their respective facets to the menu module, hiding them behind
consistently-named entry points.
Jeremy Stanley [Tue, 24 Dec 2019 22:55:01 +0000 (22:55 +0000)]
Add a mudpy.menu module to hold menu functions
In preparation for relocating arbitrary Python expressions out of
the standard menu elements, provide a stub mudpy.menu module which
will house equivalent convenience functions and include an autodoc
section for it in the Sphinx API documentation template.
Jeremy Stanley [Wed, 25 Dec 2019 21:24:06 +0000 (21:24 +0000)]
Move selected menu item into the User object
In order to simplify menu handlers, move the active choice into an
attribute of the User class so that only one object needs to be
handed off, and update menus accordingly.
Jeremy Stanley [Wed, 25 Dec 2019 13:12:43 +0000 (13:12 +0000)]
Rename state variable in get_menu_choices()
Avoid shadowing the new menu module in misc.get_menu_choices() by
renaming its menu variable to state, which is also more consistent
with other menu-related functions.
Jeremy Stanley [Tue, 24 Dec 2019 22:37:18 +0000 (22:37 +0000)]
Remove exec() from handle_user_input() function
Stop passing the constructed handler function name into an exec()
and instead reference it from the globals() dict.
Jeremy Stanley [Tue, 24 Dec 2019 22:23:32 +0000 (22:23 +0000)]
Eliminate exec() in Universe.new()
Replace questionable exec call in the new() method of the Universe
class with cleaner getattr/setattr equivalents.
Jeremy Stanley [Thu, 26 Dec 2019 01:57:24 +0000 (01:57 +0000)]
More thoroughly test account and avatar menus
Split up the teardown "test" into separate tests for avatar and
account deletion. Avatar deletion was previously not being exercised
correctly, instead avatar deletion aborting was what was actually
being tested. Add separate tests that the avatar and account
deletion default actions are to abort. Also add a test of the avatar
creation limit.
Jeremy Stanley [Wed, 25 Dec 2019 23:04:20 +0000 (23:04 +0000)]
Properly escape punctuation in test patterns
Make sure all literal question marks (?) and periods (.) in selftest
match patterns are backslash-escaped in raw strings.
Jeremy Stanley [Tue, 24 Dec 2019 21:33:37 +0000 (21:33 +0000)]
Tighten up eval() scope in show result subcommand
In order to slightly reduce risk but mostly to increase convenience
with the `show result` administrative subcommand, replace its eval()
invocation's globals with just the mudpy module namespace and the
actor's universe pointer as "universe" (this way exploratory
expressions don't need to do things relative to actor.universe all
the time). Extend the selftest to confirm these are present and that
any attempts to access other globals and locals within the
command.show() function's scope raise an exception.
Whitelist this intentional use of eval() for bandit analysis.
Jeremy Stanley [Sun, 22 Dec 2019 20:48:12 +0000 (20:48 +0000)]
Replace uses of exec() in module loader
Improve the module loader to avoid the more dangerous exec()
function in favor of smarter use of importlib. This allows us to
drop some flake8 whitelisting. Also switch out the hard-coded module
list (which missed addition of the daemon module) with a more
dynamic routine on Python 3.7 and later, which will use all *.py
files in the top level of the package so none are forgotten in the
future. Keep a hard-coded fallback list for support of earlier
Python versions, but compare the two so this list is guaranteed
complete for as long as it is maintained.