Commit 1f15282
committed
fix(safety): multi-block aggregation must let NEEDS_HUMAN_REVIEW outweigh ALLOW
_scan_code_input's old aggregation only promoted a block to worst when it was DENY, or when it shared the same decision as worst with higher risk. So [safe_python (ALLOW), bash 'sleep 100 &' (NEEDS_HUMAN_REVIEW)] kept worst=ALLOW — a real bypass. Rewrite the comparison to rank by (decision_rank, risk_rank) where DENY > NEEDS_HUMAN_REVIEW > ALLOW, so any review/deny block outweighs an allow block.
Add two regression tests requested in review: (1) test_scan_code_input_multi_block_aggregates_safe_plus_review — multi-block [safe_python, 'sleep 100 &'] with block_on_review=True must return NEEDS_HUMAN_REVIEW and _should_block_report=True; (2) test_filter_block_on_review_pure_medium_returns_needs_review — ToolSafetyFilter with block_on_review=True and pure MEDIUM 'sleep 100 &' must return TOOL_SAFETY_NEEDS_REVIEW.1 parent 65ffdbe commit 1f15282
3 files changed
Lines changed: 56 additions & 5 deletions
File tree
- tests/tool_safety
- trpc_agent_sdk/safety
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
93 | 110 | | |
94 | 111 | | |
95 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
| |||
91 | 98 | | |
92 | 99 | | |
93 | 100 | | |
94 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
95 | 106 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | 107 | | |
100 | 108 | | |
101 | 109 | | |
| |||
0 commit comments