The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test: restore path escape regression coverage
Steven Enamakel334be8bb25a5
diff --git a/app/test/e2e/specs/tool-filesystem-flow.spec.ts b/app/test/e2e/specs/tool-filesystem-flow.spec.tsindex d370049580..ea482498f6 100644--- a/app/test/e2e/specs/tool-filesystem-flow.spec.ts+++ b/app/test/e2e/specs/tool-filesystem-flow.spec.ts@@ -1,4 +1,8 @@// @ts-nocheck+import { randomUUID } from 'node:crypto';+import { promises as fs } from 'node:fs';+import path from 'node:path';+import { waitForApp } from '../helpers/app-helpers';import { callOpenhumanRpc } from '../helpers/core-rpc';import { resetApp } from '../helpers/reset-app';@@ -8,6 +12,12 @@ const USER_ID = 'e2e-tool-filesystem';const PERSONA_FILE = 'SOUL.md';const TEST_CONTENT = 'Filesystem RPC E2E canary';+function workspaceDir(): string {+ const workspace = process.env.OPENHUMAN_WORKSPACE;+ if (!workspace) throw new Error('OPENHUMAN_WORKSPACE is required for path escape assertions');+ return workspace;+}+describe('Workspace persona files — read, write, and path restriction', () => {before(async function beforeSuite() {this.timeout(90_000);@@ -39,19 +49,20 @@ describe('Workspace persona files — read, write, and path restriction', () =>});it('rejects traversal and absolute paths without writing outside the workspace', async () => {- const invalidNames = ['../escape-967.txt', '/tmp/openhuman-967-absolute-escape.txt'];- for (const filename of invalidNames) {+ const escapedFile = path.resolve(workspaceDir(), '..', `e2e-escape-${randomUUID()}.txt`);+ const traversalName = path.relative(workspaceDir(), escapedFile);+ for (const filename of [traversalName, escapedFile]) {const result = await callOpenhumanRpc('openhuman.workspace_file_write', {filename,contents: 'must not be written',});expect(result.ok).toBe(false);expect(result.error?.toLowerCase()).toMatch(/editable|allow|invalid|not found|unknown/);++ const read = await callOpenhumanRpc('openhuman.workspace_file_read', { filename });+ expect(read.ok).toBe(false);}- const traversal = await callOpenhumanRpc('openhuman.workspace_file_read', {- filename: invalidNames[0],- });- expect(traversal.ok).toBe(false);+ await expect(fs.readFile(escapedFile, 'utf8')).rejects.toMatchObject({ code: 'ENOENT' });});});diff --git a/crates/openhuman-core/src/core/all_tests.rs b/crates/openhuman-core/src/core/all_tests.rsindex be05ab35e0..1b690355c8 100644--- a/crates/openhuman-core/src/core/all_tests.rs+++ b/crates/openhuman-core/src/core/all_tests.rs@@ -198,7 +198,11 @@ fn all_controller_schemas_matches_registered_count() {// two public lookups, so comparing separate snapshots is racy.let view = registry_view();let visible: Vec<_> = view.iter().filter(|g| group_allowed(g.group)).collect();- let schemas = visible.len();+ let schemas = visible+ .iter()+ .map(|group| &group.controller.schema)+ .filter(|schema| !schema.namespace.is_empty() && !schema.function.is_empty())+ .count();let controllers = visible.len();assert_eq!(schemas, controllers);}