Commit Graph
25 Commits
Author SHA1 Message Date
yuhao 99f92f0525 WIP transfer root-skills and hub updates 2026-04-18 10:12:58 +00:00
Ömer 1dcf1e033d Merge pull request #156 from furkankoykiran/security/domshell-security-hardening
feat(browser): add security hardening for DOMShell MCP automation
2026-04-07 22:06:57 +03:00
Chill Guy 3:00PM 1a591261b3 Refactor setup.py for better package configuration
Updated setup.py to improve package metadata and dependencies.
2026-03-30 22:25:19 +07:00
Furkan Köykıran 9777483db9 docs(browser): clarify explicit scheme requirement in security docs
Update URL Restrictions section to explicitly state that URLs must
include http:// or https:// scheme. Scheme-less URLs are rejected.

Addresses Copilot review comment at line 12.
2026-03-27 20:23:56 +03:00
Furkan Köykıran d566aafd45 test(browser): make env var tests deterministic with monkeypatch
- Add module reload mechanism for env var changes
- Update test_malformed_url with proper assertion
- Add tests for scheme-less URLs, uppercase schemes, hostname requirement
- Add test for fdn.example.com (IPv6 ULA pattern fix verification)
- Make all env var dependent tests use monkeypatch

Addresses Copilot review comments:
- Line 117: Added assertion to test_malformed_url
- Line 170: Made tests deterministic with monkeypatch
2026-03-27 20:23:49 +03:00
Furkan Köykıran 1029e3130b fix(browser): raise ValueError on URL validation failure
Instead of returning an error dict, raise ValueError so that
the CLI's @handle_error decorator can handle it consistently.

This ensures error messages are properly formatted in both
normal and JSON output modes, and prevents success messages
from being printed for invalid URLs.

Addresses Copilot review comment at line 30.
2026-03-27 20:23:43 +03:00
Furkan Köykıran f7de6ab306 fix(browser): normalize env var schemes and require explicit URL scheme
- Normalize _ALLOWED_SCHEMES to lowercase and filter empty entries
- Require explicit scheme (http/https) - reject scheme-less URLs
- Require hostname for http/https URLs
- Fix IPv6 ULA pattern to require hex + colon (was matching fdn.example.com)

Addresses Copilot review comments:
- Line 28: Uppercase env var schemes now work (HTTP,HTTPS)
- Line 65: Fixed r'^fd' pattern to r'^fd[0-9a-f]{2}:'
- Line 140: Scheme-less URLs now rejected with clear error message
2026-03-27 20:23:33 +03:00
Furkan Köykıran 9a01089bcb docs(browser): add security considerations to SKILL.md
Document security considerations for AI agents using browser CLI.

Add section covering:
- URL restrictions (blocked schemes, private network blocking)
- DOM content risks (ARIA label manipulation, hidden elements)
- Environment variables for security configuration
- Session isolation recommendations

Agents reading SKILL.md will be aware of security boundaries
and mitigations when interacting with untrusted websites.
2026-03-27 19:53:08 +03:00
Furkan Köykıran c37e82c79f feat(browser): integrate URL validation into page navigation
Modify open_page() to validate URLs before navigation via DOMShell.

Calls validate_url() from security.py to block dangerous schemes
and optionally restrict private network access. Returns error dict
if validation fails instead of passing dangerous URLs to browser.

This prevents SSRF attacks via file://, javascript://, and other
dangerous URI schemes.
2026-03-27 19:53:00 +03:00
Furkan Köykıran 57fc965ab1 test(browser): add security module unit tests
Add 42 tests for URL validation and DOM sanitization functions.

