- harness/es.py: append-only event store + проекции (образец — кооп-портал) - harness/levels.py: уровни 1с/1м/1ч/1д, контекст ∝ масштабу - harness/scheduler.py: уровневые потоки, идемпотентные тики, absorbed-стабы - harness/isolated_runner.py + _llm_worker.py: LLM-тик в сабпроцессе (глобальный asyncio-рантайм Strands не переживает 2+ create_harness) - cli.py: init/task/tasks/status/events + requeue (написан самим минутным агентом) - 9router: отдельный ключ sk-simbiot, модель auto (glm-5.3 первым)
25 lines
1.3 KiB
Python
25 lines
1.3 KiB
Python
r"""Validation patterns for sandbox inputs.
|
|
|
|
Mirrors ``strands-ts/src/sandbox/constants.ts``. These patterns reject inputs
|
|
that could break out of the intended shell context (path separators, spaces,
|
|
shell metacharacters), providing defense-in-depth for shell-based sandboxes.
|
|
|
|
Match these with :meth:`re.Pattern.fullmatch` (not :meth:`re.match`): Python's
|
|
``$`` also matches just before a trailing ``\n``, so ``re.match`` would accept
|
|
e.g. ``"python3\n"`` and let a newline-separated second statement slip through.
|
|
``fullmatch`` reproduces the JavaScript ``/^...$/.test()`` semantics of the
|
|
``strands-ts`` oracle, which anchors to the true end of the string.
|
|
"""
|
|
|
|
import re
|
|
|
|
#: Pattern for validating language/interpreter names.
|
|
#: Allows alphanumeric characters, dots, hyphens, and underscores. Rejects path
|
|
#: separators, spaces, and shell metacharacters to prevent injection.
|
|
LANGUAGE_PATTERN = re.compile(r"^[a-zA-Z0-9._-]+$")
|
|
|
|
#: Pattern for validating environment variable names: a leading letter or
|
|
#: underscore, followed by letters, digits, or underscores (valid POSIX names).
|
|
#: Names outside this set are rejected to prevent shell-syntax injection where a
|
|
#: key is interpolated into a command, and to fail with a clear error otherwise.
|
|
ENV_KEY_PATTERN = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_]*$")
|