-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontent-blocker.tengo
More file actions
45 lines (39 loc) · 1.18 KB
/
content-blocker.tengo
File metadata and controls
45 lines (39 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Content Blocker Filter
// This script blocks requests containing sensitive keywords
text := import("text")
// Define sensitive keywords to block
sensitive_keywords := ["password", "secret", "api_key", "token", "credit card"]
// Check all user messages for sensitive content
should_block := false
found_keyword := ""
for msg in input.messages {
if msg.role == "user" {
for keyword in sensitive_keywords {
if text.contains(msg.content, keyword) {
should_block = true
found_keyword = keyword
break
}
}
if should_block {
break
}
}
}
compliance_events_list := []
if should_block {
compliance_events_list = [
{
event_type: "sensitive_content_detected",
severity: "critical",
description: "Blocked: sensitive keyword '" + found_keyword + "' detected",
metadata: { "matched_pattern": found_keyword }
}
]
}
output := {
block: should_block,
payload: input.raw_input,
message: should_block ? "Blocked: message contains '" + found_keyword + "'" : "",
compliance_events: compliance_events_list
}