Avoid creating metadata paths in the Windows sandbox (#33430)

## Why

Elevated Windows sandbox setup could turn the built-in read-only protections
for workspace metadata into deny-write paths, creating metadata directories
that did not already exist.

## What changed

- Track whether filesystem permission entries come from a built-in profile or
  were explicitly configured.
- Exclude generated metadata defaults from direct Windows deny-write overrides
  while continuing to enforce explicit read-only carveouts for the same paths.
- Preserve the distinction while materializing and normalizing permission
  paths, without exposing generated defaults as user configuration.

## Testing

Added Windows coverage confirming that elevated sandbox setup leaves missing
workspace metadata absent and still produces overrides for explicit metadata
carveouts.

GitOrigin-RevId: 701bcb229f631b18ab5ced22f3edf6f303d932f3
This commit is contained in:
iceweasel-oai authored and copyberry committed 2026-07-15 21:19:14 +00:00
1 parent 79177c3e20
commit cb79b3cdf9
11 files changed
+340 -60

No files matched your search

+21 -1
View File
@@ -126,8 +126,10 @@ pub struct WalkOutcome {
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ExecFileSystemPath {
Path { path: PathUri },
GeneratedDefaultPath { path: PathUri },
GlobPattern { pattern: String },
Special { value: FileSystemSpecialPath },
GeneratedDefaultSpecial { value: FileSystemSpecialPath },
}
impl From<FileSystemPath> for ExecFileSystemPath {
@@ -136,8 +138,14 @@ impl From<FileSystemPath> for ExecFileSystemPath {
FileSystemPath::Path { path } => Self::Path {
path: PathUri::from_abs_path(&path),
},
FileSystemPath::GeneratedDefaultPath { path } => Self::GeneratedDefaultPath {
path: PathUri::from_abs_path(&path),
},
FileSystemPath::GlobPattern { pattern } => Self::GlobPattern { pattern },
FileSystemPath::Special { value } => Self::Special { value },
FileSystemPath::GeneratedDefaultSpecial { value } => {
Self::GeneratedDefaultSpecial { value }
}
}
}
}
@@ -150,8 +158,14 @@ impl TryFrom<ExecFileSystemPath> for FileSystemPath {
ExecFileSystemPath::Path { path } => Self::Path {
path: path.to_abs_path()?,
},
ExecFileSystemPath::GeneratedDefaultPath { path } => Self::GeneratedDefaultPath {
path: path.to_abs_path()?,
},
ExecFileSystemPath::GlobPattern { pattern } => Self::GlobPattern { pattern },
ExecFileSystemPath::Special { value } => Self::Special { value },
ExecFileSystemPath::GeneratedDefaultSpecial { value } => {
Self::GeneratedDefaultSpecial { value }
}
})
}
}
@@ -350,8 +364,14 @@ impl FileSystemSandboxContext {
ExecFileSystemPath::GlobPattern { pattern } => !Path::new(pattern).is_absolute(),
ExecFileSystemPath::Special {
value: FileSystemSpecialPath::ProjectRoots { .. },
}
| ExecFileSystemPath::GeneratedDefaultSpecial {
value: FileSystemSpecialPath::ProjectRoots { .. },
} => true,
ExecFileSystemPath::Path { .. } | ExecFileSystemPath::Special { .. } => false,
ExecFileSystemPath::Path { .. }
| ExecFileSystemPath::GeneratedDefaultPath { .. }
| ExecFileSystemPath::Special { .. }
| ExecFileSystemPath::GeneratedDefaultSpecial { .. } => false,
}),
ExecPermissionProfile::Managed {
file_system: ExecManagedFileSystemPermissions::Unrestricted,