fix(config): protect operator credentials
Keep first-run access details confined to the active process console and remove development credentials from managed application logs. Treat notification delivery settings as sensitive during backup and restore, preserve private file access across creation and updates, and align the WebUI guidance with the new boundary.
This commit is contained in:
9 files changed
+123
-43
No files matched your search
@@ -160,7 +160,11 @@ describe('loadNotificationsConfig / saveNotificationsConfig (fs-backed)', () =>
|
||||
const mod = await import('../src/notifications/config');
|
||||
const cfg = mod.loadNotificationsConfig();
|
||||
expect(cfg).toEqual(mod.defaultNotificationsConfig());
|
||||
expect(fs.existsSync(path.join('config', 'notifications.json'))).toBe(true);
|
||||
const file = path.join('config', 'notifications.json');
|
||||
expect(fs.existsSync(file)).toBe(true);
|
||||
if (process.platform !== 'win32') {
|
||||
expect(fs.statSync(file).mode & 0o777).toBe(0o600);
|
||||
}
|
||||
});
|
||||
|
||||
it('round-trips a saved config across a fresh module load', async () => {
|
||||
@@ -177,6 +181,42 @@ describe('loadNotificationsConfig / saveNotificationsConfig (fs-backed)', () =>
|
||||
expect(mod2.loadNotificationsConfig()).toEqual(saved);
|
||||
});
|
||||
|
||||
it('repairs permissive permissions on an existing sensitive config', async () => {
|
||||
const file = path.join('config', 'notifications.json');
|
||||
fs.mkdirSync('config', { recursive: true });
|
||||
fs.writeFileSync(file, JSON.stringify({
|
||||
version: 1,
|
||||
debounceSeconds: 30,
|
||||
channels: [{ id: 'ops', url: 'https://example.com/private-hook' }],
|
||||
}), { encoding: 'utf8', mode: 0o644 });
|
||||
if (process.platform !== 'win32') fs.chmodSync(file, 0o644);
|
||||
|
||||
const mod = await import('../src/notifications/config');
|
||||
expect(mod.loadNotificationsConfig().channels).toHaveLength(1);
|
||||
if (process.platform !== 'win32') {
|
||||
expect(fs.statSync(file).mode & 0o777).toBe(0o600);
|
||||
}
|
||||
});
|
||||
|
||||
it('keeps restrictive permissions after replacing an existing config', async () => {
|
||||
const file = path.join('config', 'notifications.json');
|
||||
fs.mkdirSync('config', { recursive: true });
|
||||
fs.writeFileSync(file, JSON.stringify({ version: 1, debounceSeconds: 30, channels: [] }), {
|
||||
encoding: 'utf8',
|
||||
mode: 0o644,
|
||||
});
|
||||
if (process.platform !== 'win32') fs.chmodSync(file, 0o644);
|
||||
|
||||
const mod = await import('../src/notifications/config');
|
||||
mod.saveNotificationsConfig({
|
||||
channels: [{ id: 'ops', url: 'https://example.com/private-hook' }],
|
||||
});
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
expect(fs.statSync(file).mode & 0o777).toBe(0o600);
|
||||
}
|
||||
});
|
||||
|
||||
it('section-merges partial saves (debounce-only keeps channels)', async () => {
|
||||
const mod = await import('../src/notifications/config');
|
||||
mod.saveNotificationsConfig({ channels: [{ id: 'c1', url: 'https://a.com' }] });
|
||||
|
||||
Reference in new issue
Block a user