Skip to content

Commit 4f07d1d

Browse files
committed
fix: filter type None crash and blocklist Bash bypass
- _safety_filter: set self._type = FilterType.TOOL to avoid AttributeError on self._type.name when scan throws. - _check_blocklist_override: skip Python string stripping for UNKNOWN scripts to avoid missing Bash eval/bash -c patterns.
1 parent 99cffb9 commit 4f07d1d

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

trpc_agent_sdk/tools/safety/_safety_filter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def __init__(
8383
self._block_on_deny = block_on_deny
8484

8585
# Identify ourselves within the filter chain
86-
self._type = None # will be set by registry
86+
from trpc_agent_sdk.abc import FilterType
87+
self._type = FilterType.TOOL
8788
self._name = "tool_safety"
8889

8990
# ------------------------------------------------------------------

trpc_agent_sdk/tools/safety/_scanner.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,11 @@ def _check_blocklist_override(self,
776776
stripped = line.lstrip()
777777
if stripped.startswith("#"):
778778
continue
779-
# Strip Python string-literal content only for Python
780-
# scripts so that Bash single-quoted paths like
781-
# cat '/etc/shadow' are not masked.
782-
if script_type in (ScriptType.PYTHON, ScriptType.UNKNOWN):
779+
# Strip Python string-literal content ONLY for Python
780+
# scripts. For Bash (or UNKNOWN, which may be Bash),
781+
# keep the raw line so that patterns inside eval "...",
782+
# bash -c '...', and similar quoting are still matched.
783+
if script_type == ScriptType.PYTHON:
783784
search_line = _strip_python_comment_line(line)
784785
else:
785786
search_line = line

0 commit comments

Comments
 (0)