mirror of
https://github.com/HKUDS/CLI-Anything.git
synced 2026-11-04 23:42:05 +08:00
The repo's threat model (SECURITY.md) calls out XML/SVG content as a key
attack surface and lists "ElementTree auto-escaping" as the mitigation.
That covers XML *output* (serialization). XML *input* (parsing) across
the agent backends still goes through stdlib `xml.etree.ElementTree`,
which is vulnerable to entity-expansion DoS ("billion laughs" /
quadratic blowup) — Python 3.7.1 disabled external-entity lookup on ET
by default, but internal-entity expansion is still possible and can
exhaust CPU/RAM from a small file.
Migrate the parse/fromstring call sites in production code paths to
defusedxml.ElementTree (drop-in API). Construction calls (Element,
SubElement, tostring, register_namespace) are left on stdlib ET — those
don't parse untrusted input. Tests are left as-is in this PR.
Detected by Aeon + semgrep p/security-audit + p/owasp-top-ten
(rules: use-defused-xml, use-defused-xml-parse).
Severity: medium (DoS from agent-ingested files; not RCE).
CWE-776 Improper Restriction of Recursive Entity References.
MacroCLI
MacroCLI is a layered CLI that converts GUI workflows into
parameterized, agent-callable macros. Agents call macro run <name> through
a stable CLI; the system routes execution to the right backend (native plugin,
file transform, semantic UI, or compiled GUI replay) — invisible to the agent.
Installation
pip install -e .
Dependencies: Python 3.10+, PyYAML, click, prompt-toolkit
Optional extras:
pip install -e ".[visual]" # visual_anchor backend (mss, Pillow, numpy, pynput)
pip install -e ".[gui_agent]" # gui_agent backend (openai, mss, Pillow)
pip install -e ".[all]" # everything
The gui_agent backend uses the OpenAI SDK and is compatible with any
OpenAI-compatible API. Configure via environment variables:
| Variable | Description |
|---|---|
MACROCLI_MODEL |
Model name (required, e.g. gpt-4o) |
MACROCLI_API_KEY |
API key for the provider |
MACROCLI_BASE_URL |
Base URL (only needed for non-OpenAI hosts) |
Usage
# List available macros
cli-anything-macrocli macro list --json
# Inspect a macro
cli-anything-macrocli macro info export_file --json
# Execute a macro
cli-anything-macrocli macro run transform_json \
--param file=/tmp/config.json \
--param key=theme --param value=dark --json
# Dry run
cli-anything-macrocli --dry-run macro run export_file \
--param output=/tmp/out.txt --json
# Interactive REPL
cli-anything-macrocli
Run Tests
cd macrocli/agent-harness
pip install -e ".[dev]"
python -m pytest cli_anything/macrocli/tests/ -v -s
Architecture
cli-anything-macrocli (CLI)
└─▶ macro run <name> --param key=value
│
MacroRuntime
│ validate params
│ check preconditions
│ for each step:
│ RoutingEngine → select backend
│ Backend.execute(step, params)
│ check postconditions
└─▶ ExecutionResult { success, output, telemetry }
Backends:
native_api— subprocess / shell commandsfile_transform— XML, JSON, text file editingsemantic_ui— accessibility controls + keyboard shortcutsvisual_anchor— template-matching click/type (requires[visual])gui_agent— vision-model-driven automation (requires[gui_agent])gui_macro— precompiled coordinate-based replayrecovery— retry + fallback orchestration
Adding a Macro
- Create
cli_anything/macrocli/macro_definitions/my_macro.yaml - Add it to
macro_definitions/manifest.yaml - Verify:
cli-anything-macrocli macro validate my_macro --json
See skills/SKILL.md (installed with the package) for full macro YAML schema.