( cwd: string, key: string, )
| 339 | if (!env || typeof env !== "object" || Array.isArray(env)) continue; |
| 340 | for (const [key, value] of Object.entries(env as Record<string, unknown>)) { |
| 341 | if (value === undefined || value === null) continue; |
| 342 | if ((src.source === "project" || src.source === "local") && isInheritedCredentialProtected(key)) { |
| 343 | continue; |
| 344 | } |
| 345 | out[key] = typeof value === "string" ? value : String(value); |
| 346 | } |
| 347 | } |
| 348 | return out; |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * Concatenate + de-duplicate a string-array setting across TRUSTED sources. |
| 353 | * Used by `additionalDirectories`, which widens the filesystem access boundary |
| 354 | * — so an untrusted repo must not be able to grant itself extra directories. |
| 355 | */ |
| 356 | export async function readTrustedStringArraySetting(cwd: string, key: string): Promise<string[]> { |
| 357 | const sources = await loadTrustedSettingSources(cwd); |
| 358 | const seen = new Set<string>(); |
| 359 | const out: string[] = []; |
| 360 | for (const src of sources) { |
| 361 | const arr = src.raw?.[key]; |
| 362 | if (!Array.isArray(arr)) continue; |
| 363 | for (const item of arr) { |
no test coverage detected