Add Memory Gateway agent plugin

This commit is contained in:
2026-05-06 16:10:04 +08:00
parent e65731a273
commit c44af407d4
48 changed files with 3111 additions and 0 deletions

View File

@ -0,0 +1,24 @@
from __future__ import annotations
from memory_gateway_plugin.safety import detect_large_log, sanitize_memory_content, validate_memory_write
def test_safety_rejects_private_key():
content = "-----BEGIN PRIVATE KEY-----\nabc\n-----END PRIVATE KEY-----"
result = validate_memory_write(content)
assert result["allowed"] is False
assert result["reason"] == "secret_like_content"
def test_safety_rejects_large_log():
content = "\n".join(f"2026-05-06 10:00:{i:02d} ERROR failure" for i in range(10))
blocked, reason = detect_large_log(content)
assert blocked is True
assert reason == "large_or_raw_log"
def test_safety_sanitizes_secret_when_called_directly():
assert "sk-test" not in sanitize_memory_content("api_key=sk-test")