leashd 2.3.0__tar.gz → 2.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {leashd-2.3.0 → leashd-2.4.0}/CHANGELOG.md +5 -0
- {leashd-2.3.0 → leashd-2.4.0}/PKG-INFO +1 -1
- {leashd-2.3.0 → leashd-2.4.0}/leashd/__init__.py +1 -1
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/engine.py +14 -5
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/safety/analyzer.py +187 -4
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/safety/gatekeeper.py +27 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/safety/policy.py +33 -3
- {leashd-2.3.0 → leashd-2.4.0}/leashd/policies/autonomous.yaml +2 -2
- {leashd-2.3.0 → leashd-2.4.0}/leashd/policies/default.yaml +2 -2
- {leashd-2.3.0 → leashd-2.4.0}/leashd/policies/permissive.yaml +1 -1
- {leashd-2.3.0 → leashd-2.4.0}/pyproject.toml +1 -1
- {leashd-2.3.0 → leashd-2.4.0}/.claude/settings.json +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/.gitignore +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/LICENSE +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/README.md +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/__main__.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/agents/base.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/agents/capabilities.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/agents/registry.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/agents/runtimes/_helpers.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/agents/runtimes/hook_relay.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/agents/runtimes/tmux.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/agents/runtimes/tmux_manifest.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/agents/runtimes/tmux_session.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/agents/types.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/app.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/browser_profile.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/cc_plugins.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/cli.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/cli_run.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/config_store.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/connectors/base.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/connectors/multi.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/connectors/telegram.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/connectors/telegram_approval.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/connectors/telegram_commands.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/connectors/telegram_markdown.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/connectors/telegram_sessions.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/connectors/web.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/chat_sessions.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/config.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/events.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/file_delivery.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/interactions.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/message_logger.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/plan_gate.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/queue.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/runtime_settings.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/safety/approval_card.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/safety/approvals.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/safety/audit.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/safety/sandbox.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/session.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/session_title.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/task.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/task_events.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/task_memory.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/task_profile.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/test_output.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/core/workspace.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/daemon.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/SKILL.md +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/authentication.md +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/commands.md +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/profiling.md +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/proxy-support.md +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/session-management.md +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/snapshot-refs.md +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/trust-boundaries.md +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/video-recording.md +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/webgpu.md +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/templates/authenticated-session.sh +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/templates/capture-workflow.sh +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/templates/form-automation.sh +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/search-batch.sh +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/webui/app.js +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/webui/icons/icon-192.png +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/webui/icons/icon-512.png +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/webui/index.html +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/webui/manifest.json +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/webui/service-worker.js +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/data/webui/style.css +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/exceptions.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/git/formatter.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/git/handler.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/git/models.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/git/service.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/main.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/middleware/auth.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/middleware/base.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/middleware/rate_limit.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/base.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/builtin/_task_prompts.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/builtin/audit_plugin.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/builtin/browser_tools.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/builtin/merge_resolver.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/builtin/playbooks/linkedin_comment.yaml +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/builtin/task_orchestrator.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/builtin/test_config_loader.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/builtin/web_agent.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/builtin/web_checkpoint.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/builtin/web_interaction_logger.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/builtin/workflow.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/plugins/registry.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/policies/.gitkeep +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/policies/dev-tools.yaml +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/policies/strict.yaml +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/setup.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/skills.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/storage/base.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/storage/memory.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/storage/sqlite.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/tunnel.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/web/app.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/web/auth.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/web/models.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/web/push.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/web/routes.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/web/tmux_hooks.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/web/tmux_jsonl.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/web/tmux_server.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/leashd/web/ws_handler.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/scripts/_harness/drive.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/scripts/_harness/multisession_suite.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/scripts/_harness/soak_model.py +0 -0
- {leashd-2.3.0 → leashd-2.4.0}/scripts/_harness/tmux_harness.py +0 -0
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.4.0] - 2026-10-17
|
|
4
|
+
- **changed**: "Approve all" now survives `/clear` and `/stop`; a directory or mode change still drops it.
|
|
5
|
+
- **changed**: fewer prompts for reads that already ran unasked in another spelling: SQL fed to `psql` by heredoc on a trusted SSH host, `begin read only; … commit` transactions, and `grep -c` counts of a `.env` variable prefix.
|
|
6
|
+
- **fixed**: approval prompts name the gated command instead of a `$(…)` inside it or a `case` pattern (`Bash::*queued*`), sourcing a file names the file, and `/usr/bin/grep` is treated as `grep`.
|
|
7
|
+
|
|
3
8
|
## [2.3.0] - 2026-10-10
|
|
4
9
|
- **added**: while background subagents are still working after Claude's turn has ended, the chat shows a line under the last reply naming them, until they report back.
|
|
5
10
|
- **added**: a `tool_ran_ungated` audit entry and `tmux_tool_ran_ungated` log line for any tool call that finishes without having gone through the gate.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: leashd
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Run Claude Code as a governed daemon: a real claude TUI in tmux behind a sandbox, YAML policies and human-in-the-loop approval
|
|
5
5
|
Project-URL: Homepage, https://github.com/vmehera123/leashd
|
|
6
6
|
Project-URL: Repository, https://github.com/vmehera123/leashd
|
|
@@ -975,8 +975,14 @@ class Engine:
|
|
|
975
975
|
if self.interaction_coordinator:
|
|
976
976
|
self.interaction_coordinator.cancel_pending(chat_id)
|
|
977
977
|
|
|
978
|
-
async def _cleanup_session(
|
|
979
|
-
|
|
978
|
+
async def _cleanup_session(
|
|
979
|
+
self, session: Session, chat_id: str, *, same_directory: bool = False
|
|
980
|
+
) -> None:
|
|
981
|
+
"""Cancel active work, shut down browser, and clean up state for a chat.
|
|
982
|
+
|
|
983
|
+
*same_directory* is for ``/clear`` and ``/stop``, which restart the
|
|
984
|
+
agent where it stands: the human's "Approve all" taps stay.
|
|
985
|
+
"""
|
|
980
986
|
if self.approval_coordinator:
|
|
981
987
|
await self.approval_coordinator.cancel_pending(chat_id)
|
|
982
988
|
if self.interaction_coordinator:
|
|
@@ -995,7 +1001,10 @@ class Engine:
|
|
|
995
1001
|
if mid and self.connector:
|
|
996
1002
|
await self.connector.delete_message(chat_id, mid)
|
|
997
1003
|
await self._end_web_session(session)
|
|
998
|
-
|
|
1004
|
+
if same_directory:
|
|
1005
|
+
self._gatekeeper.end_conversation(chat_id)
|
|
1006
|
+
else:
|
|
1007
|
+
self._gatekeeper.disable_auto_approve(chat_id)
|
|
999
1008
|
self._pending_messages.pop(chat_id, None)
|
|
1000
1009
|
|
|
1001
1010
|
async def _end_web_session(self, session: Session) -> None:
|
|
@@ -2290,7 +2299,7 @@ class Engine:
|
|
|
2290
2299
|
},
|
|
2291
2300
|
)
|
|
2292
2301
|
)
|
|
2293
|
-
await self._cleanup_session(session, chat_id)
|
|
2302
|
+
await self._cleanup_session(session, chat_id, same_directory=True)
|
|
2294
2303
|
self.session_manager.stash_resume_token(session)
|
|
2295
2304
|
session.agent_resume_token = None
|
|
2296
2305
|
self.session_manager.reset_mode(session)
|
|
@@ -2390,7 +2399,7 @@ class Engine:
|
|
|
2390
2399
|
},
|
|
2391
2400
|
)
|
|
2392
2401
|
)
|
|
2393
|
-
await self._cleanup_session(session, chat_id)
|
|
2402
|
+
await self._cleanup_session(session, chat_id, same_directory=True)
|
|
2394
2403
|
await self.session_manager.reset(user_id, chat_id)
|
|
2395
2404
|
logger.info("session_cleared", user_id=user_id, chat_id=chat_id)
|
|
2396
2405
|
return "Session cleared. Next message starts a fresh conversation."
|
|
@@ -104,6 +104,10 @@ _EXECUTOR_COMMANDS = frozenset(
|
|
|
104
104
|
{"sqlite3", "sqlite", "duckdb", "sed", "awk", "gawk", "mawk"}
|
|
105
105
|
)
|
|
106
106
|
|
|
107
|
+
_FLAGS_ARE_NOT_CODE = frozenset(
|
|
108
|
+
{"jq", "grep", "egrep", "fgrep", "rg", "wc", "head", "tail", "cut", "uniq"}
|
|
109
|
+
)
|
|
110
|
+
|
|
107
111
|
_COMMAND_POSITION_RE = re.compile(r"\|\||&&|[|;&(]")
|
|
108
112
|
|
|
109
113
|
|
|
@@ -121,6 +125,11 @@ def shell_match_texts(command: str) -> list[str]:
|
|
|
121
125
|
that executes it (``bash -c``, ``eval``, ``psql -c``), which is real
|
|
122
126
|
executable text wearing quotes.
|
|
123
127
|
|
|
128
|
+
``-c`` and ``-e`` hand over a program only to something that runs one.
|
|
129
|
+
For ``jq -c`` (compact output), ``grep -c`` (count) and ``grep -e`` (a
|
|
130
|
+
pattern) the quoted run after the flag is data, and reading it as code
|
|
131
|
+
took ``jq -c 'select(.key|test("x"))'`` for a read of a ``.key`` file.
|
|
132
|
+
|
|
124
133
|
A flag is not the only way to hand over a program. ``sqlite3 db "DROP
|
|
125
134
|
TABLE users"`` passes its statement positionally, so the deny floor read
|
|
126
135
|
it as an inert string while the identical ``psql -c`` form was denied;
|
|
@@ -179,9 +188,10 @@ def _split_quoting(command: str) -> tuple[str, list[str], list[str]]:
|
|
|
179
188
|
def _preceded_by_executor(skeleton_so_far: str) -> bool:
|
|
180
189
|
unquoted = skeleton_so_far.replace("'", " ").replace('"', " ")
|
|
181
190
|
tokens = unquoted.split()
|
|
182
|
-
if tokens and tokens[-1] in _EXECUTOR_FLAGS:
|
|
183
|
-
return True
|
|
184
191
|
running_text = _COMMAND_POSITION_RE.split(unquoted)[-1].strip()
|
|
192
|
+
if tokens and tokens[-1] in _EXECUTOR_FLAGS:
|
|
193
|
+
head = strip_command_wrappers(running_text).split(maxsplit=1)
|
|
194
|
+
return not head or head[0] not in _FLAGS_ARE_NOT_CODE
|
|
185
195
|
if (
|
|
186
196
|
tokens
|
|
187
197
|
and _SQL_STATEMENT_FLAG_RE.fullmatch(tokens[-1])
|
|
@@ -257,6 +267,13 @@ def split_chain_segments(command: str) -> list[str]:
|
|
|
257
267
|
one. The substitution's own commands are classified by
|
|
258
268
|
:func:`command_units`.
|
|
259
269
|
|
|
270
|
+
A ``case`` statement splits into its header and the commands of its arms.
|
|
271
|
+
The patterns are dropped: ``a|b) sleep 20;; *) break`` used to split at
|
|
272
|
+
``;`` into ``a|b) sleep 20`` and ``*) break``, then at the pattern's ``|``
|
|
273
|
+
as if it were a pipe, so the human was asked to approve ``Bash::*queued*``.
|
|
274
|
+
A pattern the shell would expand (``$``, a backtick) is left in place and
|
|
275
|
+
classified as the text it is.
|
|
276
|
+
|
|
260
277
|
Inspired by openclaw ``splitCommandChainWithOperators()`` which uses a
|
|
261
278
|
character-by-char scanner that tracks quote state before splitting.
|
|
262
279
|
"""
|
|
@@ -267,6 +284,8 @@ def split_chain_segments(command: str) -> list[str]:
|
|
|
267
284
|
in_double_quote = False
|
|
268
285
|
substitutions_close = True
|
|
269
286
|
escaped = False
|
|
287
|
+
case_depth = 0
|
|
288
|
+
expect_pattern = False
|
|
270
289
|
i = 0
|
|
271
290
|
length = len(command)
|
|
272
291
|
|
|
@@ -281,17 +300,18 @@ def split_chain_segments(command: str) -> list[str]:
|
|
|
281
300
|
|
|
282
301
|
if ch == "\\":
|
|
283
302
|
escaped = True
|
|
303
|
+
expect_pattern = False
|
|
284
304
|
current.append(ch)
|
|
285
305
|
i += 1
|
|
286
306
|
continue
|
|
287
307
|
|
|
288
|
-
if ch == "'" and not in_double_quote:
|
|
308
|
+
if ch == "'" and not in_double_quote and not expect_pattern:
|
|
289
309
|
in_single_quote = not in_single_quote
|
|
290
310
|
current.append(ch)
|
|
291
311
|
i += 1
|
|
292
312
|
continue
|
|
293
313
|
|
|
294
|
-
if ch == '"' and not in_single_quote:
|
|
314
|
+
if ch == '"' and not in_single_quote and not expect_pattern:
|
|
295
315
|
in_double_quote = not in_double_quote
|
|
296
316
|
current.append(ch)
|
|
297
317
|
i += 1
|
|
@@ -307,6 +327,39 @@ def split_chain_segments(command: str) -> list[str]:
|
|
|
307
327
|
continue
|
|
308
328
|
|
|
309
329
|
if not in_single_quote and not in_double_quote:
|
|
330
|
+
if expect_pattern:
|
|
331
|
+
if ch.isspace():
|
|
332
|
+
i += 1
|
|
333
|
+
continue
|
|
334
|
+
expect_pattern = False
|
|
335
|
+
pattern = _CASE_PATTERN_RE.match(command, i)
|
|
336
|
+
if pattern and not _CASE_END_RE.match(command, i):
|
|
337
|
+
i = pattern.end()
|
|
338
|
+
continue
|
|
339
|
+
|
|
340
|
+
if ch in "ce" and _CASE_COMMAND_START_RE.fullmatch("".join(current)):
|
|
341
|
+
header = _CASE_HEADER_RE.match(command, i)
|
|
342
|
+
if header:
|
|
343
|
+
segments.append(header.group(0).strip())
|
|
344
|
+
current = []
|
|
345
|
+
case_depth += 1
|
|
346
|
+
expect_pattern = True
|
|
347
|
+
i = header.end()
|
|
348
|
+
continue
|
|
349
|
+
if case_depth and _CASE_END_RE.match(command, i):
|
|
350
|
+
case_depth -= 1
|
|
351
|
+
|
|
352
|
+
if case_depth:
|
|
353
|
+
arm_end = _CASE_ARM_END_RE.match(command, i)
|
|
354
|
+
if arm_end:
|
|
355
|
+
seg = "".join(current).strip()
|
|
356
|
+
if seg:
|
|
357
|
+
segments.append(seg)
|
|
358
|
+
current = []
|
|
359
|
+
expect_pattern = True
|
|
360
|
+
i = arm_end.end()
|
|
361
|
+
continue
|
|
362
|
+
|
|
310
363
|
if ch == "<":
|
|
311
364
|
heredoc = _HEREDOC_START_RE.match(command, i)
|
|
312
365
|
if heredoc:
|
|
@@ -353,6 +406,15 @@ def split_chain_segments(command: str) -> list[str]:
|
|
|
353
406
|
|
|
354
407
|
_LEADING_CONTINUATION_RE = re.compile(r"^(?:\\\n\s*)+")
|
|
355
408
|
|
|
409
|
+
_CASE_COMMAND_START_RE = re.compile(r"\s*(?:(?:do|then|else|\{)\s+)*")
|
|
410
|
+
_CASE_HEADER_RE = re.compile(r"case\s+(?:\"[^\"`]*\"|[^\s`;|&<>()'\"]+)\s+in(?=\s)")
|
|
411
|
+
_CASE_END_RE = re.compile(r"esac(?![\w-])")
|
|
412
|
+
_CASE_ARM_END_RE = re.compile(r";;&|;;|;&")
|
|
413
|
+
_CASE_PATTERN_ITEM = r"(?:'[^']*'|\"[^\"$`\\]*\"|[^\s()`$;&<>'\"|\\])+"
|
|
414
|
+
_CASE_PATTERN_RE = re.compile(
|
|
415
|
+
r"\(?\s*" + _CASE_PATTERN_ITEM + r"(?:\s*\|\s*" + _CASE_PATTERN_ITEM + r")*\s*\)"
|
|
416
|
+
)
|
|
417
|
+
|
|
356
418
|
|
|
357
419
|
def split_pipeline_stages(segment: str) -> list[str]:
|
|
358
420
|
stages: list[str] = []
|
|
@@ -504,6 +566,9 @@ _RUNNER_PREFIX_RE = re.compile(
|
|
|
504
566
|
)
|
|
505
567
|
_TIMEOUT_PREFIX_RE = re.compile(r"^timeout\s+(?:-\S+\s+)*[\d.]+[smhd]?\s+(?=\S)")
|
|
506
568
|
_GROUP_OPEN_RE = re.compile(r"^[({]\s*(?=\S)")
|
|
569
|
+
_SYSTEM_BIN_PREFIX_RE = re.compile(
|
|
570
|
+
r"^(?:/usr/local/bin|/opt/homebrew/bin|/usr/s?bin|/s?bin)/(?=[A-Za-z0-9_.+-]+(?:\s|$))"
|
|
571
|
+
)
|
|
507
572
|
_FUNCTION_HEADER_RE = re.compile(
|
|
508
573
|
r"^(?:function\s+)?[A-Za-z_][\w-]*\s*\(\)\s*\{\s*(?=\S)"
|
|
509
574
|
r"|^function\s+[A-Za-z_][\w-]*\s*\{\s*(?=\S)"
|
|
@@ -523,6 +588,11 @@ def strip_command_wrappers(command: str) -> str:
|
|
|
523
588
|
``for`` is deliberately not peeled: its header is a word list, not a
|
|
524
589
|
command. Assignment values containing ``$``/backtick/operators are left
|
|
525
590
|
alone so ``FOO=$(rm -rf /) ls`` still reaches the deny rules intact.
|
|
591
|
+
|
|
592
|
+
A binary named by its path in a system directory is the binary:
|
|
593
|
+
``/usr/bin/grep`` matched no rule at all, neither the read-only allow nor
|
|
594
|
+
any gate ``grep`` has. Only the directories ``PATH`` already resolves a
|
|
595
|
+
bare name from are peeled, so ``/tmp/x/grep`` stays what it is.
|
|
526
596
|
"""
|
|
527
597
|
prev = None
|
|
528
598
|
while command != prev:
|
|
@@ -534,6 +604,7 @@ def strip_command_wrappers(command: str) -> str:
|
|
|
534
604
|
_RUNNER_PREFIX_RE,
|
|
535
605
|
_GROUP_OPEN_RE,
|
|
536
606
|
_FUNCTION_HEADER_RE,
|
|
607
|
+
_SYSTEM_BIN_PREFIX_RE,
|
|
537
608
|
):
|
|
538
609
|
command = pattern.sub("", command, count=1)
|
|
539
610
|
return command
|
|
@@ -1411,6 +1482,27 @@ def mentions_credential_path(command: str) -> bool:
|
|
|
1411
1482
|
return bool(_SHELL_CREDENTIAL_RE.search(shell_match_texts(command)[0]))
|
|
1412
1483
|
|
|
1413
1484
|
|
|
1485
|
+
_NAME_COUNT_RE = re.compile(
|
|
1486
|
+
r"(?P<head>grep(?:\s+-[Hhs]+)*\s+-[Hhs]*c[cHhs]*(?:\s+-[cHhs]+)*\s+)"
|
|
1487
|
+
r"(?P<q>['\"])(?P<pattern>\^[A-Z][A-Z0-9_]*[_=])(?P=q)"
|
|
1488
|
+
r"(?P<paths>(?:\s+(?!-)[A-Za-z0-9_./~-]+)+)"
|
|
1489
|
+
)
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
def counted_variable_names(command: str) -> str | None:
|
|
1493
|
+
"""``grep -c "^NAME=" file`` with the quotes taken off its pattern.
|
|
1494
|
+
|
|
1495
|
+
A rule sees a quoted run blanked out, so the count of a variable's lines
|
|
1496
|
+
was allowed bare and asked about quoted. Only a name is unquoted: the
|
|
1497
|
+
pattern has to end at ``=`` or ``_``, because a count that could test the
|
|
1498
|
+
value (``^TOKEN=a``) answers what the secret starts with.
|
|
1499
|
+
"""
|
|
1500
|
+
match = _NAME_COUNT_RE.fullmatch(command.strip())
|
|
1501
|
+
if match is None:
|
|
1502
|
+
return None
|
|
1503
|
+
return match.group("head") + match.group("pattern") + match.group("paths")
|
|
1504
|
+
|
|
1505
|
+
|
|
1414
1506
|
def quotes_credential_path(command: str) -> bool:
|
|
1415
1507
|
"""Whether a quoted argument names a credential path.
|
|
1416
1508
|
|
|
@@ -1719,6 +1811,10 @@ def remote_shell_command(command: str) -> tuple[str, str] | None:
|
|
|
1719
1811
|
for redirection in redirections
|
|
1720
1812
|
):
|
|
1721
1813
|
return None
|
|
1814
|
+
return _fixed_remote_command(text)
|
|
1815
|
+
|
|
1816
|
+
|
|
1817
|
+
def _fixed_remote_command(text: str) -> tuple[str, str] | None:
|
|
1722
1818
|
words = _literal_shell_words(text)
|
|
1723
1819
|
if not words or words[0] != "ssh":
|
|
1724
1820
|
return None
|
|
@@ -1732,6 +1828,93 @@ def remote_shell_command(command: str) -> tuple[str, str] | None:
|
|
|
1732
1828
|
return scope.removeprefix("ssh "), " ".join(remote)
|
|
1733
1829
|
|
|
1734
1830
|
|
|
1831
|
+
_QUOTED_HEREDOC_RE = re.compile(
|
|
1832
|
+
r"\s*<<-?\s*(?P<q>['\"])(?P<delim>[A-Za-z_][A-Za-z0-9_]*)(?P=q)"
|
|
1833
|
+
)
|
|
1834
|
+
|
|
1835
|
+
|
|
1836
|
+
def remote_stdin_script(command: str) -> tuple[str, str, str] | None:
|
|
1837
|
+
"""The destination, remote command and script of ``ssh host '<cmd>' <<'EOF'``.
|
|
1838
|
+
|
|
1839
|
+
The same statement reaches ``psql`` as ``-c "select …"`` or on its stdin,
|
|
1840
|
+
and only the first spelling could be read. The delimiter must be quoted,
|
|
1841
|
+
so the local shell passes the body through untouched, and the heredoc must
|
|
1842
|
+
be the whole of what follows the command line: text after the terminator
|
|
1843
|
+
is another command. Every other redirection still has to discard.
|
|
1844
|
+
"""
|
|
1845
|
+
head, newline, rest = command.strip().partition("\n")
|
|
1846
|
+
if not newline:
|
|
1847
|
+
return None
|
|
1848
|
+
text, redirections = _split_redirections(strip_command_wrappers(head.strip()))
|
|
1849
|
+
heredocs = [
|
|
1850
|
+
match
|
|
1851
|
+
for match in map(_QUOTED_HEREDOC_RE.fullmatch, redirections)
|
|
1852
|
+
if match is not None
|
|
1853
|
+
]
|
|
1854
|
+
if len(heredocs) != 1 or not all(
|
|
1855
|
+
_QUOTED_HEREDOC_RE.fullmatch(redirection)
|
|
1856
|
+
or _DISCARDING_REDIRECT_RE.fullmatch(redirection.strip())
|
|
1857
|
+
for redirection in redirections
|
|
1858
|
+
):
|
|
1859
|
+
return None
|
|
1860
|
+
lines = rest.rstrip().split("\n")
|
|
1861
|
+
delimiter = heredocs[0].group("delim")
|
|
1862
|
+
if lines[-1].strip() != delimiter or delimiter in map(str.strip, lines[:-1]):
|
|
1863
|
+
return None
|
|
1864
|
+
session = _fixed_remote_command(text)
|
|
1865
|
+
if session is None:
|
|
1866
|
+
return None
|
|
1867
|
+
return session[0], session[1], "\n".join(lines[:-1])
|
|
1868
|
+
|
|
1869
|
+
|
|
1870
|
+
_PSQL_SWITCHES = frozenset("AtqXx1")
|
|
1871
|
+
_PSQL_VALUE_FLAGS = frozenset("UdhpFRP")
|
|
1872
|
+
_PSQL_LONG_SWITCHES = frozenset(
|
|
1873
|
+
{"--no-psqlrc", "--tuples-only", "--no-align", "--quiet", "--single-transaction"}
|
|
1874
|
+
)
|
|
1875
|
+
_PSQL_SAFE_VARIABLE_RE = re.compile(r"ON_ERROR_STOP=(?:[01]|on|off)")
|
|
1876
|
+
_PLAIN_CD_RE = re.compile(r"cd\s+[A-Za-z0-9_./~-]+")
|
|
1877
|
+
|
|
1878
|
+
|
|
1879
|
+
def psql_reads_stdin(command: str) -> bool:
|
|
1880
|
+
"""Whether *command* is a ``psql`` that runs only what its stdin carries.
|
|
1881
|
+
|
|
1882
|
+
``-c`` and ``-f`` name other statements, ``-o`` and ``-L`` write files,
|
|
1883
|
+
and ``-v name=value`` splices text into the script after it was read, so
|
|
1884
|
+
each declines. So does anything in front of the ``psql`` but a ``cd``:
|
|
1885
|
+
``xargs cat`` would take the script's lines as the files to print.
|
|
1886
|
+
"""
|
|
1887
|
+
units = command_units(command)
|
|
1888
|
+
if not units or any(kind != "command" for _, kind in units):
|
|
1889
|
+
return False
|
|
1890
|
+
*before, (last, _) = units
|
|
1891
|
+
if not all(_PLAIN_CD_RE.fullmatch(text.strip()) for text, _ in before):
|
|
1892
|
+
return False
|
|
1893
|
+
if not keeps_to_its_streams(last) or _split_redirections(last)[1]:
|
|
1894
|
+
return False
|
|
1895
|
+
client = docker_exec_command(last.strip()) or last.strip()
|
|
1896
|
+
words = _literal_shell_words(client)
|
|
1897
|
+
if not words or words[0] != "psql":
|
|
1898
|
+
return False
|
|
1899
|
+
remaining = iter(words[1:])
|
|
1900
|
+
for word in remaining:
|
|
1901
|
+
if word in _PSQL_LONG_SWITCHES:
|
|
1902
|
+
continue
|
|
1903
|
+
if not re.fullmatch(r"-[A-Za-z0-9]+", word):
|
|
1904
|
+
return False
|
|
1905
|
+
flags = word[1:]
|
|
1906
|
+
if set(flags) <= _PSQL_SWITCHES:
|
|
1907
|
+
continue
|
|
1908
|
+
if set(flags[:-1]) <= _PSQL_SWITCHES and flags[-1] in _PSQL_VALUE_FLAGS:
|
|
1909
|
+
if next(remaining, None) is None:
|
|
1910
|
+
return False
|
|
1911
|
+
continue
|
|
1912
|
+
if flags == "v" and _PSQL_SAFE_VARIABLE_RE.fullmatch(next(remaining, "")):
|
|
1913
|
+
continue
|
|
1914
|
+
return False
|
|
1915
|
+
return True
|
|
1916
|
+
|
|
1917
|
+
|
|
1735
1918
|
_SED_ADDRESS = r"(?:\d+|\$|/(?:[^/\\\n]|\\.)*/)"
|
|
1736
1919
|
_SED_PRINT_PROGRAM_RE = re.compile(
|
|
1737
1920
|
r"(?:\s*(?:" + _SED_ADDRESS + r"(?:\s*,\s*" + _SED_ADDRESS + r")?)?\s*!?\s*"
|
|
@@ -67,6 +67,8 @@ _TARGET_BEARING_COMMANDS = frozenset(
|
|
|
67
67
|
"ssh",
|
|
68
68
|
"scp",
|
|
69
69
|
"rsync",
|
|
70
|
+
".",
|
|
71
|
+
"source",
|
|
70
72
|
}
|
|
71
73
|
)
|
|
72
74
|
|
|
@@ -244,6 +246,7 @@ class ToolGatekeeper:
|
|
|
244
246
|
self._path_tools = path_tools or DEFAULT_PATH_TOOLS
|
|
245
247
|
self._auto_approved_chats: set[str] = set()
|
|
246
248
|
self._auto_approved_tools: dict[str, set[str]] = {}
|
|
249
|
+
self._human_grants: dict[str, set[str]] = {}
|
|
247
250
|
self._browsing_grants: frozenset[str] = (
|
|
248
251
|
_agent_browser_browsing_keys() if browser_auto_approve else frozenset()
|
|
249
252
|
)
|
|
@@ -293,6 +296,7 @@ class ToolGatekeeper:
|
|
|
293
296
|
def grant_approve_all(self, chat_id: str, approval_key: str) -> None:
|
|
294
297
|
granted = approve_all_grant(approval_key)
|
|
295
298
|
self._auto_approved_tools.setdefault(chat_id, set()).update(granted)
|
|
299
|
+
self._human_grants.setdefault(chat_id, set()).update(granted)
|
|
296
300
|
logger.info(
|
|
297
301
|
"auto_approve_enabled",
|
|
298
302
|
chat_id=chat_id,
|
|
@@ -317,8 +321,28 @@ class ToolGatekeeper:
|
|
|
317
321
|
def disable_auto_approve(self, chat_id: str) -> None:
|
|
318
322
|
self._auto_approved_chats.discard(chat_id)
|
|
319
323
|
self._auto_approved_tools.pop(chat_id, None)
|
|
324
|
+
self._human_grants.pop(chat_id, None)
|
|
320
325
|
logger.info("auto_approve_disabled", chat_id=chat_id)
|
|
321
326
|
|
|
327
|
+
def end_conversation(self, chat_id: str) -> None:
|
|
328
|
+
"""Drop what a mode or plugin granted, keep the human's "Approve all" taps.
|
|
329
|
+
|
|
330
|
+
``/clear`` and ``/stop`` start the agent over in the same chat and the
|
|
331
|
+
same directory, and the human who tapped "Approve all" on ``git push
|
|
332
|
+
origin`` there was asked again after each one. The blanket grant and
|
|
333
|
+
the per-tool grants a mode seeded go, because the reset also returns
|
|
334
|
+
the chat to its default mode. A directory or mode change still calls
|
|
335
|
+
:meth:`disable_auto_approve`: the same key names a different target
|
|
336
|
+
there.
|
|
337
|
+
"""
|
|
338
|
+
kept = set(self._human_grants.get(chat_id, ()))
|
|
339
|
+
self._auto_approved_chats.discard(chat_id)
|
|
340
|
+
if kept:
|
|
341
|
+
self._auto_approved_tools[chat_id] = kept
|
|
342
|
+
else:
|
|
343
|
+
self._auto_approved_tools.pop(chat_id, None)
|
|
344
|
+
logger.info("auto_approve_disabled", chat_id=chat_id, kept=len(kept))
|
|
345
|
+
|
|
322
346
|
async def check(
|
|
323
347
|
self,
|
|
324
348
|
tool_name: str,
|
|
@@ -641,6 +665,9 @@ class ToolGatekeeper:
|
|
|
641
665
|
key = _approval_key("Bash", {"command": text})
|
|
642
666
|
if key not in keys:
|
|
643
667
|
keys.append(key)
|
|
668
|
+
if whole in keys:
|
|
669
|
+
keys.remove(whole)
|
|
670
|
+
keys.insert(0, whole)
|
|
644
671
|
return keys or [whole]
|
|
645
672
|
|
|
646
673
|
async def _handle_approval(
|
|
@@ -14,6 +14,7 @@ from leashd.core.safety.analyzer import (
|
|
|
14
14
|
SQL_CLIENT_RE,
|
|
15
15
|
RiskLevel,
|
|
16
16
|
command_units,
|
|
17
|
+
counted_variable_names,
|
|
17
18
|
docker_exec_command,
|
|
18
19
|
expand_literal_variables,
|
|
19
20
|
inline_shell_script,
|
|
@@ -22,10 +23,12 @@ from leashd.core.safety.analyzer import (
|
|
|
22
23
|
mentions_credential_path,
|
|
23
24
|
names_what_it_reads,
|
|
24
25
|
network_read_scope,
|
|
26
|
+
psql_reads_stdin,
|
|
25
27
|
public_read_scope,
|
|
26
28
|
quotes_credential_path,
|
|
27
29
|
reads_without_writing,
|
|
28
30
|
remote_shell_command,
|
|
31
|
+
remote_stdin_script,
|
|
29
32
|
shell_match_texts,
|
|
30
33
|
split_chain_segments,
|
|
31
34
|
strip_benign_prefixes,
|
|
@@ -228,16 +231,27 @@ class PolicyEngine:
|
|
|
228
231
|
):
|
|
229
232
|
return None
|
|
230
233
|
command = str(tool_input.get("command", ""))
|
|
234
|
+
script: str | None = None
|
|
231
235
|
session = remote_shell_command(command)
|
|
232
236
|
if session is None:
|
|
233
|
-
|
|
237
|
+
fed = remote_stdin_script(command)
|
|
238
|
+
if fed is None:
|
|
239
|
+
return None
|
|
240
|
+
session, script = fed[:2], fed[2]
|
|
234
241
|
destination, remote = session
|
|
235
242
|
if destination not in self._trusted_ssh_hosts:
|
|
236
243
|
return None
|
|
237
244
|
login = self._classify_by_rules("Bash", {"command": f"ssh {destination}"})
|
|
238
|
-
if login.matched_rule is not rule
|
|
245
|
+
if login.matched_rule is not rule:
|
|
246
|
+
return None
|
|
247
|
+
if mentions_credential_path(command.partition("\n")[0]):
|
|
248
|
+
return None
|
|
249
|
+
if quotes_credential_path(remote):
|
|
239
250
|
return None
|
|
240
|
-
if
|
|
251
|
+
if script is None:
|
|
252
|
+
if not self._reads_only(remote):
|
|
253
|
+
return None
|
|
254
|
+
elif not psql_reads_stdin(remote) or not self._sql_reads_only(script):
|
|
241
255
|
return None
|
|
242
256
|
return Classification(
|
|
243
257
|
category=_TRUSTED_SSH_READ_RULE.name,
|
|
@@ -248,6 +262,20 @@ class PolicyEngine:
|
|
|
248
262
|
matched_rule=_TRUSTED_SSH_READ_RULE,
|
|
249
263
|
)
|
|
250
264
|
|
|
265
|
+
def _sql_reads_only(self, script: str) -> bool:
|
|
266
|
+
"""Whether a script fed to ``psql`` is one the rules allow as ``-c``.
|
|
267
|
+
|
|
268
|
+
The script is matched as the statement it is, in rule order, so a
|
|
269
|
+
deny, a credential path or a writing statement decides before the
|
|
270
|
+
read rule can.
|
|
271
|
+
"""
|
|
272
|
+
texts = [script.strip()]
|
|
273
|
+
command_texts = (texts, texts, texts)
|
|
274
|
+
for rule in self.rules:
|
|
275
|
+
if self._rule_matches(rule, {"Bash"}, "Bash", {}, command_texts):
|
|
276
|
+
return rule.action == PolicyDecision.ALLOW and rule.name == "sql-read"
|
|
277
|
+
return False
|
|
278
|
+
|
|
251
279
|
def _reads_only(self, command: str) -> bool:
|
|
252
280
|
"""Whether every command in *command* is a read, however it is spelled.
|
|
253
281
|
|
|
@@ -370,6 +398,8 @@ class PolicyEngine:
|
|
|
370
398
|
public: str | None = None
|
|
371
399
|
if inner is not None:
|
|
372
400
|
allow_texts = self._bash_match_texts(inner)[0]
|
|
401
|
+
elif (counted := counted_variable_names(normalized)) is not None:
|
|
402
|
+
allow_texts = [counted]
|
|
373
403
|
elif payloads and SQL_CLIENT_RE.match(skeleton):
|
|
374
404
|
allow_texts = payloads
|
|
375
405
|
elif _AWK_RE.match(skeleton) and any(
|
|
@@ -104,7 +104,7 @@ rules:
|
|
|
104
104
|
command_patterns:
|
|
105
105
|
- "^(ls|stat|file|test|\\[\\[?)(\\s|$)(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))"
|
|
106
106
|
- "^git\\s+(-C\\s+\\S+\\s+)?(status|check-ignore|ls-files)\\b(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))"
|
|
107
|
-
- "^grep(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))(?:\\s+-[Hhs]+)*\\s+-[Hhs]*c[cHhs]*(?:\\s+-[cHhs]+)*\\s+\\^[A-Z][A-Z0-9_]
|
|
107
|
+
- "^grep(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))(?:\\s+-[Hhs]+)*\\s+-[Hhs]*c[cHhs]*(?:\\s+-[cHhs]+)*\\s+\\^[A-Z][A-Z0-9_]*[_=](?:\\s+(?!-)[A-Za-z0-9_./~-]+)+$"
|
|
108
108
|
action: allow
|
|
109
109
|
description: "Metadata of a credential path (listing, existence, ignore status, a match count) without reading it"
|
|
110
110
|
|
|
@@ -247,7 +247,7 @@ rules:
|
|
|
247
247
|
command_patterns:
|
|
248
248
|
# A backslash starts a psql meta-command (`\!`, `\copy`, `\o file`), so
|
|
249
249
|
# the only one a statement may carry is the `\n` of an `E'\n'` string.
|
|
250
|
-
- "(?is)^(?!.*(\\b(INSERT|UPDATE|DELETE|MERGE|COPY|CREATE|DROP|ALTER|TRUNCATE|ATTACH|DETACH|VACUUM|REINDEX|GRANT|REVOKE)\\b|\\bREPLACE\\s+INTO\\b|\\bPRAGMA\\s+\\w+\\s*=))\\s*(SELECT|WITH|EXPLAIN|PRAGMA|\\.tables|\\.schema|\\.databases|\\.dbinfo|\\.indexes)\\b([^;\\\\]|\\\\n)*(;\\s*((SELECT|WITH|EXPLAIN|PRAGMA|\\.tables|\\.schema|\\.databases|\\.dbinfo|\\.indexes)\\b([^;\\\\]|\\\\n)*)?)*$"
|
|
250
|
+
- "(?is)^(?!.*(\\b(INSERT|UPDATE|DELETE|MERGE|COPY|CREATE|DROP|ALTER|TRUNCATE|ATTACH|DETACH|VACUUM|REINDEX|GRANT|REVOKE)\\b|\\bREPLACE\\s+INTO\\b|\\b(COMMIT|ROLLBACK)\\s+PREPARED\\b|\\bPRAGMA\\s+\\w+\\s*=))\\s*(SELECT|WITH|EXPLAIN|PRAGMA|BEGIN|START\\s+TRANSACTION|COMMIT|ROLLBACK|END|\\.tables|\\.schema|\\.databases|\\.dbinfo|\\.indexes)\\b([^;\\\\]|\\\\n)*(;\\s*((SELECT|WITH|EXPLAIN|PRAGMA|BEGIN|START\\s+TRANSACTION|COMMIT|ROLLBACK|END|\\.tables|\\.schema|\\.databases|\\.dbinfo|\\.indexes)\\b([^;\\\\]|\\\\n)*)?)*$"
|
|
251
251
|
# psql's describe commands: `\d portals`, `\dt+`, `\l`.
|
|
252
252
|
- "^\\\\(d[a-zA-Z]*\\+?|l\\+?|conninfo)(\\s+[\\w.*]+)?\\s*$"
|
|
253
253
|
action: allow
|
|
@@ -69,7 +69,7 @@ rules:
|
|
|
69
69
|
command_patterns:
|
|
70
70
|
- "^(ls|stat|file|test|\\[\\[?)(\\s|$)(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))"
|
|
71
71
|
- "^git\\s+(-C\\s+\\S+\\s+)?(status|check-ignore|ls-files)\\b(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))"
|
|
72
|
-
- "^grep(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))(?:\\s+-[Hhs]+)*\\s+-[Hhs]*c[cHhs]*(?:\\s+-[cHhs]+)*\\s+\\^[A-Z][A-Z0-9_]
|
|
72
|
+
- "^grep(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))(?:\\s+-[Hhs]+)*\\s+-[Hhs]*c[cHhs]*(?:\\s+-[cHhs]+)*\\s+\\^[A-Z][A-Z0-9_]*[_=](?:\\s+(?!-)[A-Za-z0-9_./~-]+)+$"
|
|
73
73
|
action: allow
|
|
74
74
|
description: "Metadata of a credential path (listing, existence, ignore status, a match count) without reading it"
|
|
75
75
|
|
|
@@ -214,7 +214,7 @@ rules:
|
|
|
214
214
|
command_patterns:
|
|
215
215
|
# A backslash starts a psql meta-command (`\!`, `\copy`, `\o file`), so
|
|
216
216
|
# the only one a statement may carry is the `\n` of an `E'\n'` string.
|
|
217
|
-
- "(?is)^(?!.*(\\b(INSERT|UPDATE|DELETE|MERGE|COPY|CREATE|DROP|ALTER|TRUNCATE|ATTACH|DETACH|VACUUM|REINDEX|GRANT|REVOKE)\\b|\\bREPLACE\\s+INTO\\b|\\bPRAGMA\\s+\\w+\\s*=))\\s*(SELECT|WITH|EXPLAIN|PRAGMA|\\.tables|\\.schema|\\.databases|\\.dbinfo|\\.indexes)\\b([^;\\\\]|\\\\n)*(;\\s*((SELECT|WITH|EXPLAIN|PRAGMA|\\.tables|\\.schema|\\.databases|\\.dbinfo|\\.indexes)\\b([^;\\\\]|\\\\n)*)?)*$"
|
|
217
|
+
- "(?is)^(?!.*(\\b(INSERT|UPDATE|DELETE|MERGE|COPY|CREATE|DROP|ALTER|TRUNCATE|ATTACH|DETACH|VACUUM|REINDEX|GRANT|REVOKE)\\b|\\bREPLACE\\s+INTO\\b|\\b(COMMIT|ROLLBACK)\\s+PREPARED\\b|\\bPRAGMA\\s+\\w+\\s*=))\\s*(SELECT|WITH|EXPLAIN|PRAGMA|BEGIN|START\\s+TRANSACTION|COMMIT|ROLLBACK|END|\\.tables|\\.schema|\\.databases|\\.dbinfo|\\.indexes)\\b([^;\\\\]|\\\\n)*(;\\s*((SELECT|WITH|EXPLAIN|PRAGMA|BEGIN|START\\s+TRANSACTION|COMMIT|ROLLBACK|END|\\.tables|\\.schema|\\.databases|\\.dbinfo|\\.indexes)\\b([^;\\\\]|\\\\n)*)?)*$"
|
|
218
218
|
# psql's describe commands: `\d portals`, `\dt+`, `\l`.
|
|
219
219
|
- "^\\\\(d[a-zA-Z]*\\+?|l\\+?|conninfo)(\\s+[\\w.*]+)?\\s*$"
|
|
220
220
|
action: allow
|
|
@@ -68,7 +68,7 @@ rules:
|
|
|
68
68
|
command_patterns:
|
|
69
69
|
- "^(ls|stat|file|test|\\[\\[?)(\\s|$)(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))"
|
|
70
70
|
- "^git\\s+(-C\\s+\\S+\\s+)?(status|check-ignore|ls-files)\\b(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))"
|
|
71
|
-
- "^grep(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))(?:\\s+-[Hhs]+)*\\s+-[Hhs]*c[cHhs]*(?:\\s+-[cHhs]+)*\\s+\\^[A-Z][A-Z0-9_]
|
|
71
|
+
- "^grep(?=.*(\\.env\\b(?!\\.(example|sample|template|dist))|\\.ssh/|\\.aws/|\\.gnupg/|authorized_keys|\\.pem\\b|\\.key\\b|\\.p12\\b|\\.pfx\\b|\\.keystore\\b|id_rsa|id_ed25519|id_ecdsa|id_dsa|\\.git-credentials\\b|credentials\\b|secrets?\\.|token\\.json\\b))(?:\\s+-[Hhs]+)*\\s+-[Hhs]*c[cHhs]*(?:\\s+-[cHhs]+)*\\s+\\^[A-Z][A-Z0-9_]*[_=](?:\\s+(?!-)[A-Za-z0-9_./~-]+)+$"
|
|
72
72
|
action: allow
|
|
73
73
|
description: "Metadata of a credential path (listing, existence, ignore status, a match count) without reading it"
|
|
74
74
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/session-management.md
RENAMED
|
File without changes
|
|
File without changes
|
{leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/trust-boundaries.md
RENAMED
|
File without changes
|
{leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/references/video-recording.md
RENAMED
|
File without changes
|
|
File without changes
|
{leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/templates/authenticated-session.sh
RENAMED
|
File without changes
|
{leashd-2.3.0 → leashd-2.4.0}/leashd/data/skills/agent-browser/templates/capture-workflow.sh
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|