MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / validateTeamMemKey

Function validateTeamMemKey

source code/memdir/teamMemPaths.ts:267–286  ·  view source on GitHub ↗
(relativeKey: string)

Source from the content-addressed store, hash-verified

265 * Throws PathTraversalError if the key is malicious (PSR M22186).
266 */
267export async function validateTeamMemKey(relativeKey: string): Promise<string> {
268 sanitizePathKey(relativeKey)
269 const teamDir = getTeamMemPath()
270 const fullPath = join(teamDir, relativeKey)
271 // First pass: normalize .. segments and check string-level containment.
272 const resolvedPath = resolve(fullPath)
273 if (!resolvedPath.startsWith(teamDir)) {
274 throw new PathTraversalError(
275 `Key escapes team memory directory: "${relativeKey}"`,
276 )
277 }
278 // Second pass: resolve symlinks and verify real containment.
279 const realPath = await realpathDeepestExisting(resolvedPath)
280 if (!(await isRealPathWithinTeamDir(realPath))) {
281 throw new PathTraversalError(
282 `Key escapes team memory directory via symlink: "${relativeKey}"`,
283 )
284 }
285 return resolvedPath
286}
287
288/**
289 * Check if a file path is within the team memory directory

Callers 1

Calls 5

sanitizePathKeyFunction · 0.85
getTeamMemPathFunction · 0.85
realpathDeepestExistingFunction · 0.85
isRealPathWithinTeamDirFunction · 0.85
resolveFunction · 0.50

Tested by

no test coverage detected