@sandrobuilds/tracerney 0.9.22 → 0.9.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -139
- package/dist/application/ShieldApplicationService.d.ts +8 -0
- package/dist/application/ShieldApplicationService.d.ts.map +1 -1
- package/dist/application/ShieldApplicationService.js +48 -2
- package/dist/application/ShieldApplicationService.js.map +1 -1
- package/dist/domain/events/SecurityEventType.d.ts +5 -1
- package/dist/domain/events/SecurityEventType.d.ts.map +1 -1
- package/dist/domain/events/SecurityEventType.js +4 -0
- package/dist/domain/events/SecurityEventType.js.map +1 -1
- package/dist/domain/pii/DeterministicFilter.d.ts +79 -0
- package/dist/domain/pii/DeterministicFilter.d.ts.map +1 -0
- package/dist/domain/pii/DeterministicFilter.js +151 -0
- package/dist/domain/pii/DeterministicFilter.js.map +1 -0
- package/dist/domain/pii/PIIPattern.d.ts +41 -0
- package/dist/domain/pii/PIIPattern.d.ts.map +1 -0
- package/dist/domain/pii/PIIPattern.js +253 -0
- package/dist/domain/pii/PIIPattern.js.map +1 -0
- package/dist/domain/pii/index.d.ts +9 -0
- package/dist/domain/pii/index.d.ts.map +1 -0
- package/dist/domain/pii/index.js +7 -0
- package/dist/domain/pii/index.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic Filter
|
|
3
|
+
* Domain service: Layer 1 outbound intelligent gatekeeper.
|
|
4
|
+
*
|
|
5
|
+
* Philosophy — The SDK is a HIGH-PRECISION SENSOR, not a policy enforcer.
|
|
6
|
+
*
|
|
7
|
+
* Every match is surfaced as a SuspiciousTrace. The developer owns the reaction:
|
|
8
|
+
*
|
|
9
|
+
* const trace = tracerney.validate(agentOutput);
|
|
10
|
+
*
|
|
11
|
+
* if (trace.isSuspicious) {
|
|
12
|
+
* console.log(`Alert: ${trace.reason}`);
|
|
13
|
+
*
|
|
14
|
+
* // Option A: Hard Block
|
|
15
|
+
* // throw new Error("Security Policy Violation");
|
|
16
|
+
*
|
|
17
|
+
* // Option B: Surgical Scrub
|
|
18
|
+
* // return trace.redactedContent;
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* See the "Suspicious Manifest" in PIIPattern.ts for the label-to-action guide.
|
|
22
|
+
*
|
|
23
|
+
* Pure synchronous — no I/O, no async. Target latency <5ms.
|
|
24
|
+
*/
|
|
25
|
+
import { PII_PATTERNS, CATEGORY_TO_LABEL, LABEL_PRIORITY, } from './PIIPattern.js';
|
|
26
|
+
// ─── Service ──────────────────────────────────────────────────────────────────
|
|
27
|
+
export class DeterministicFilter {
|
|
28
|
+
constructor(patterns = PII_PATTERNS) {
|
|
29
|
+
this.patterns = patterns;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Scan a plain string and return a SuspiciousTrace.
|
|
33
|
+
* Always returns — never throws. The caller decides what to do.
|
|
34
|
+
*/
|
|
35
|
+
validate(text) {
|
|
36
|
+
if (!text || typeof text !== "string") {
|
|
37
|
+
return {
|
|
38
|
+
isSuspicious: false,
|
|
39
|
+
label: null,
|
|
40
|
+
reason: "Clean",
|
|
41
|
+
redactedContent: text ?? "",
|
|
42
|
+
findings: [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
let redacted = text;
|
|
46
|
+
const findings = [];
|
|
47
|
+
for (const p of this.patterns) {
|
|
48
|
+
p.pattern.lastIndex = 0;
|
|
49
|
+
const matches = redacted.match(p.pattern);
|
|
50
|
+
if (!matches || matches.length === 0)
|
|
51
|
+
continue;
|
|
52
|
+
p.pattern.lastIndex = 0;
|
|
53
|
+
redacted = redacted.replace(p.pattern, p.redactAs);
|
|
54
|
+
findings.push({
|
|
55
|
+
patternId: p.id,
|
|
56
|
+
patternName: p.name,
|
|
57
|
+
category: p.category,
|
|
58
|
+
label: CATEGORY_TO_LABEL[p.category],
|
|
59
|
+
count: matches.length,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (findings.length === 0) {
|
|
63
|
+
return {
|
|
64
|
+
isSuspicious: false,
|
|
65
|
+
label: null,
|
|
66
|
+
reason: "Clean",
|
|
67
|
+
redactedContent: text,
|
|
68
|
+
findings: [],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Derive the highest-severity label across all findings
|
|
72
|
+
const dominantLabel = findings.reduce((best, f) => {
|
|
73
|
+
return LABEL_PRIORITY[f.label] > LABEL_PRIORITY[best] ? f.label : best;
|
|
74
|
+
}, findings[0].label);
|
|
75
|
+
const reason = `Detected ${findings.length} finding(s): ${findings.map((f) => f.patternName).join(", ")}`;
|
|
76
|
+
return {
|
|
77
|
+
isSuspicious: true,
|
|
78
|
+
label: dominantLabel,
|
|
79
|
+
reason,
|
|
80
|
+
redactedContent: redacted,
|
|
81
|
+
findings,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Scan all text content in an LLMResponse.
|
|
86
|
+
* Returns a merged SuspiciousTrace (highest label across all choices)
|
|
87
|
+
* and a new response with redactedContent applied — never mutates the original.
|
|
88
|
+
*/
|
|
89
|
+
filterResponse(response) {
|
|
90
|
+
if (!response?.choices?.length) {
|
|
91
|
+
const cleanTrace = {
|
|
92
|
+
isSuspicious: false,
|
|
93
|
+
label: null,
|
|
94
|
+
reason: "Clean",
|
|
95
|
+
redactedContent: "",
|
|
96
|
+
findings: [],
|
|
97
|
+
};
|
|
98
|
+
return { response, outcome: { trace: cleanTrace } };
|
|
99
|
+
}
|
|
100
|
+
const allFindings = [];
|
|
101
|
+
let anyRedacted = false;
|
|
102
|
+
const sanitizedChoices = [];
|
|
103
|
+
for (const choice of response.choices) {
|
|
104
|
+
const content = choice.message?.content;
|
|
105
|
+
if (!content) {
|
|
106
|
+
sanitizedChoices.push(choice);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const trace = this.validate(content);
|
|
110
|
+
if (trace.isSuspicious) {
|
|
111
|
+
anyRedacted = true;
|
|
112
|
+
allFindings.push(...trace.findings);
|
|
113
|
+
sanitizedChoices.push({
|
|
114
|
+
...choice,
|
|
115
|
+
message: { ...choice.message, content: trace.redactedContent },
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
sanitizedChoices.push(choice);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const sanitizedResponse = anyRedacted
|
|
123
|
+
? { ...response, choices: sanitizedChoices }
|
|
124
|
+
: response;
|
|
125
|
+
if (allFindings.length === 0) {
|
|
126
|
+
const cleanTrace = {
|
|
127
|
+
isSuspicious: false,
|
|
128
|
+
label: null,
|
|
129
|
+
reason: "Clean",
|
|
130
|
+
redactedContent: "",
|
|
131
|
+
findings: [],
|
|
132
|
+
};
|
|
133
|
+
return { response: sanitizedResponse, outcome: { trace: cleanTrace } };
|
|
134
|
+
}
|
|
135
|
+
const dominantLabel = allFindings.reduce((best, f) => {
|
|
136
|
+
return LABEL_PRIORITY[f.label] > LABEL_PRIORITY[best] ? f.label : best;
|
|
137
|
+
}, allFindings[0].label);
|
|
138
|
+
const mergedTrace = {
|
|
139
|
+
isSuspicious: true,
|
|
140
|
+
label: dominantLabel,
|
|
141
|
+
reason: `Detected ${allFindings.length} finding(s): ${allFindings.map((f) => f.patternName).join(", ")}`,
|
|
142
|
+
redactedContent: "",
|
|
143
|
+
findings: allFindings,
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
response: sanitizedResponse,
|
|
147
|
+
outcome: { trace: mergedTrace, redactedResponse: sanitizedResponse },
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=DeterministicFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeterministicFilter.js","sourceRoot":"","sources":["../../../src/domain/pii/DeterministicFilter.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,EAAE,iBAAiB,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC;QACzE,CAAC;QAED,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAkB,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YACpE,OAAO,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QACzE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAEzB,MAAM,WAAW,GAAoB;YACnC,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,YAAY,WAAW,CAAC,MAAM,gBAAgB,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACxG,eAAe,EAAE,EAAE;YACnB,QAAQ,EAAE,WAAW;SACtB,CAAC;QAEF,OAAO;YACL,QAAQ,EAAE,iBAAiB;YAC3B,OAAO,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE;SACrE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PII Pattern
|
|
3
|
+
* Domain value object: immutable pattern definitions for Layer 1 outbound filtering.
|
|
4
|
+
*
|
|
5
|
+
* The SDK is a HIGH-PRECISION SENSOR. It does not guess the developer's intent.
|
|
6
|
+
* Every match is labeled SUSPICIOUS with a specific SuspiciousLabel.
|
|
7
|
+
* The developer decides the reaction: redact, block, or audit.
|
|
8
|
+
*
|
|
9
|
+
* The "Suspicious" Manifest:
|
|
10
|
+
* ┌──────────────────┬────────────────────────┬───────────────────────┐
|
|
11
|
+
* │ Trigger │ Label │ Developer's Action │
|
|
12
|
+
* ├──────────────────┼────────────────────────┼───────────────────────┤
|
|
13
|
+
* │ Email / Phone │ SUSPICIOUS_PII │ Usually Redact │
|
|
14
|
+
* │ API / SSH Keys │ SUSPICIOUS_SECRET │ Usually Block │
|
|
15
|
+
* │ External URL │ SUSPICIOUS_EGRESS │ Always Block │
|
|
16
|
+
* │ ASCII / Unicode │ SUSPICIOUS_ENCODING │ Audit / Block │
|
|
17
|
+
* └──────────────────┴────────────────────────┴───────────────────────┘
|
|
18
|
+
*
|
|
19
|
+
* All regex patterns carry the global flag so String.replace replaces every match.
|
|
20
|
+
*/
|
|
21
|
+
export type PIICategory = "email" | "phone" | "credit_card" | "ssn" | "api_key" | "ssh_private_key" | "egress_url_smuggling" | "egress_credential_url" | "egress_base64_url" | "encoding_zero_width" | "encoding_direction_override" | "encoding_base64_blob";
|
|
22
|
+
/**
|
|
23
|
+
* Semantic label surfaced on every SuspiciousTrace.
|
|
24
|
+
* Maps directly to the "Suspicious Manifest" table — developer uses this to route decisions.
|
|
25
|
+
*/
|
|
26
|
+
export type SuspiciousLabel = "SUSPICIOUS_PII" | "SUSPICIOUS_SECRET" | "SUSPICIOUS_EGRESS" | "SUSPICIOUS_ENCODING";
|
|
27
|
+
/** Maps each category to its semantic label */
|
|
28
|
+
export declare const CATEGORY_TO_LABEL: Readonly<Record<PIICategory, SuspiciousLabel>>;
|
|
29
|
+
/** Priority order for label escalation (highest wins when multiple labels fire) */
|
|
30
|
+
export declare const LABEL_PRIORITY: Readonly<Record<SuspiciousLabel, number>>;
|
|
31
|
+
export interface PIIPattern {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly name: string;
|
|
34
|
+
/** Must carry the global flag — String.replace relies on it */
|
|
35
|
+
readonly pattern: RegExp;
|
|
36
|
+
readonly category: PIICategory;
|
|
37
|
+
/** Token to substitute in the pre-computed redactedContent */
|
|
38
|
+
readonly redactAs: string;
|
|
39
|
+
}
|
|
40
|
+
export declare const PII_PATTERNS: readonly PIIPattern[];
|
|
41
|
+
//# sourceMappingURL=PIIPattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PIIPattern.d.ts","sourceRoot":"","sources":["../../../src/domain/pii/PIIPattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,MAAM,WAAW,GACnB,OAAO,GACP,OAAO,GACP,aAAa,GACb,KAAK,GACL,SAAS,GACT,iBAAiB,GACjB,sBAAsB,GACtB,uBAAuB,GACvB,mBAAmB,GACnB,qBAAqB,GACrB,6BAA6B,GAC7B,sBAAsB,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,mBAAmB,GACnB,mBAAmB,GACnB,qBAAqB,CAAC;AAE1B,+CAA+C;AAC/C,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC,CAa5E,CAAC;AAEF,mFAAmF;AACnF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAKpE,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAuND,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAK7C,CAAC"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PII Pattern
|
|
3
|
+
* Domain value object: immutable pattern definitions for Layer 1 outbound filtering.
|
|
4
|
+
*
|
|
5
|
+
* The SDK is a HIGH-PRECISION SENSOR. It does not guess the developer's intent.
|
|
6
|
+
* Every match is labeled SUSPICIOUS with a specific SuspiciousLabel.
|
|
7
|
+
* The developer decides the reaction: redact, block, or audit.
|
|
8
|
+
*
|
|
9
|
+
* The "Suspicious" Manifest:
|
|
10
|
+
* ┌──────────────────┬────────────────────────┬───────────────────────┐
|
|
11
|
+
* │ Trigger │ Label │ Developer's Action │
|
|
12
|
+
* ├──────────────────┼────────────────────────┼───────────────────────┤
|
|
13
|
+
* │ Email / Phone │ SUSPICIOUS_PII │ Usually Redact │
|
|
14
|
+
* │ API / SSH Keys │ SUSPICIOUS_SECRET │ Usually Block │
|
|
15
|
+
* │ External URL │ SUSPICIOUS_EGRESS │ Always Block │
|
|
16
|
+
* │ ASCII / Unicode │ SUSPICIOUS_ENCODING │ Audit / Block │
|
|
17
|
+
* └──────────────────┴────────────────────────┴───────────────────────┘
|
|
18
|
+
*
|
|
19
|
+
* All regex patterns carry the global flag so String.replace replaces every match.
|
|
20
|
+
*/
|
|
21
|
+
/** Maps each category to its semantic label */
|
|
22
|
+
export const CATEGORY_TO_LABEL = {
|
|
23
|
+
email: "SUSPICIOUS_PII",
|
|
24
|
+
phone: "SUSPICIOUS_PII",
|
|
25
|
+
credit_card: "SUSPICIOUS_SECRET",
|
|
26
|
+
ssn: "SUSPICIOUS_SECRET",
|
|
27
|
+
api_key: "SUSPICIOUS_SECRET",
|
|
28
|
+
ssh_private_key: "SUSPICIOUS_SECRET",
|
|
29
|
+
egress_url_smuggling: "SUSPICIOUS_EGRESS",
|
|
30
|
+
egress_credential_url: "SUSPICIOUS_EGRESS",
|
|
31
|
+
egress_base64_url: "SUSPICIOUS_EGRESS",
|
|
32
|
+
encoding_zero_width: "SUSPICIOUS_ENCODING",
|
|
33
|
+
encoding_direction_override: "SUSPICIOUS_ENCODING",
|
|
34
|
+
encoding_base64_blob: "SUSPICIOUS_ENCODING",
|
|
35
|
+
};
|
|
36
|
+
/** Priority order for label escalation (highest wins when multiple labels fire) */
|
|
37
|
+
export const LABEL_PRIORITY = {
|
|
38
|
+
SUSPICIOUS_EGRESS: 3,
|
|
39
|
+
SUSPICIOUS_SECRET: 2,
|
|
40
|
+
SUSPICIOUS_ENCODING: 1,
|
|
41
|
+
SUSPICIOUS_PII: 0,
|
|
42
|
+
};
|
|
43
|
+
// ─── SUSPICIOUS_EGRESS ────────────────────────────────────────────────────────
|
|
44
|
+
const EGRESS_PATTERNS = [
|
|
45
|
+
{
|
|
46
|
+
id: "pii-egress-001",
|
|
47
|
+
name: "Markdown Image with URL Query Params (Data Smuggling)",
|
|
48
|
+
// 
|
|
49
|
+
pattern: /!\[[^\]]*\]\(https?:\/\/[^\s)]*\?[^\s)]+\)/gi,
|
|
50
|
+
category: "egress_url_smuggling",
|
|
51
|
+
redactAs: "[SUSPICIOUS_EGRESS:MARKDOWN_IMAGE_SMUGGLING]",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "pii-egress-002",
|
|
55
|
+
name: "Markdown Link with URL Query Params (Data Smuggling)",
|
|
56
|
+
// [click](https://evil.com?data=secret)
|
|
57
|
+
pattern: /(?<!!)\[[^\]]*\]\(https?:\/\/[^\s)]*\?[^\s)]+\)/gi,
|
|
58
|
+
category: "egress_url_smuggling",
|
|
59
|
+
redactAs: "[SUSPICIOUS_EGRESS:MARKDOWN_LINK_SMUGGLING]",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "pii-egress-003",
|
|
63
|
+
name: "Credential-Embedded URL",
|
|
64
|
+
// https://user:password@hostname
|
|
65
|
+
pattern: /https?:\/\/[A-Za-z0-9._%-]+:[A-Za-z0-9._~!$&'()*+,;=%-]+@[A-Za-z0-9.-]+/gi,
|
|
66
|
+
category: "egress_credential_url",
|
|
67
|
+
redactAs: "[SUSPICIOUS_EGRESS:CREDENTIAL_URL]",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "pii-egress-004",
|
|
71
|
+
name: "Base64 Blob in URL Parameter",
|
|
72
|
+
// ?param=<80+ base64 chars> — encodes data for exfiltration via tracking pixels
|
|
73
|
+
pattern: /[?&][A-Za-z0-9_%-]+=(?:[A-Za-z0-9+/]{80,}={0,2})/g,
|
|
74
|
+
category: "egress_base64_url",
|
|
75
|
+
redactAs: "[SUSPICIOUS_EGRESS:BASE64_URL_PAYLOAD]",
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
// ─── SUSPICIOUS_ENCODING ──────────────────────────────────────────────────────
|
|
79
|
+
const ENCODING_PATTERNS = [
|
|
80
|
+
{
|
|
81
|
+
id: "pii-enc-001",
|
|
82
|
+
name: "Zero-Width Characters",
|
|
83
|
+
// Invisible Unicode used to watermark, fingerprint, or smuggle hidden data
|
|
84
|
+
pattern: /[\u200B\u200C\u200D\uFEFF\u2060]+/g,
|
|
85
|
+
category: "encoding_zero_width",
|
|
86
|
+
redactAs: "[SUSPICIOUS_ENCODING:ZERO_WIDTH_CHARS]",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: "pii-enc-002",
|
|
90
|
+
name: "Unicode Bidirectional Override",
|
|
91
|
+
// LRE/RLE/PDF/LRO/RLO and newer isolate/pop chars — used to reverse text visually
|
|
92
|
+
pattern: /[\u202A-\u202E\u2066-\u2069]+/g,
|
|
93
|
+
category: "encoding_direction_override",
|
|
94
|
+
redactAs: "[SUSPICIOUS_ENCODING:BIDI_OVERRIDE]",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: "pii-enc-003",
|
|
98
|
+
name: "Standalone Base64 Blob (≥120 chars)",
|
|
99
|
+
// A large base64 block outside of a URL — likely encoded payload or data exfil
|
|
100
|
+
pattern: /(?<![A-Za-z0-9+/])(?:[A-Za-z0-9+/]{4}){30,}(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?(?![A-Za-z0-9+/=])/g,
|
|
101
|
+
category: "encoding_base64_blob",
|
|
102
|
+
redactAs: "[SUSPICIOUS_ENCODING:BASE64_BLOB]",
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
// ─── SUSPICIOUS_SECRET ────────────────────────────────────────────────────────
|
|
106
|
+
const SECRET_PATTERNS = [
|
|
107
|
+
{
|
|
108
|
+
id: "pii-ssh-001",
|
|
109
|
+
name: "SSH/PEM Private Key Block",
|
|
110
|
+
pattern: /-----BEGIN (?:RSA |DSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |DSA |EC |OPENSSH )?PRIVATE KEY-----/gi,
|
|
111
|
+
category: "ssh_private_key",
|
|
112
|
+
redactAs: "[SUSPICIOUS_SECRET:SSH_PRIVATE_KEY]",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: "pii-apikey-001",
|
|
116
|
+
name: "Anthropic API Key",
|
|
117
|
+
pattern: /sk-ant-api0[0-9]+-[A-Za-z0-9_-]{32,}/g,
|
|
118
|
+
category: "api_key",
|
|
119
|
+
redactAs: "[SUSPICIOUS_SECRET:ANTHROPIC_API_KEY]",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: "pii-apikey-002",
|
|
123
|
+
name: "OpenAI API Key",
|
|
124
|
+
pattern: /sk-(?:proj-)?[A-Za-z0-9]{32,}/g,
|
|
125
|
+
category: "api_key",
|
|
126
|
+
redactAs: "[SUSPICIOUS_SECRET:OPENAI_API_KEY]",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: "pii-apikey-003",
|
|
130
|
+
name: "Stripe Live Secret Key",
|
|
131
|
+
pattern: /sk_live_[A-Za-z0-9]{24,}/g,
|
|
132
|
+
category: "api_key",
|
|
133
|
+
redactAs: "[SUSPICIOUS_SECRET:STRIPE_SECRET_KEY]",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
id: "pii-apikey-004",
|
|
137
|
+
name: "Stripe Live Restricted Key",
|
|
138
|
+
pattern: /rk_live_[A-Za-z0-9]{24,}/g,
|
|
139
|
+
category: "api_key",
|
|
140
|
+
redactAs: "[SUSPICIOUS_SECRET:STRIPE_RESTRICTED_KEY]",
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: "pii-apikey-005",
|
|
144
|
+
name: "GitHub Personal Access Token (classic)",
|
|
145
|
+
pattern: /ghp_[A-Za-z0-9]{36}/g,
|
|
146
|
+
category: "api_key",
|
|
147
|
+
redactAs: "[SUSPICIOUS_SECRET:GITHUB_TOKEN]",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: "pii-apikey-006",
|
|
151
|
+
name: "GitHub Personal Access Token (fine-grained)",
|
|
152
|
+
pattern: /github_pat_[A-Za-z0-9_]{82}/g,
|
|
153
|
+
category: "api_key",
|
|
154
|
+
redactAs: "[SUSPICIOUS_SECRET:GITHUB_TOKEN]",
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: "pii-apikey-007",
|
|
158
|
+
name: "AWS Access Key ID",
|
|
159
|
+
pattern: /\bAKIA[0-9A-Z]{16}\b/g,
|
|
160
|
+
category: "api_key",
|
|
161
|
+
redactAs: "[SUSPICIOUS_SECRET:AWS_ACCESS_KEY]",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: "pii-apikey-008",
|
|
165
|
+
name: "Google API Key",
|
|
166
|
+
pattern: /\bAIza[0-9A-Za-z_-]{35}\b/g,
|
|
167
|
+
category: "api_key",
|
|
168
|
+
redactAs: "[SUSPICIOUS_SECRET:GOOGLE_API_KEY]",
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
id: "pii-apikey-009",
|
|
172
|
+
name: "Slack Token",
|
|
173
|
+
pattern: /\bxox[baprs]-[0-9A-Za-z-]{10,}\b/g,
|
|
174
|
+
category: "api_key",
|
|
175
|
+
redactAs: "[SUSPICIOUS_SECRET:SLACK_TOKEN]",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: "pii-apikey-010",
|
|
179
|
+
name: "SendGrid API Key",
|
|
180
|
+
pattern: /\bSG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}\b/g,
|
|
181
|
+
category: "api_key",
|
|
182
|
+
redactAs: "[SUSPICIOUS_SECRET:SENDGRID_API_KEY]",
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
id: "pii-apikey-011",
|
|
186
|
+
name: "Twilio API Key",
|
|
187
|
+
pattern: /\bSK[0-9a-fA-F]{32}\b/g,
|
|
188
|
+
category: "api_key",
|
|
189
|
+
redactAs: "[SUSPICIOUS_SECRET:TWILIO_API_KEY]",
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
id: "pii-cc-001",
|
|
193
|
+
name: "Visa Card Number",
|
|
194
|
+
pattern: /\b4[0-9]{3}[- ]?[0-9]{4}[- ]?[0-9]{4}[- ]?[0-9]{4}\b/g,
|
|
195
|
+
category: "credit_card",
|
|
196
|
+
redactAs: "[SUSPICIOUS_SECRET:CREDIT_CARD]",
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
id: "pii-cc-002",
|
|
200
|
+
name: "Mastercard Number",
|
|
201
|
+
pattern: /\b(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[- ]?[0-9]{4}[- ]?[0-9]{4}[- ]?[0-9]{4}\b/g,
|
|
202
|
+
category: "credit_card",
|
|
203
|
+
redactAs: "[SUSPICIOUS_SECRET:CREDIT_CARD]",
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
id: "pii-cc-003",
|
|
207
|
+
name: "Amex Card Number",
|
|
208
|
+
pattern: /\b3[47][0-9]{2}[- ]?[0-9]{6}[- ]?[0-9]{5}\b/g,
|
|
209
|
+
category: "credit_card",
|
|
210
|
+
redactAs: "[SUSPICIOUS_SECRET:CREDIT_CARD]",
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
id: "pii-cc-004",
|
|
214
|
+
name: "Discover Card Number",
|
|
215
|
+
pattern: /\b6(?:011|5[0-9]{2})[- ]?[0-9]{4}[- ]?[0-9]{4}[- ]?[0-9]{4}\b/g,
|
|
216
|
+
category: "credit_card",
|
|
217
|
+
redactAs: "[SUSPICIOUS_SECRET:CREDIT_CARD]",
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
id: "pii-ssn-001",
|
|
221
|
+
name: "US Social Security Number",
|
|
222
|
+
pattern: /(?<!\d)\d{3}-\d{2}-\d{4}(?!\d)/g,
|
|
223
|
+
category: "ssn",
|
|
224
|
+
redactAs: "[SUSPICIOUS_SECRET:SSN]",
|
|
225
|
+
},
|
|
226
|
+
];
|
|
227
|
+
// ─── SUSPICIOUS_PII ───────────────────────────────────────────────────────────
|
|
228
|
+
const PII_PATTERNS_LOW = [
|
|
229
|
+
{
|
|
230
|
+
id: "pii-email-001",
|
|
231
|
+
name: "Email Address",
|
|
232
|
+
pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,
|
|
233
|
+
category: "email",
|
|
234
|
+
redactAs: "[SUSPICIOUS_PII:EMAIL]",
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
id: "pii-phone-001",
|
|
238
|
+
name: "US Phone Number",
|
|
239
|
+
pattern: /(?<!\d)(?:\+1[-.\s]?)?\(?[2-9][0-9]{2}\)?[-.\s][0-9]{3}[-.\s][0-9]{4}(?!\d)/g,
|
|
240
|
+
category: "phone",
|
|
241
|
+
redactAs: "[SUSPICIOUS_PII:PHONE]",
|
|
242
|
+
},
|
|
243
|
+
];
|
|
244
|
+
// ─── Canonical ordered set ────────────────────────────────────────────────────
|
|
245
|
+
// Scan order: EGRESS → ENCODING → SECRET → PII
|
|
246
|
+
// Highest-severity patterns first so the label reflects the worst finding.
|
|
247
|
+
export const PII_PATTERNS = [
|
|
248
|
+
...EGRESS_PATTERNS,
|
|
249
|
+
...ENCODING_PATTERNS,
|
|
250
|
+
...SECRET_PATTERNS,
|
|
251
|
+
...PII_PATTERNS_LOW,
|
|
252
|
+
];
|
|
253
|
+
//# sourceMappingURL=PIIPattern.js.map
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AAG,gBAAgB;CACpB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain / PII
|
|
3
|
+
* Barrel export for Layer 1 Deterministic Filter
|
|
4
|
+
*/
|
|
5
|
+
export { DeterministicFilter } from "./DeterministicFilter";
|
|
6
|
+
export type { SuspiciousTrace, PIIFinding, FilterOutcome, SuspiciousLabel } from "./DeterministicFilter";
|
|
7
|
+
export { PII_PATTERNS, CATEGORY_TO_LABEL, LABEL_PRIORITY } from "./PIIPattern";
|
|
8
|
+
export type { PIIPattern, PIICategory } from "./PIIPattern";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/pii/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEzG,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/E,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/pii/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
import { type WrapOptions, type ServiceStatus, type ScanResult } from "./application";
|
|
20
|
+
import { type SuspiciousTrace } from "./domain/pii/DeterministicFilter";
|
|
20
21
|
import { ShieldBlockError } from "./application/ShieldBlockError";
|
|
21
22
|
import { type LLMResponse } from "./application/ports/ILLMProvider";
|
|
22
23
|
/**
|
|
@@ -134,6 +135,39 @@ export declare class Tracerney {
|
|
|
134
135
|
* ```
|
|
135
136
|
*/
|
|
136
137
|
scanPrompt(prompt: string): Promise<ScanResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Layer 1: Scan any string (agent output, tool result, raw text) for suspicious content.
|
|
140
|
+
*
|
|
141
|
+
* The SDK is a high-precision sensor — it never decides for you.
|
|
142
|
+
* Every match is returned as a SuspiciousTrace with a label and pre-computed redactedContent.
|
|
143
|
+
* You choose the reaction.
|
|
144
|
+
*
|
|
145
|
+
* **The Suspicious Manifest:**
|
|
146
|
+
* | Label | Trigger | Recommended Action |
|
|
147
|
+
* |------------------------|----------------------|--------------------|
|
|
148
|
+
* | `SUSPICIOUS_PII` | Email / Phone | Usually Redact |
|
|
149
|
+
* | `SUSPICIOUS_SECRET` | API keys / SSH | Usually Block |
|
|
150
|
+
* | `SUSPICIOUS_EGRESS` | External URL smuggle | Always Block |
|
|
151
|
+
* | `SUSPICIOUS_ENCODING` | Zero-width / BiDi | Audit / Block |
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const trace = tracerney.validate(agentOutput);
|
|
156
|
+
*
|
|
157
|
+
* if (trace.isSuspicious) {
|
|
158
|
+
* console.log(`Alert [${trace.label}]: ${trace.reason}`);
|
|
159
|
+
*
|
|
160
|
+
* // Option A: Hard block
|
|
161
|
+
* if (trace.label === 'SUSPICIOUS_EGRESS') {
|
|
162
|
+
* throw new Error('Security Policy Violation');
|
|
163
|
+
* }
|
|
164
|
+
*
|
|
165
|
+
* // Option B: Surgical scrub
|
|
166
|
+
* return trace.redactedContent;
|
|
167
|
+
* }
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
validate(text: string): SuspiciousTrace;
|
|
137
171
|
/**
|
|
138
172
|
* Update allowed tools at runtime
|
|
139
173
|
*
|
|
@@ -161,6 +195,10 @@ export type { RemotePatternRepositoryConfig } from "./infrastructure/patterns";
|
|
|
161
195
|
export { normalizePrompt, normalizePrompts, jitter } from "./application/utils";
|
|
162
196
|
export { HttpSignalSink } from "./infrastructure/telemetry";
|
|
163
197
|
export type { HttpSignalSinkConfig } from "./infrastructure/telemetry";
|
|
198
|
+
export { DeterministicFilter } from "./domain/pii/DeterministicFilter";
|
|
199
|
+
export type { SuspiciousTrace, FilterOutcome, PIIFinding, SuspiciousLabel } from "./domain/pii/DeterministicFilter";
|
|
200
|
+
export { PII_PATTERNS } from "./domain/pii/PIIPattern";
|
|
201
|
+
export type { PIIPattern, PIICategory } from "./domain/pii/PIIPattern";
|
|
164
202
|
export { LLMSentinel } from "./infrastructure/sentinel/LLMSentinel";
|
|
165
203
|
export type { LLMSentinelOptions } from "./infrastructure/sentinel/LLMSentinel";
|
|
166
204
|
export { HttpShadowLogSink } from "./infrastructure/telemetry/HttpShadowLogSink";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAA4B,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAMpE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,MAAM,CAAC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
|
|
134
134
|
return this.service.scanPrompt(prompt);
|
|
135
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Layer 1: Scan any string (agent output, tool result, raw text) for suspicious content.
|
|
138
|
+
*
|
|
139
|
+
* The SDK is a high-precision sensor — it never decides for you.
|
|
140
|
+
* Every match is returned as a SuspiciousTrace with a label and pre-computed redactedContent.
|
|
141
|
+
* You choose the reaction.
|
|
142
|
+
*
|
|
143
|
+
* **The Suspicious Manifest:**
|
|
144
|
+
* | Label | Trigger | Recommended Action |
|
|
145
|
+
* |------------------------|----------------------|--------------------|
|
|
146
|
+
* | `SUSPICIOUS_PII` | Email / Phone | Usually Redact |
|
|
147
|
+
* | `SUSPICIOUS_SECRET` | API keys / SSH | Usually Block |
|
|
148
|
+
* | `SUSPICIOUS_EGRESS` | External URL smuggle | Always Block |
|
|
149
|
+
* | `SUSPICIOUS_ENCODING` | Zero-width / BiDi | Audit / Block |
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const trace = tracerney.validate(agentOutput);
|
|
154
|
+
*
|
|
155
|
+
* if (trace.isSuspicious) {
|
|
156
|
+
* console.log(`Alert [${trace.label}]: ${trace.reason}`);
|
|
157
|
+
*
|
|
158
|
+
* // Option A: Hard block
|
|
159
|
+
* if (trace.label === 'SUSPICIOUS_EGRESS') {
|
|
160
|
+
* throw new Error('Security Policy Violation');
|
|
161
|
+
* }
|
|
162
|
+
*
|
|
163
|
+
* // Option B: Surgical scrub
|
|
164
|
+
* return trace.redactedContent;
|
|
165
|
+
* }
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
validate(text) {
|
|
169
|
+
return this.service.validate(text);
|
|
170
|
+
}
|
|
136
171
|
/**
|
|
137
172
|
* Update allowed tools at runtime
|
|
138
173
|
*
|
|
@@ -165,6 +200,9 @@ export { BundledPatternRepository, RemotePatternRepository } from './infrastruct
|
|
|
165
200
|
// Utility exports (for middleware & advanced use)
|
|
166
201
|
export { normalizePrompt, normalizePrompts, jitter } from './application/utils/index.js';
|
|
167
202
|
export { HttpSignalSink } from './infrastructure/telemetry/index.js';
|
|
203
|
+
// Layer 1 Deterministic Filter exports
|
|
204
|
+
export { DeterministicFilter } from './domain/pii/DeterministicFilter.js';
|
|
205
|
+
export { PII_PATTERNS } from './domain/pii/PIIPattern.js';
|
|
168
206
|
// Layer 2 Sentinel exports
|
|
169
207
|
export { LLMSentinel } from './infrastructure/sentinel/LLMSentinel.js';
|
|
170
208
|
export { HttpShadowLogSink } from './infrastructure/telemetry/HttpShadowLogSink.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,wBAAwB,EAAyD,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,wBAAwB,EAAyD,MAAM,eAAe,CAAC;AAEhH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,gGAAgG;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAwEpE;;;;GAIG;AACH,MAAM,OAAO,SAAS;IAGpB;;OAEG;IACH,YAAY,UAA4B,EAAE;QACxC,qDAAqD;QACrD,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAEvD,mCAAmC;QACnC,sDAAsD;QACtD,4DAA4D;QAC5D,MAAM,WAAW,GAAG,IAAI,wBAA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BAA4B,CAAC;AAG5D,uCAAuC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,2BAA2B;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAGpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AAGjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sandrobuilds/tracerney",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.23",
|
|
4
4
|
"description": "Lightweight prompt injection detection with Layer 1 (258 patterns) + Layer 2 (AI verification). Runs locally with zero data storage. Upgrade to Pro for context-aware threat analysis at tracerney.com",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|