Skip to content

Commit b906cf2

Browse files
docs(auth): document credential permission tightening
1 parent 06b450e commit b906cf2

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/lib/credentials.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ export function deleteProfile(profile: string, options: CredentialsOptions = {})
184184
return true;
185185
}
186186

187+
/**
188+
* Enforce restrictive access on the credentials file after atomic writes.
189+
* POSIX hosts use chmod(0600); Windows hosts use ACL tightening via icacls.
190+
*/
187191
export function ensureRestrictiveMode(path: string, options: RestrictiveModeOptions = {}): void {
188192
if (!existsSync(path)) return;
189193
if ((options.platform ?? process.platform) === 'win32') {
@@ -194,6 +198,10 @@ export function ensureRestrictiveMode(path: string, options: RestrictiveModeOpti
194198
if (overpermissive) chmodSync(path, 0o600);
195199
}
196200

201+
/**
202+
* Restrict a Windows credentials file to the current user using icacls.
203+
* The command is invoked with an args array so credential paths are never shell-interpreted.
204+
*/
197205
function ensureWindowsRestrictiveAcl(path: string, options: RestrictiveModeOptions): void {
198206
const username = (options.env ?? process.env).USERNAME?.trim();
199207
if (!username) {
@@ -226,6 +234,7 @@ function ensureWindowsRestrictiveAcl(path: string, options: RestrictiveModeOptio
226234
}
227235
}
228236

237+
/** Emit an explicit warning when Windows ACL tightening cannot be completed. */
229238
function warnWindowsAcl(message: string, options: RestrictiveModeOptions): void {
230239
const warn = options.warn ?? ((line: string) => process.stderr.write(`${line}\n`));
231240
warn(`[warning] ${message}`);

0 commit comments

Comments
 (0)