(input: {
readonly pluginRoot: string;
readonly field: string;
readonly value: string;
readonly diagnostics: PluginDiagnostic[];
})
| 200 | } |
| 201 | |
| 202 | async function resolvePluginPathField(input: { |
| 203 | readonly pluginRoot: string; |
| 204 | readonly field: string; |
| 205 | readonly value: string; |
| 206 | readonly diagnostics: PluginDiagnostic[]; |
| 207 | }): Promise<string | undefined> { |
| 208 | if (!input.value.startsWith('./')) { |
| 209 | input.diagnostics.push({ |
| 210 | severity: 'warn', |
| 211 | message: `"${input.field}" path must start with "./" (got "${input.value}")`, |
| 212 | }); |
| 213 | return undefined; |
| 214 | } |
| 215 | const absolute = path.resolve(input.pluginRoot, input.value); |
| 216 | let real: string; |
| 217 | try { |
| 218 | real = await realpath(absolute); |
| 219 | } catch { |
| 220 | real = absolute; |
| 221 | } |
| 222 | const rootReal = await realpath(input.pluginRoot).catch(() => input.pluginRoot); |
| 223 | if (!isWithin(real, rootReal)) { |
| 224 | input.diagnostics.push({ |
| 225 | severity: 'warn', |
| 226 | message: `"${input.field}" path resolves outside the plugin (${input.value})`, |
| 227 | }); |
| 228 | return undefined; |
| 229 | } |
| 230 | return real; |
| 231 | } |
| 232 | |
| 233 | function readSessionStart( |
| 234 | raw: unknown, |
no test coverage detected