tools: add tool script safety guard#168
Open
shsaihdsaiudh wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #168 +/- ##
==========================================
Coverage ? 87.55044%
==========================================
Files ? 479
Lines ? 47335
Branches ? 0
==========================================
Hits ? 41442
Misses ? 5893
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tool, Skill, MCP, and CodeExecutor execution can carry scripts, commands, environment metadata, filesystem access, and network destinations that need a policy decision before execution. This change adds a configurable Tool Script Safety Guard for Python and Bash payloads.
The guard performs AST- and token-based static scanning for dangerous file access, non-allowlisted network calls, process execution, dependency installation, resource abuse, and sensitive-data exposure. It produces allow, deny, or needs_human_review reports with redacted evidence, JSONL audit events, and OpenTelemetry safety attributes.
ToolSafetyFilter runs as the final authorization filter after callbacks and argument transforms. A SafetyGuardedCodeExecutor wrapper covers executor code blocks. StreamingProgressTool, callback, telemetry, workspace timeout/background metadata, and BashTool defaults are integrated so the effective payload and execution limits are checked without leaking scripts or tool responses into traces.
The example includes a strict YAML policy, 12 canonical samples, a CLI scanner, a structured report, an audit log, and design documentation describing sandbox boundaries and extension points.
Validation completed with 368 safety tests at 86.94% safety-package coverage, 371 related filter/telemetry/streaming/executor/Bash/workspace regression tests, YAPF, flake8, compileall, canonical artifact validation, and wheel/sdist builds.
Fixes #90
RELEASE NOTES: Added configurable pre-execution safety checks, audit events, and telemetry redaction for script-capable tools and code executors.