MCPcopy Create free account
hub / github.com/diillson/chatcli / sanitizeForPrompt

Method sanitizeForPrompt

cli/workspace/memory.go:130–140  ·  view source on GitHub ↗

sanitizeForPrompt neutralizes prompt-injection / exec / persistence payloads in memory before it is injected into the system prompt. Memory is auto-curated and should never carry shell scripts, so it uses the stricter ScopeMemory. The on-disk store is never modified.

(s string)

Source from the content-addressed store, hash-verified

128// is auto-curated and should never carry shell scripts, so it uses the
129// stricter ScopeMemory. The on-disk store is never modified.
130func (ms *MemoryStore) sanitizeForPrompt(s string) string {
131 if s == "" || !threatscan.Enabled() {
132 return s
133 }
134 sanitized, blocked := threatscan.Sanitize(s, threatscan.ScopeMemory)
135 if blocked > 0 && ms.logger != nil {
136 ms.logger.Warn("threatscan: neutralized lines in memory context",
137 zap.Int("blocked", blocked))
138 }
139 return sanitized
140}
141
142// AttachVectorIndex attaches a vector index used by HyDE Phase 3b.
143// Pass nil to detach.

Callers 4

GetMemoryContextMethod · 0.95
GetRelevantContextMethod · 0.95
GetMemoryIndexMethod · 0.95

Calls 3

EnabledFunction · 0.92
SanitizeFunction · 0.92
WarnMethod · 0.80

Tested by

no test coverage detected