Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(runners): redact configured runner roots [C7]

Corey Olsonf971f8264a1f
diff --git a/src/runner-worker.js b/src/runner-worker.js
index 7a367627..19d93d68 100644
--- a/src/runner-worker.js
+++ b/src/runner-worker.js
@@ -15,6 +15,7 @@ import {
openSync,
readFileSync,
readdirSync,
+ realpathSync,
readSync,
renameSync,
rmSync,
@@ -65,6 +66,7 @@ let cleanupTimer = null;
let cleanupStage = 'command exit';
let cleanupDirectory = null;
let cleanupDetails = null;
+const setupPrivatePaths = new Set();
/** Start the post-run budget once; later cleanup phases cannot extend it. */
function beginCleanup() {
@@ -837,7 +839,7 @@ async function acquireResourceApi(api, options, machineHomePath) {
/** Bound Git diagnostics and hide runner-private paths, URL credentials and credential assignments. */
function safeGitDiagnostic(value, root, env) {
let text = String(value).replace(/\u001b\[[0-?]*[ -/]*[@-~]/gu, '').replace(/\r\n?/gu, '\n').replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/gu, '');
- for (const [path, label] of [[root, '<source>'], [env.HOME, '<job-home>'], [process.env.HOME, '<runner-home>'], [env.TMPDIR, '<job-tmp>']]) {
+ for (const [path, label] of [[root, '<source>'], [env.HOME, '<job-home>'], [process.env.HOME, '<runner-home>'], [env.TMPDIR, '<job-tmp>'], ...[...setupPrivatePaths].map(path => [path, '<runner-state>'])]) {
if (path && path.length > 1) text = text.split(path).join(label);
}
text = text.replace(/https?:\/\/[^\s"'<>]+/giu, '<url>')
@@ -1250,11 +1252,14 @@ async function main() {
try {
const runnerHome = isAbsolute(process.env.HOME || '') ? process.env.HOME : userInfo().homedir;
const runnerRoot = spec.root ?? join(runnerHome, '.pullboard-runner');
+ setupPrivatePaths.add(runnerRoot);
mkdirSync(runnerRoot, { recursive: true, mode: 0o700 });
+ setupPrivatePaths.add(realpathSync(runnerRoot));
chmodSync(runnerRoot, 0o700);
const configuredMachineHome = process.env.PULLBOARD_MACHINE_HOME;
if (configuredMachineHome !== undefined && !isAbsolute(configuredMachineHome)) throw new Error('machine home is invalid');
const machineHomePath = configuredMachineHome ?? join(runnerHome, '.pullboard');
+ setupPrivatePaths.add(machineHomePath);
setupStep = 'trusted resource API';
api = loadResourceApi(spec.runtime);
const previousMachineHome = process.env.PULLBOARD_MACHINE_HOME;
diff --git a/test/runner-source-setup-fixture.js b/test/runner-source-setup-fixture.js
index ea8a2437..eee102d6 100644
--- a/test/runner-source-setup-fixture.js
+++ b/test/runner-source-setup-fixture.js
@@ -17,6 +17,7 @@ export async function sourceSetupFailureFixture(t, { cli, git, runThroughGate, g
});
const home = join(dir, 'home'), machineHome = join(home, '.pullboard');
const remoteHome = join(dir, 'worker-home'), remoteMachineHome = join(remoteHome, '.pullboard');
+ const configuredRoot = mode === 'custom-filesystem' ? join(dir, 'configured-root') : join(remoteHome, '.pullboard-runner');
const repo = join(dir, 'repo'), worker = join(dir, 'worker'), bin = join(dir, 'bin');
const requests = join(dir, 'requests.jsonl'), injected = join(dir, 'injected');
const executed = join(dir, 'command-executed'), preload = join(dir, 'checkout-lock.mjs');
@@ -30,8 +31,8 @@ export async function sourceSetupFailureFixture(t, { cli, git, runThroughGate, g
writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({ gate: 'true' }));
writeFileSync(join(repo, 'tracked.txt'), 'source\n');
git(repo, env, 'add', '.'); git(repo, env, 'commit', '-qm', 'test: source setup fixture');
- if (mode === 'filesystem') {
- const state = join(remoteHome, '.pullboard-runner');
+ if (mode.endsWith('filesystem')) {
+ const state = configuredRoot;
mkdirSync(state, { recursive: true });
writeFileSync(join(state, 'repos'), 'a file prevents creating the cache directory\n');
writeFileSync(injected, 'cache directory obstacle injected\n');
@@ -40,6 +41,7 @@ export async function sourceSetupFailureFixture(t, { cli, git, runThroughGate, g
import { syncBuiltinESMExports } from 'node:module';
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
+if (${JSON.stringify(mode)} === 'custom-filesystem') process.env.TMPDIR = ${JSON.stringify(join(remoteHome, 'shell-tmp'))};
const spawn = childProcess.spawn;
childProcess.spawn = (command, args, options) => {
const operation = ${JSON.stringify(mode)} === 'index' ? 'index-pack' : 'checkout';
@@ -56,7 +58,9 @@ childProcess.spawn = (command, args, options) => {
syncBuiltinESMExports();\n`);
installSshStandIn({ bin, worker, home: remoteHome, machineHome: remoteMachineHome, requests,
nodeOptions: `--import=${pathToFileURL(preload).href}` });
- const added = cli(repo, env, 'runner', 'add', HOST, '--slots', '1', '--browser', '1', '--json');
+ mkdirSync(join(remoteHome, 'shell-tmp'), { recursive: true });
+ const rootArgs = mode === 'custom-filesystem' ? ['--root', configuredRoot] : [];
+ const added = cli(repo, env, 'runner', 'add', HOST, '--slots', '1', '--browser', '1', ...rootArgs, '--json');
assert.equal(added.status, 0, added.context);
const previous = [process.env.PULLBOARD_HOME, process.env.PULLBOARD_MACHINE_HOME];
process.env.PULLBOARD_HOME = home; process.env.PULLBOARD_MACHINE_HOME = machineHome;
@@ -68,7 +72,7 @@ syncBuiltinESMExports();\n`);
assert.equal(gateResult(result.stdout).isGreen, false, 'the failed setup is not a successful run');
assert.equal(existsSync(injected), true, 'the real checkout Git operation encountered the lock');
assert.equal(existsSync(executed), false, 'the requested command never ran or fell back locally');
- if (mode === 'filesystem') {
+ if (mode.endsWith('filesystem')) {
assert.match(result.stdout, /step: source history checkout.*EEXIST[\s\S]*cause:/u, 'filesystem setup keeps its phase, code and cause');
} else if (mode === 'index') {
assert.match(result.stdout, /source cache: git index-pack.*exit \d+[\s\S]*git stderr:.*(?:usage|error)/iu, 'a broken pack command retains Git stderr even when its input pipe fails');
@@ -83,6 +87,7 @@ syncBuiltinESMExports();\n`);
assert.ok(Buffer.byteLength(result.stdout.split('PULLBOARD_RUN_RESULT ')[0]) < 2_400, 'the diagnostic is bounded in bytes');
}
assert.ok(!result.stdout.includes(remoteHome), 'runner-private paths never reach the controller');
+ assert.ok(!result.stdout.includes(configuredRoot), 'a configured runner root outside HOME and TMPDIR stays private too');
completed = true;
} finally {
held?.release();
diff --git a/test/runners.test.js b/test/runners.test.js
index 45103ee9..a4c854d6 100644
--- a/test/runners.test.js
+++ b/test/runners.test.js
@@ -1910,7 +1910,7 @@ test('review655 a registered runner honors the same live person waiver at landin
}
});
test('a refused runner checkout names its failed Git step and stderr [C6,C7]', async t => {
- for (const mode of ['lock', 'missing', 'large', 'filesystem', 'index']) {
+ for (const mode of ['lock', 'missing', 'large', 'filesystem', 'index', 'custom-filesystem']) {
await t.test(mode, child => sourceSetupFailureFixture(child, { cli, git, runThroughGate, gateResult }, mode));
}
});