Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Keep the guard when the team workspace is a data root

Fei2411e1b08128bb05
diff --git a/ds-bot/src/host/folders.js b/ds-bot/src/host/folders.js
index 39dae7d0..38d024ee 100644
--- a/ds-bot/src/host/folders.js
+++ b/ds-bot/src/host/folders.js
@@ -58,13 +58,13 @@ export function install(rt) {
// A Bot that could write where DSH or the team keeps its data could change its own
// permissions or the team, so neither those folders nor one that holds them is allowed.
// The workspace exception covers only a workspace lying inside the data root (the
- // plugin's default does): one that holds a data root does not open it up.
+ // plugin's default does): one that holds or is a data root does not open it up.
async function guarded(path) {
const team = await realTeam()
for (const root of dataRoots()) {
const data = await real(root)
if (within(data, path)) return true
- if (within(path, data) && !(team !== undefined && within(path, team) && within(team, data))) return true
+ if (within(path, data) && !(team !== undefined && within(path, team) && team !== data && within(team, data))) return true
}
return false
}
@@ -76,7 +76,7 @@ export function install(rt) {
const team = await realTeam()
for (const root of dataRoots()) {
const data = await real(root)
- if (within(path, data) && !(team !== undefined && within(path, team) && within(team, data))) return true
+ if (within(path, data) && !(team !== undefined && within(path, team) && team !== data && within(team, data))) return true
}
return false
}
diff --git a/ds-bot/test/work-dir.test.js b/ds-bot/test/work-dir.test.js
index 6cd8a691..d0f32db7 100644
--- a/ds-bot/test/work-dir.test.js
+++ b/ds-bot/test/work-dir.test.js
@@ -641,7 +641,7 @@ test('the team workspace holds no DeepSeek Harness data, apart from the plugin\'
test('a team workspace that holds the data still keeps Bots out of it', async (t) => {
const root = realpathSync.native(mkdtempSync(join(tmpdir(), 'ds-bot-work-dir-')))
const { dsh, home, project, state, call, tool, stop } = await start({
- rootDir: root,
+ root,
workspaces: [{ id: 'w9', path: root, title: 'root' }],
team: { ...TEAM, workspaceId: 'w9' },
})
@@ -661,6 +661,30 @@ test('a team workspace that holds the data still keeps Bots out of it', async (t
assert.equal(await tool('update_bot', { avatar: pic }, 'b'), `Could not update the Bot: ${pic} is in DeepSeek Harness data, so it cannot be a Bot's photo. Pass an image from another folder.`)
})
+// #508: the exception covers a workspace lying inside a data root, not one equal to
+// it: a workspace that is DSH's home or the team's own data opens every folder in it.
+test('a team workspace that is a data root still keeps Bots out of it', async (t) => {
+ const PNG = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])
+ for (const name of ['dsh', 'bot']) {
+ const root = realpathSync.native(mkdtempSync(join(tmpdir(), 'ds-bot-work-dir-')))
+ const at = name === 'dsh' ? join(root, 'dsh') : join(root, 'dsh', 'bot')
+ const env = await start({
+ root,
+ workspaces: [{ id: 'w9', path: at, title: name }],
+ team: { ...TEAM, workspaceId: 'w9' },
+ })
+ t.after(env.stop)
+ const error = async workDir => (await env.call('update-bot', { id: 'b', workDir })).error?.message
+ for (const guarded of [join(env.dsh, 'profiles'), join(env.home, 'memory')]) {
+ mkdirSync(guarded, { recursive: true })
+ assert.equal(await error(guarded), `${guarded} holds DeepSeek Harness data, so Bots cannot work there`)
+ }
+ writeFileSync(join(env.dsh, 'profiles', 'pic.png'), PNG)
+ const pic = join(env.dsh, 'profiles', 'pic.png')
+ assert.equal(await env.tool('update_bot', { avatar: pic }, 'b'), `Could not update the Bot: ${pic} is in DeepSeek Harness data, so it cannot be a Bot's photo. Pass an image from another folder.`)
+ }
+})
+
// #508: with no sandbox policy service a folder outside the workspace asked nobody.
test('a folder outside the workspace asks for approval, or throws when nobody can be asked', async (t) => {
const first = await start()