@lmzhen/dsh-evolution-threat 0.22.0 → 0.23.0
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/lib/index.js +3 -4
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { DEFAULT_THREAT_MAX_SCAN_CHARS, EVOLUTION_WRITE_TOOLS, PATTERN_OVERLAP, asRecord, clampedNumber, scanContentThreats, scanMemoryThreats } from "@lmzhen/dsh-evolution-core";
|
|
1
2
|
import z from "@deepseek-ai/schemastery";
|
|
2
|
-
import { DEFAULT_THREAT_MAX_SCAN_CHARS, EVOLUTION_WRITE_TOOLS, PATTERN_OVERLAP, clampedNumber, scanContentThreats, scanMemoryThreats } from "@lmzhen/dsh-evolution-core";
|
|
3
3
|
//#region lib/types/index.js
|
|
4
4
|
/**
|
|
5
5
|
* Write-time threat guard for evolution tools.
|
|
@@ -11,9 +11,6 @@ const Config = z.object({
|
|
|
11
11
|
maxScanChars: z.number().min(PATTERN_OVERLAP + 1).default(DEFAULT_THREAT_MAX_SCAN_CHARS),
|
|
12
12
|
threatExemptLabels: z.array(z.string()).default([])
|
|
13
13
|
});
|
|
14
|
-
function asRecord(value) {
|
|
15
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
16
|
-
}
|
|
17
14
|
/** Scan one tool invocation for threat-shaped payload text. Exported so the
|
|
18
15
|
* guard contract is testable directly (0.3.17). `options.excludeLabels` carries
|
|
19
16
|
* the deployment's benign-label allowlist so this channel agrees with the
|
|
@@ -21,6 +18,7 @@ function asRecord(value) {
|
|
|
21
18
|
function scanToolArgs(toolName, args, maxScanChars, options = {}) {
|
|
22
19
|
if (!EVOLUTION_WRITE_TOOLS.includes(toolName)) return null;
|
|
23
20
|
const record = asRecord(args);
|
|
21
|
+
if (record === void 0) return null;
|
|
24
22
|
if (toolName === "memory") {
|
|
25
23
|
for (const text of [record.facts, record.content]) if (typeof text === "string") {
|
|
26
24
|
const hit = scanMemoryThreats(text, maxScanChars, options);
|
|
@@ -28,6 +26,7 @@ function scanToolArgs(toolName, args, maxScanChars, options = {}) {
|
|
|
28
26
|
}
|
|
29
27
|
if (Array.isArray(record.operations)) for (const op of record.operations) {
|
|
30
28
|
const inner = asRecord(op);
|
|
29
|
+
if (inner === void 0) continue;
|
|
31
30
|
for (const text of [inner.facts, inner.content]) if (typeof text === "string") {
|
|
32
31
|
const hit = scanMemoryThreats(text, maxScanChars, options);
|
|
33
32
|
if (hit) return hit;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-threat",
|
|
3
3
|
"description": "Write-time threat guard for evolution tools (community build)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.23.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@deepseek-ai/schemastery": "^3.18.4",
|
|
30
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
30
|
+
"@lmzhen/dsh-evolution-core": "^0.23.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@deepseek-ai/dsh-agent-loop-testkit": "^0.2.0-rc.1",
|
|
38
38
|
"@deepseek-ai/dsh-tools": "^0.2.0-rc.1",
|
|
39
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
39
|
+
"@lmzhen/dsh-evolution-core": "^0.23.0"
|
|
40
40
|
}
|
|
41
41
|
}
|