MCPcopy
hub / github.com/AutoMaker-Org/automaker / validatePath

Function validatePath

libs/platform/src/security.ts:81–89  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

79 * Throws PathNotAllowedError if path is not allowed
80 */
81export function validatePath(filePath: string): string {
82 const resolvedPath = path.resolve(filePath);
83
84 if (!isPathAllowed(resolvedPath)) {
85 throw new PathNotAllowedError(filePath);
86 }
87
88 return resolvedPath;
89}
90
91/**
92 * Check if a path is within a directory, with protection against path traversal

Callers 15

validatePathParamsFunction · 0.90
security.test.tsFile · 0.85
accessFunction · 0.85
readFileFunction · 0.85
writeFileFunction · 0.85
mkdirFunction · 0.85
readdirFunction · 0.85
statFunction · 0.85
rmFunction · 0.85
unlinkFunction · 0.85
copyFileFunction · 0.85
appendFileFunction · 0.85

Calls 2

isPathAllowedFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected