mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-13 08:29:04 +02:00
test: consent-gate E2E suite + functional fs-capability probes
Five hermetic gate-tier E2E cases (tpa-present / absent-linux / broken / absent-darwin / apple-ban) drive the real contract section through claude -p with PATH shims for aside and uname; the absent cases filter any REAL aside binary out of the child PATH and assert absence with Bun.which before spawning, so dev machines cannot leak into detection. Registered per-case in E2E_TOUCHFILES/E2E_TIERS with template-level deps (ship/SKILL.md.tmpl, gen-skill-docs.ts) and added to the evals.yml matrix with tier: gate. eval:bg:periodic's detach timeout rises to 36000s for the grown periodic shard census (floor-enforced by test/eval-detach-timeout-floor.test.ts); CLAUDE.md doc updated to match. test/helpers/fs-caps.ts adds canRevokeWrites/canRevokeReads functional probes; 13 chmod-based tests swap their uid-0-only guards for the probes so suites skip honestly on CAP_DAC_OVERRIDE containers (this sandbox: uid 1000 with full caps) instead of asserting revocations the kernel ignores. path-validation's symlink test targets /etc/passwd (exists everywhere; /etc/crontab is absent on Amazon Linux).
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, test, expect } from 'bun:test';
|
||||
import { canRevokeWrites } from '../../test/helpers/fs-caps';
|
||||
import { resolveConfig, ensureStateDir, readVersionHash, getGitRoot, getRemoteSlug, resolveGstackHome, resolveChromiumProfile, cleanSingletonLocks } from '../src/config';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
@@ -129,6 +130,7 @@ describe('config', () => {
|
||||
});
|
||||
|
||||
test('logs warning to browse-server.log on non-ENOENT gitignore error', () => {
|
||||
if (!canRevokeWrites()) return; // chmod is advisory here (win32, root, DAC-override containers)
|
||||
const tmpDir = path.join(os.tmpdir(), `browse-gitignore-test-${Date.now()}`);
|
||||
fs.mkdirSync(tmpDir, { recursive: true });
|
||||
// Create a read-only .gitignore (no .gstack/ entry → would try to append)
|
||||
|
||||
@@ -115,7 +115,7 @@ describe('validateOutputPath — symlink resolution', () => {
|
||||
it('blocks symlink inside /tmp pointing outside safe dirs', () => {
|
||||
const linkPath = join(tmpdir(), 'test-output-symlink-' + Date.now() + '.png');
|
||||
try {
|
||||
symlinkSync('/etc/crontab', linkPath);
|
||||
symlinkSync('/etc/passwd', linkPath); // /etc/passwd exists on every Unix — /etc/crontab is absent on Amazon Linux/Fedora minimal;
|
||||
expect(() => validateOutputPath(linkPath)).toThrow(/Path must be within/);
|
||||
} finally {
|
||||
try { unlinkSync(linkPath); } catch {}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
import { describe, test, expect, afterAll } from 'bun:test';
|
||||
import { canRevokeWrites } from '../../test/helpers/fs-caps';
|
||||
import * as fs from 'fs';
|
||||
// Default (CJS) export — its properties are mutable in Bun, unlike the frozen
|
||||
// `* as fs` namespace, and mutations propagate to cli.ts's own fs import.
|
||||
@@ -41,7 +42,7 @@ describe('acquireServerLock (#1084 error honesty)', () => {
|
||||
});
|
||||
|
||||
test('EACCES throws ServerLockError with the real errno — NOT phantom contention', () => {
|
||||
if (process.platform === 'win32' || process.getuid?.() === 0) return; // chmod semantics differ
|
||||
if (!canRevokeWrites()) return; // chmod is advisory here (win32, root, DAC-override containers)
|
||||
const rodir = path.join(tmpRoot, 'rodir');
|
||||
fs.mkdirSync(rodir, { recursive: true });
|
||||
fs.chmodSync(rodir, 0o500); // r-x: open('wx') inside fails EACCES
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
import { describe, test, expect, afterAll } from 'bun:test';
|
||||
import { canRevokeWrites } from '../../test/helpers/fs-caps';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
@@ -128,7 +129,7 @@ describe('session-persist units', () => {
|
||||
|
||||
test('a failed snapshot write preserves the previous good snapshot', async () => {
|
||||
// chmod-based read-only dirs don't bind on Windows or when running as root.
|
||||
if (process.platform === 'win32' || process.getuid?.() === 0) return;
|
||||
if (!canRevokeWrites()) return; // chmod is advisory here (win32, root, DAC-override containers)
|
||||
const dir = path.join(tmpRoot, 'ro');
|
||||
fs.mkdirSync(dir);
|
||||
const file = path.join(dir, 'session-state.json');
|
||||
|
||||
Reference in New Issue
Block a user