-
Notifications
You must be signed in to change notification settings - Fork 30
fix(cloud): give a cloud box's agent its workspace, and stop three AppleDouble leaks #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
madarco
wants to merge
3
commits into
nightly
Choose a base branch
from
agentbox/cloud-workspace-env
base: nightly
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import { readFileSync, readdirSync, statSync } from 'node:fs'; | ||
| import { join } from 'node:path'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| /** | ||
| * Source-level guard: a `tar` that CREATES an archive from a host path must | ||
| * pass `COPYFILE_DISABLE=1`. | ||
| * | ||
| * macOS BSD tar otherwise emits `._*` AppleDouble resource-fork stubs, and they | ||
| * land wherever the archive is unpacked — a box's `/workspace`, a bake context, | ||
| * an exported clone. This is not a theoretical rule: it has been fixed FIVE | ||
| * separate times at five call sites, each time as a bug report from a real box | ||
| * (`._agentbox.yaml`, `._AGENTS.md`, `._skills`), because the rule lived only in | ||
| * the comments of the sites that already had it. | ||
| * | ||
| * Extractions (`-x`) are exempt — the variable means nothing when unpacking. | ||
| * | ||
| * A source scan rather than a lint rule for the same reason | ||
| * `no-inline-agent-union.test.ts` is one: it is one rule about one repo fact, | ||
| * and it must fail in the same `pnpm test` run that would otherwise pass. | ||
| */ | ||
| const REPO = join(__dirname, '..', '..', '..'); | ||
|
|
||
| const ROOTS = [ | ||
| 'apps/cli/src', | ||
| 'packages/core/src', | ||
| 'packages/ctl/src', | ||
| 'packages/relay/src', | ||
| 'packages/sandbox-core/src', | ||
| 'packages/sandbox-cloud/src', | ||
| 'packages/sandbox-docker/src', | ||
| 'packages/sandbox-remote-docker/src', | ||
| 'packages/sandbox-hetzner/src', | ||
| 'packages/sandbox-digitalocean/src', | ||
| ]; | ||
|
|
||
| /** A create flag: `-c`, `-cf`, `-czf`, `-cvf`… but never `-x…`. */ | ||
| const CREATE_FLAG = /'-[a-zA-Z]*c[a-zA-Z]*'/; | ||
|
|
||
| function walk(dir: string, out: string[] = []): string[] { | ||
| let entries: string[]; | ||
| try { | ||
| entries = readdirSync(dir); | ||
| } catch { | ||
| return out; | ||
| } | ||
| for (const name of entries) { | ||
| const full = join(dir, name); | ||
| if (statSync(full).isDirectory()) { | ||
| if (name !== 'node_modules' && name !== 'dist') walk(full, out); | ||
| } else if (name.endsWith('.ts')) { | ||
| out.push(full); | ||
| } | ||
| } | ||
| return out; | ||
| } | ||
|
|
||
| /** Every `execa('tar', …)` call site, as (file, line, call text). */ | ||
| function tarCalls(): { file: string; line: number; call: string }[] { | ||
| const out: { file: string; line: number; call: string }[] = []; | ||
| for (const root of ROOTS) { | ||
| for (const file of walk(join(REPO, root))) { | ||
| const src = readFileSync(file, 'utf8'); | ||
| const re = /execa\(\s*'tar'/g; | ||
| let m: RegExpExecArray | null; | ||
| while ((m = re.exec(src)) !== null) { | ||
| // Enough of the call to cover its options object; these are short. | ||
| const seg = src.slice(m.index, m.index + 800); | ||
| const end = seg.indexOf('});'); | ||
| out.push({ | ||
| file: file.slice(REPO.length + 1), | ||
| line: src.slice(0, m.index).split('\n').length, | ||
| call: end === -1 ? seg.slice(0, 400) : seg.slice(0, end + 3), | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| return out; | ||
| } | ||
|
|
||
| describe('tar invocations', () => { | ||
| const calls = tarCalls(); | ||
|
|
||
| it('finds the tar call sites at all (guards the scanner itself)', () => { | ||
| expect(calls.length).toBeGreaterThan(10); | ||
| }); | ||
|
|
||
| it('every archive-CREATING tar disables macOS AppleDouble stubs', () => { | ||
| const offenders = calls | ||
| .filter((c) => CREATE_FLAG.test(c.call)) | ||
| .filter((c) => !c.call.includes('COPYFILE_DISABLE') && !c.call.includes('HOST_TAR_ENV')) | ||
| .map((c) => `${c.file}:${String(c.line)}`); | ||
| expect( | ||
| offenders, | ||
| `add \`env: { ...process.env, COPYFILE_DISABLE: '1' }\` to:\n ${offenders.join('\n ')}`, | ||
| ).toEqual([]); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resume drops cloud agent run-env
Medium Severity
Resume builds
agentRunEnvfrombox.agents ?? [], so a missingagentsfield becomes no run-env. Create usesagentVolumes.agents, which means every agent when the caller omitted a selection, and the kick then rewritesbox.envwithtee. A later start therefore stripsOPENCLAW_WORKSPACE_DIR(and other declared run-env) for generic and pre-selection boxes, undoing the workspace fix this change just applied.Reviewed by Cursor Bugbot for commit 32c257c. Configure here.