MCPcopy Create free account
hub / github.com/vercel/vercel / getUnsafePackageFileReason

Function getUnsafePackageFileReason

packages/cli-exec/src/safety.ts:132–156  ·  view source on GitHub ↗
(
  packageDirectory: string,
  filePath: string
)

Source from the content-addressed store, hash-verified

130 * Validates that package file ancestors and the file itself are safe.
131 */
132export async function getUnsafePackageFileReason(
133 packageDirectory: string,
134 filePath: string
135): Promise<string | null> {
136 const directoriesToCheck = getDirectoriesBetween(
137 packageDirectory,
138 path.dirname(filePath)
139 );
140
141 if (directoriesToCheck.length === 0) {
142 return `${filePath} resolves outside package`;
143 }
144
145 for (const directory of directoriesToCheck) {
146 const reason = await getUnsafeDirectoryReason(directory);
147
148 if (reason) {
149 return `${directory} is ${reason}`;
150 }
151 }
152
153 const reason = await getUnsafeFileReason(filePath);
154
155 return reason ? `${filePath} is ${reason}` : null;
156}
157
158/**
159 * Reports unsafe ownership or write permissions for a directory path.

Callers 2

Calls 3

getDirectoriesBetweenFunction · 0.90
getUnsafeDirectoryReasonFunction · 0.85
getUnsafeFileReasonFunction · 0.85

Tested by

no test coverage detected