Context
From PR #13 code review.
Problem
In nightshift/cycle.py line 464-468, _extract_shell_command() uses a regex that only matches the -lc 'body' or -lc "body" shell wrapper pattern:
def _extract_shell_command(command: str) -> str:
shell_match = re.search(r"-lc\s+['\"](?P<body>.+?)['\"]$", command)
if shell_match:
return shell_match.group("body").strip()
return command.strip()
If an agent wraps commands differently (e.g. bash -c "cmd", sh -c 'cmd', or no wrapper at all with just the raw command), this won't extract the inner command and the forbidden command check could miss violations.
Suggested fix
Broaden the regex to also handle bash -c, sh -c, and /bin/sh -c patterns, or extract more generically. The current approach is a reasonable tradeoff (avoids false positives), but documenting the limitation with a comment would also be acceptable as a minimal fix.
Context
From PR #13 code review.
Problem
In
nightshift/cycle.pyline 464-468,_extract_shell_command()uses a regex that only matches the-lc 'body'or-lc "body"shell wrapper pattern:If an agent wraps commands differently (e.g.
bash -c "cmd",sh -c 'cmd', or no wrapper at all with just the raw command), this won't extract the inner command and the forbidden command check could miss violations.Suggested fix
Broaden the regex to also handle
bash -c,sh -c, and/bin/sh -cpatterns, or extract more generically. The current approach is a reasonable tradeoff (avoids false positives), but documenting the limitation with a comment would also be acceptable as a minimal fix.