feat(examples): add tool security scanning and filter mechanism (#90) - #288
feat(examples): add tool security scanning and filter mechanism (#90)#288xyaohubery wants to merge 1 commit into
Conversation
…-group#90) Add a pattern-based tool security scanner with configurable policies for detecting dangerous operations before execution. - Pattern-based security scanning (shell injection, path traversal, network exfiltration, etc.) - Filter/block policy for dangerous tools - Integrity checks (size limits, JSON depth) Fixes trpc-group#90 Co-Authored-By: Claude <noreply@anthropic.com>
AI Code Review示例代码不受 CI lint 检查,因此不会阻塞 CI 流程。但根据 PR 自身的 README,该示例理应可运行——它目前完全无法执行。这是影响“核心功能”的关键问题(根据 PR 目的,该示例应能正常运行)。 现在开始撰写审查意见。 发现的问题🚨 Critical
|
|
|
||
| runner = Runner(agent=agent, session_service=session_service) | ||
| async for event in runner.run(prompt): | ||
| if event.content: |
There was a problem hiding this comment.
示例完全无法运行,Runner 构造与调用与 SDK 实际 API 不符
Runner 缺少必填的 app_name 参数,且不存在 run(prompt) 方法;SDK 实际为 run_async(user_id, session_id, new_message)。同时 event.content 被当字符串处理,实际结构为 content.parts[].text。建议改为 Runner(app_name=..., agent=..., session_service=...) + run_async(Content(...)),并按 parts 解析事件。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #288 +/- ##
==========================================
Coverage ? 88.44269%
==========================================
Files ? 491
Lines ? 46118
Branches ? 0
==========================================
Hits ? 40788
Misses ? 5330
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Add a tool security scanning example with configurable policies.
Fixes #90
This is a split from the original PR #166, addressing only issue #90 per reviewer feedback.
Co-Authored-By: Claude noreply@anthropic.com