Allow @-includes outside of workspaces (with permission) (#18470)

This commit is contained in:
Tommaso Sciortino
2026-02-09 12:24:28 -08:00
committed by GitHub
parent e73288f25f
commit 262e8384d4
17 changed files with 250 additions and 64 deletions
+14 -1
View File
@@ -1880,9 +1880,22 @@ export class Config {
* Validates if a path is allowed and returns a detailed error message if not.
*
* @param absolutePath The absolute path to validate.
* @param checkType The type of access to check ('read' or 'write'). Defaults to 'write' for safety.
* @returns An error message string if the path is disallowed, null otherwise.
*/
validatePathAccess(absolutePath: string): string | null {
validatePathAccess(
absolutePath: string,
checkType: 'read' | 'write' = 'write',
): string | null {
// For read operations, check read-only paths first
if (checkType === 'read') {
if (this.getWorkspaceContext().isPathReadable(absolutePath)) {
return null;
}
}
// Then check standard allowed paths (Workspace + Temp)
// This covers 'write' checks and acts as a fallback/temp-dir check for 'read'
if (this.isPathAllowed(absolutePath)) {
return null;
}