fix(workflow): prevent prototype traversal and inherited CLI authorization
This commit is contained in:
1 parent
fac81b08e8
commit
d2e0d564ca
6 files changed
+62
-31
No files matched your search
@@ -128,3 +128,5 @@ hose-use workflow eval-script --code="return a + b;" --input='{"a":1,"b":2}'
|
||||
- 借助 Kimi 网桥(`kimi-webbridge`)建立真实微前端会话,自动探测并解析不同应用类型下的非费用类表单元数据;
|
||||
- 提取出动态列、关联实体 ID 与系统字段字典,在 CLI 层面提供对非费用类业务对象的只读探针与结构化校验能力。
|
||||
|
||||
|
||||
草稿补丁路径仅遍历对象自身属性,禁止 `__proto__`、`constructor`、`prototype` 路径段;非法路径在写入前拒绝。CLI 选项仅识别自身属性,继承的确认标记无效。
|
||||
@@ -21,6 +21,9 @@ function pathParts(path: string): string[] {
|
||||
.map((part) => part.trim())
|
||||
.filter(Boolean);
|
||||
if (!parts.length) throw new ValidationError("工作流配置路径不能为空");
|
||||
if (parts.some(part => ["__proto__", "constructor", "prototype"].includes(part))) {
|
||||
throw new ValidationError("工作流配置路径禁止访问对象原型");
|
||||
}
|
||||
if (parts.some((part) => !/^[A-Za-z_$][\w$-]*$/.test(part) && !/^\d+$/.test(part))) {
|
||||
throw new ValidationError(`工作流配置路径非法: ${path}`);
|
||||
}
|
||||
@@ -40,7 +43,7 @@ export function applyWorkflowPathPatch(
|
||||
const patched = structuredClone(workflow) as Record<string, any>;
|
||||
let cursor: any = patched;
|
||||
for (const part of parts.slice(0, -1)) {
|
||||
if (cursor === null || typeof cursor !== "object" || !(part in cursor)) {
|
||||
if (cursor === null || typeof cursor !== "object" || !Object.hasOwn(cursor, part)) {
|
||||
throw new NotFoundError(`工作流配置路径不存在: ${path}`);
|
||||
}
|
||||
cursor = cursor[part];
|
||||
|
||||
Reference in new issue
Block a user