Repository navigation
Restore shell semantics and colored output #271
grisuno
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I fixed the functional regressions the security pass introduced.
The mechanism was a category error: treating a generic shell-command runner as
if it were an argv runner. Four runners had been switched to shlex.split with
shell=False while their contract was to run a command string, so shell syntax
silently stopped working: chaining, pipes, command substitution, globs, tilde
expansion and backgrounding. This broke linpeas, pipelines, and commands that
use ~ or *.
I added core.safe_exec.needs_shell, a single detector for the syntax a shell
must interpret, and used it in LazyOwnShell.cmd, core.process.run_command,
SafeRunner.run_shell and ResourceScript.run_command. When the syntax is present
the runner uses bash -c; otherwise the faster argv path stays.
The color loss had a different cause: the runners pipe stdout so they can tee
it to a log, and tools built on termenv (gum, used by the LazyNmap script)
disable color when stdout is not a terminal. core.hardening.terminal_env now
forces CLICOLOR_FORCE and FORCE_COLOR unless NO_COLOR is set.
linpeas also depended on a trailing ampersand reaching a shell through a pipe,
which deadlocks the log loop. It now starts the HTTP server detached with
start_new_session and no inherited pipe.
I generalized the guard: tests/test_shell_semantics.py pins the detection, the
environment and the detached server, and run_mutation_shell_semantics.py kills
a mutant that disables each rule.
The gui addons no longer hardcode a Qt venv path; they read
LAZYOWN_QT_SITE_PACKAGES and fall back to the active environment.
Validation: pytest 3621 passed, BDD 530 passed, mutation 12 of 12 runners
pass, ruff green.
All reactions