fix(sandbox): restore SHA-1 in slugifySessionKey to preserve workspace dirs (#18503)

This commit is contained in:
yinghaosang
2026-02-17 04:05:20 +08:00
committed by Peter Steinberger
parent d799a3994f
commit f275611862
2 changed files with 32 additions and 2 deletions

View File

@@ -1,12 +1,14 @@
import crypto from "node:crypto";
import path from "node:path";
import { normalizeAgentId } from "../../routing/session-key.js";
import { resolveUserPath } from "../../utils.js";
import { resolveAgentIdFromSessionKey } from "../agent-scope.js";
import { hashTextSha256 } from "./hash.js";
export function slugifySessionKey(value: string) {
const trimmed = value.trim() || "session";
const hash = hashTextSha256(trimmed).slice(0, 8);
// SHA-1 is intentional: this is a non-security slug differentiator and changing
// the algorithm orphans existing workspace directories on upgrade (#18503).
const hash = crypto.createHash("sha1").update(trimmed).digest("hex").slice(0, 8);
const safe = trimmed
.toLowerCase()
.replace(/[^a-z0-9._-]+/g, "-")