Tests cover:
- Blocked URI schemes (file://, javascript://, data://, etc.)
- Private network detection (127.0.0.1, 192.168.x.x, 10.x.x.x)
- DOM content sanitization and prompt injection pattern flagging
- Edge cases (empty URLs, None values, malformed URLs)

All tests pass without requiring DOMShell backend.
2026-03-27 19:52:53 +03:00
Furkan Köykıran c01edb3113 feat(browser): add URL validation and DOM sanitization utilities
Add security.py with validate_url() and sanitize_dom_text() functions
to mitigate SSRF and prompt injection risks in browser automation.

- validate_url(): Blocks dangerous schemes (file://, javascript://, data://)
- sanitize_dom_text(): Flags suspicious prompt injection patterns
- Configurable via CLI_ANYTHING_BROWSER_BLOCK_PRIVATE and
  CLI_ANYTHING_BROWSER_ALLOWED_SCHEMES environment variables

This addresses security concerns raised by Ilhan Goktas during
peer review of PR #118 (DOMShell MCP browser automation).
2026-03-27 19:52:13 +03:00
apirenoandClaude Opus 4.6 2d0381c236 fix(browser): address review feedback on DOMShell integration
- Build server args at call time so DOMSHELL_TOKEN/DOMSHELL_PORT env
  var changes are honored after import; raise clear error if token unset
- Implement cd+grep+cd pattern in grep_elements() so the path parameter
  correctly roots the search at the requested subtree
- Update grep_elements_with_path test to verify cd+grep+cd behavior

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 17:02:41 -04:00
apirenoandClaude Opus 4.6 bb941f2bb2 fix(browser): fix DOMShell MCP parameter mismatches and connection model
- Switch from `domshell` to `domshell-proxy` (stdio bridge) to match
  how MCP clients like Claude Desktop integrate with DOMShell
- Add DOMSHELL_TOKEN / DOMSHELL_PORT env var support for auth
- Fix MCP tool parameter names: ls (options), cat (name), click (name)
- Remove unsupported path param from grep
- Fix type_text to focus (domshell_focus) then type in single MCP session
- Add --allow-write --no-confirm flags for write commands

Fixes issues reported in PR #118.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:43:04 -04:00
Furkan Köykıran d8055f4421 fix(browser): improve error message and document daemon limitation
The DOMShell error message said "Install with" but npx doesn't actually
install packages, it runs them. Clarified the message. Also added a
known limitation comment about daemon mode using asyncio.run() per call,
which creates new event loops - to be addressed in a future PR.
2026-03-22 13:27:40 +03:00
Furkan Köykıran c341c00100 fix(tests): update mocks to match backend API changes
Tests were patching backend.open_url but the code now calls
backend.back() and backend.forward() directly. Updated mocks
to patch the correct functions.
2026-03-22 13:27:29 +03:00
Furkan Köykıran 5f20c5970e fix(tests): add proper assertions to e2e tests
test_daemon_start_with_json had a silent JSONDecodeError pass that
would hide regressions. test_invalid_path_gives_error ended with
assert True which doesn't verify any actual behavior.
2026-03-22 13:27:18 +03:00
Furkan Köykıran 827e5e0743 fix(browser): only update working_dir when backend cd succeeds
The change_directory function was updating session.working_dir even
when the backend returned an error. This could leave the session in an
invalid directory state and break subsequent relative-path operations.
2026-03-22 13:27:14 +03:00
Furkan Köykıran daa6001c01 fix(browser): redact sensitive text from act type output
The act type command was echoing the full text value in non-JSON mode,
which could leak passwords or PII into terminal scrollback and logs.
Now only outputs the target path without the typed text.
2026-03-22 13:27:09 +03:00
Furkan Köykıran b88b5458ec fix(docs): clarify daemon mode and state persistence behavior
Update documentation to clarify that daemon mode works within a single
process (REPL or --daemon flag) and that state does not persist across
separate CLI invocations.
2026-03-21 21:55:45 +03:00
Furkan Köykıran a41c5be3bc fix(docs): correct command name from cli-autocomplete-browser
Fix typo in daemon stop command name from cli-autocomplete-browser
to cli-anything-browser.
2026-03-21 21:55:38 +03:00
Furkan Köykıran a8fd4d6f98 fix(tests): use DOMSHELL_E2E environment variable for test gating
Avoid invoking npx during test collection by requiring DOMSHELL_E2E=1
environment variable. This prevents unwanted side effects when running
pytest in environments without DOMShell.
2026-03-21 21:55:31 +03:00
Furkan Köykıran 017a6ce6f1 fix(backend): fix daemon lifecycle to properly cleanup subprocess
Store the stdio_client context manager to ensure proper cleanup
when stopping daemon mode. Previously, __aexit__ was called on a new
instance, causing subprocess leaks.
2026-03-21 21:55:19 +03:00
Furkan Köykıran 1dfce3127b fix(page): use backend.back() and backend.forward() MCP tools
Instead of reconstructing navigation via open_url(), directly use the
DOMShell MCP tools for back/forward navigation. This ensures
proper browser history tracking.
2026-03-21 21:54:53 +03:00
Furkan Köykıran 99ff7438d8 fix(browser): skip dependency check for --help/--version
Allow --help and --version flags to work without DOMShell installed.
This aligns with other CLI-Anything harnesses where help is always available.
2026-03-21 21:54:37 +03:00
Furkan Köykıran 5fa31fc122 feat: add Browser automation CLI via DOMShell MCP server
Implement filesystem-first browser automation using DOMShell's MCP
server. Maps Chrome's Accessibility Tree to a virtual filesystem
for agent-native navigation with ls, cd, cat, grep, click commands.

Key features:
- MCP backend pattern (first in CLI-Anything)
- Daemon mode for persistent connections
- Page state management (URL, working directory, history)
- Filesystem-first commands (fs, page, act, session)
- Comprehensive test coverage (31 unit tests, 10 E2E tests)

Resolves #90
2026-03-21 21:28:18 +03:00