Fix security scan findings: confirm gate, exit codes, redaction, CI tag env (#180)
- Gate rules push behind --yes at CLI and domain layers (fail-closed on
dryRun=false without confirm)
- Raise webhook replay partial failure as CliError so exit 1 survives
cli.ts exitCode overwrite; route webhook stdout through printJson for
exit-12 protection and --output-file support
- Narrow MCP read-only allowlist: drop config mode/lint (write forms are
indistinguishable under token-prefix matching; config get covers reads)
- Extract redactSensitiveText to core, extend credential patterns, apply
to HTTP sendError/500 and domain error messages
- Pass release TAG_NAME via env instead of inline ${{ }} interpolation
to close script injection through crafted tag names
- Track .zcodeignore so enterprise credential exclusions travel with the
repo
- Add .agents/rules/security-posture.md documenting usability-first
accepted risks (loopback adapter auth, update verification, mutation
command gates, skill dump stdout); register skill dump as a documented
stdout Markdown exception in AGENTS.md and cli-protocol.md
- Rebuild dist/mcp/server.js
This commit is contained in:
1 parent
3d9df01c31
commit
f8e083f3b2
15 files changed
+283
-151
No files matched your search
@@ -28,7 +28,7 @@ import {
|
||||
webhookRateOption,
|
||||
webhookShowSecretOption
|
||||
} from "../parser.js";
|
||||
import { outputOptions } from "../printer.js";
|
||||
import { outputOptions, printJson } from "../printer.js";
|
||||
import type { ParsedArgs } from "../types.js";
|
||||
import type { MaterialPackFilePolicyPatch } from "../../domains/seal/material-pack/policy.js";
|
||||
import { CliError, confirmationRequired, usageError } from "../errors.js";
|
||||
@@ -39,7 +39,7 @@ export async function handleWebhookResourcePackPreview(
|
||||
) {
|
||||
if (!existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
|
||||
const input = readMaterialPackFile(filePath);
|
||||
console.log(JSON.stringify(await previewMaterialPack(input.fileBuffer, input.fileName, filePolicy), null, 2));
|
||||
printJson(await previewMaterialPack(input.fileBuffer, input.fileName, filePolicy));
|
||||
}
|
||||
|
||||
export const handleWebhookMaterialPackPreview = handleWebhookResourcePackPreview;
|
||||
@@ -83,7 +83,7 @@ export async function handleWebhookCommand(
|
||||
console.error(`🔴 准备阶段未通过: ${result.statusMessage}`);
|
||||
console.error(`👉 Next action: ${result.nextAction}`);
|
||||
}
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
printJson(result, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ export async function handleWebhookCommand(
|
||||
console.error(
|
||||
`[webhook-replay] 预览模式:已成功从 ${sourceCorp.name} 提取单据并转换为 Webhook Payload(未实际推送)。`
|
||||
);
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
printJson(result, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -197,9 +197,15 @@ export async function handleWebhookCommand(
|
||||
);
|
||||
}
|
||||
console.error(`👉 Next action: seal-use approval-runs list --corp ${targetCorp.id} --limit ${result.totalCount}`);
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
printJson(result, outputOptions(args.options));
|
||||
if (!result.success) {
|
||||
process.exitCode = 1;
|
||||
// The partial-failure signal must survive cli.ts overwriting process.exitCode with the
|
||||
// dispatch result, so it is raised as a CliError instead of set on the process.
|
||||
throw new CliError(
|
||||
`Webhook replay finished with failures (success ${result.successCount}, failed ${result.failureCount}).`,
|
||||
1,
|
||||
`seal-use approval-runs list --corp ${targetCorp.id} --limit ${result.totalCount}`
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -263,7 +269,7 @@ export async function handleWebhookCommand(
|
||||
`🟢 成功导出 Webhook 资源包: ${result.filePath} (共 ${result.recordCount} 条单据,${result.attachmentCount} 个附件,${(result.fileSizeBytes / 1024).toFixed(1)} KB)`
|
||||
);
|
||||
console.error(`👉 Next action: ${result.nextAction}`);
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
printJson(result, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -275,7 +281,7 @@ export async function handleWebhookCommand(
|
||||
if (!existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
|
||||
const input = readMaterialPackFile(filePath);
|
||||
if (operation === "preview") {
|
||||
console.log(JSON.stringify(await previewMaterialPack(input.fileBuffer, input.fileName), null, 2));
|
||||
printJson(await previewMaterialPack(input.fileBuffer, input.fileName), outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
if (operation !== "push") throw new Error("Usage: seal-use webhook resource-pack <export|preview|push> [options]");
|
||||
@@ -305,7 +311,7 @@ export async function handleWebhookCommand(
|
||||
});
|
||||
console.error(`🟢 Webhook 资源包推送完成 (成功 ${result.results.length} 条单据)`);
|
||||
console.error(`👉 Next action: seal-use approval-runs list --corp ${corp.id} --limit ${result.results.length}`);
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
printJson(result, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
if (action === "list") {
|
||||
|
||||
Reference in new issue
Block a user