feat: add tool script safety guard#234
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
AI Code Review已确认:提交的 发现的问题🚨 Critical未发现 Critical 级别问题。
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #234 +/- ##
==========================================
Coverage ? 87.94158%
==========================================
Files ? 493
Lines ? 45943
Branches ? 0
==========================================
Hits ? 40403
Misses ? 5540
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Follow-up incorporated in the latest clean commit:
Validation after the fix: required CI build/lint/test pass; focused safety tests are 47/47 with 93% package coverage. |
2ad7fad to
73afdad
Compare
Closes #90
Summary
allow,deny, orneeds_human_reviewdecisions with structured findings and redacted evidenceToolScriptSafetyFilterandSafetyGuardedCodeExecutortool.safety.*span attributesSecurity coverage
The default rules cover protected paths and destructive deletion, non-allowlisted network egress, subprocess/shell injection/pipelines/privilege escalation, runtime dependency installation, unbounded loops/fork bombs/large writes/long sleeps/concurrency, and secret output or exfiltration.
Configuration changes to
allowed_domains,allowed_commands,denied_paths, timeout/output/resource limits, rule decisions, and disabled rules require no code change. Human-review decisions fail closed unless an application explicitly continues after reviewing the exact script hash.This guard is intentionally a pre-execution policy layer, not a sandbox replacement. Runtime deployments must still enforce filesystem/network isolation, least privilege, syscall/PID/CPU/memory/disk limits, timeouts, and output quotas.
Validation
trpc_agent_sdk/tools/safetymodulesgit diff --checkpassedFull-suite environment note: optional Claude tests and CLI auto-discovery were excluded because
claude-agent-sdk<0.1.64usestyping.TypedDicton Python 3.11 while current Pydantic requirestyping_extensions.TypedDict. The remaining pre-existing failure istests/common/test_compatible.py::TestCheckenum::test_string_value_is_found_by_value, which expects Python 3.12 Enum behavior on Python 3.11.Known limitations
Static analysis remains vulnerable to obfuscation, generated code, runtime downloads, aliases/reflection, complex shell expansion, native binaries, symlink/TOCTOU races, and DNS rebinding. The docs describe these false-positive, false-negative, and bypass risks and how to extend rules safely.