Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions packages/cli/src/commands/review/lib/run-ledger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,23 +686,27 @@ describe('the properties the threat model rests on', () => {
expect(priorSessionIds(plan, envOf('S2'))).toEqual([]);
});

it('refuses to append over a ledger it could not read', () => {
// A present-but-unreadable REGULAR file holds every recorded entry, and
// this append rewrites the whole file from what it read — proceeding on
// a transient fault would clobber attempt 1's address exactly when a
// resume needs it.
appendRunSession(plan, envOf('S1'));
const before = readFileSync(runSessionsPath(plan), 'utf8');
chmodSync(runSessionsPath(plan), 0o000);
try {
appendRunSession(plan, envOf('S2'));
} finally {
chmodSync(runSessionsPath(plan), 0o644);
}
expect(readFileSync(runSessionsPath(plan), 'utf8')).toBe(before);
authorize('S3');
expect(priorSessionIds(plan, envOf('S3'))).toEqual(['S1']);
});
it.skipIf(process.getuid?.() === 0)(
'refuses to append over a ledger it could not read',
() => {
// A present-but-unreadable REGULAR file holds every recorded entry, and
// this append rewrites the whole file from what it read — proceeding on
// a transient fault would clobber attempt 1's address exactly when a
// resume needs it. Skipped under root: root bypasses permission bits,
// so chmod 000 stays readable and the premise is untestable.
appendRunSession(plan, envOf('S1'));
const before = readFileSync(runSessionsPath(plan), 'utf8');
chmodSync(runSessionsPath(plan), 0o000);
try {
appendRunSession(plan, envOf('S2'));
} finally {
chmodSync(runSessionsPath(plan), 0o644);
}
expect(readFileSync(runSessionsPath(plan), 'utf8')).toBe(before);
authorize('S3');
expect(priorSessionIds(plan, envOf('S3'))).toEqual(['S1']);
},
);

it('does not write at all when the id fails the charset gate', () => {
// The write-side guard, discriminated from the read-side one by looking
Expand Down
Loading