mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 00:50:22 +08:00
fix: seal object JSON schemas so redteam preset loads on DSH 0.2.1.
This commit is contained in:
1 parent
ca848d767e
commit
6cb2ac32ba
1 file changed
+35
-6
+35
-6
@@ -99,7 +99,36 @@ function loadDefineTool() {
|
||||
throw new Error('dsh-purge/redteam/tools: cannot resolve @deepseek-ai/dsh-tools from host')
|
||||
}
|
||||
|
||||
const defineTool = loadDefineTool()
|
||||
const defineToolRaw = loadDefineTool()
|
||||
|
||||
/** 0.2.1:任何 type=object 都必须显式 additionalProperties,否则整份红队预设加载失败。 */
|
||||
function sealObjectSchemas(node) {
|
||||
if (!node || typeof node !== 'object') return node
|
||||
if (Array.isArray(node)) {
|
||||
for (const item of node) sealObjectSchemas(item)
|
||||
return node
|
||||
}
|
||||
if (node.type === 'object' && node.additionalProperties === undefined) {
|
||||
node.additionalProperties = node.properties ? false : true
|
||||
}
|
||||
if (node.properties) {
|
||||
for (const key of Object.keys(node.properties)) sealObjectSchemas(node.properties[key])
|
||||
}
|
||||
if (node.items) sealObjectSchemas(node.items)
|
||||
if (node.additionalProperties && typeof node.additionalProperties === 'object') {
|
||||
sealObjectSchemas(node.additionalProperties)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
function defineTool(spec) {
|
||||
if (spec && spec.parameters) sealObjectSchemas(spec.parameters)
|
||||
const tool = defineToolRaw(spec)
|
||||
if (tool && tool.parameters) sealObjectSchemas(tool.parameters)
|
||||
if (tool && tool.inputSchema) sealObjectSchemas(tool.inputSchema)
|
||||
if (tool && tool.schema) sealObjectSchemas(tool.schema)
|
||||
return tool
|
||||
}
|
||||
|
||||
/** Cordis 插件名。 */
|
||||
export const name = 'dsh-purge-redteam-tools'
|
||||
@@ -2057,8 +2086,8 @@ export function apply(ctx) {
|
||||
parameters: {
|
||||
engagement: { type: 'string' },
|
||||
operation: { type: 'string', required: true, description: '操作名,如 "nmap_scan"、"webshell_established"、"sql_injection_confirmed"' },
|
||||
parameters: { type: 'object', description: '调用参数(JSON 对象,会参与哈希)' },
|
||||
result: { type: 'object', required: true, description: '规范化结果(JSON 对象,会参与哈希)' },
|
||||
parameters: { type: 'object', additionalProperties: true, description: '调用参数(JSON 对象,会参与哈希)' },
|
||||
result: { type: 'object', additionalProperties: true, required: true, description: '规范化结果(JSON 对象,会参与哈希)' },
|
||||
confidence: { type: 'string', description: 'claimed | observed | derived | inferred,默认 observed' },
|
||||
authority: { type: 'string', description: 'tool-output | database-record | screenshot | request-replay | subagent-report | operator-input,默认 tool-output' },
|
||||
limitations: { type: 'array', items: { type: 'string' }, description: '局限性说明,如 ["只扫了 Top1000 端口"]' },
|
||||
@@ -2090,8 +2119,8 @@ export function apply(ctx) {
|
||||
parameters: {
|
||||
engagement: { type: 'string' },
|
||||
operation: { type: 'string', required: true },
|
||||
parameters: { type: 'object' },
|
||||
result: { type: 'object', required: true },
|
||||
parameters: { type: 'object', additionalProperties: true },
|
||||
result: { type: 'object', additionalProperties: true, required: true },
|
||||
confidence: { type: 'string' },
|
||||
authority: { type: 'string' },
|
||||
limitations: { type: 'array', items: { type: 'string' } },
|
||||
@@ -2119,7 +2148,7 @@ export function apply(ctx) {
|
||||
parameters: {
|
||||
engagement: { type: 'string' },
|
||||
claimed_ev_id: { type: 'string', required: true, description: '要升级的证据 ID' },
|
||||
verified_result: { type: 'object', description: '亲自验证后的实际结果' },
|
||||
verified_result: { type: 'object', additionalProperties: true, description: '亲自验证后的实际结果' },
|
||||
verified_by: { type: 'string', description: '谁核实的,默认 coordinator' },
|
||||
},
|
||||
output: { schema: { type: 'string' }, render: (_args, value) => text(value) },
|
||||
|
||||
Reference in new issue
Block a user