( pattern: string, source: SettingSource, )
| 97 | * @param source The settings source this pattern came from (needed to resolve `/path` patterns) |
| 98 | */ |
| 99 | export function resolvePathPatternForSandbox( |
| 100 | pattern: string, |
| 101 | source: SettingSource, |
| 102 | ): string { |
| 103 | // Handle // prefix - absolute from root (CC-specific convention) |
| 104 | if (pattern.startsWith('//')) { |
| 105 | return pattern.slice(1) // "//.aws/**" → "/.aws/**" |
| 106 | } |
| 107 | |
| 108 | // Handle / prefix - relative to settings file directory (CC-specific convention) |
| 109 | // Note: ~/path and relative paths are passed through for sandbox-runtime to handle |
| 110 | if (pattern.startsWith('/') && !pattern.startsWith('//')) { |
| 111 | const root = getSettingsRootPathForSource(source) |
| 112 | // Pattern like "/foo/**" becomes "${root}/foo/**" |
| 113 | return resolve(root, pattern.slice(1)) |
| 114 | } |
| 115 | |
| 116 | // Other patterns (~/path, ./path, path) pass through as-is |
| 117 | // sandbox-runtime's normalizePathForSandbox will handle them |
| 118 | return pattern |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Resolve paths from sandbox.filesystem.* settings (allowWrite, denyWrite, etc). |
no test coverage detected