From 7abba4c77b7c78d6c46b383556819c0072e9230b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 12:41:09 +0000 Subject: [PATCH] Clean up test files and update gitignore Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --- .gitignore | 3 ++ shell/preload/test_sandbox_direct.js | 43 ------------------------ shell/preload/test_sandbox_direct.py | 50 ---------------------------- 3 files changed, 3 insertions(+), 93 deletions(-) delete mode 100644 shell/preload/test_sandbox_direct.js delete mode 100644 shell/preload/test_sandbox_direct.py diff --git a/.gitignore b/.gitignore index 709791ed..2f6acf71 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ __pycache__ /shell/preload/notify.* /shell/preload/*-notify.json /shell/preload/__ql_notify__.* +test_sandbox_integration.sh +data/scripts/test_*.js +data/scripts/test_*.py diff --git a/shell/preload/test_sandbox_direct.js b/shell/preload/test_sandbox_direct.js deleted file mode 100644 index 2ce18f38..00000000 --- a/shell/preload/test_sandbox_direct.js +++ /dev/null @@ -1,43 +0,0 @@ -// Minimal test of sandbox module -const path = require('path'); - -// Set up environment -process.env.QL_DIR = path.join(__dirname, '../..'); -process.env.QL_DATA_DIR = path.join(__dirname, '../../data'); - -// Load sandbox -require('./sandbox.js'); - -const fs = require('fs'); - -console.log("Testing filesystem sandbox...\n"); - -// Test 1: Try to write to config directory (should fail) -console.log("Test 1: Attempting to write to config/test.txt (should fail)..."); -try { - const configPath = path.join(__dirname, '../../data/config/test.txt'); - fs.writeFileSync(configPath, 'test'); - console.log("❌ FAILED: Was able to write to protected config directory!"); - process.exit(1); -} catch (error) { - if (error.code === 'EACCES' && error.message.includes('Security Error')) { - console.log("✅ PASSED: Correctly blocked write to config directory"); - console.log("Error message:", error.message.split('\n')[0]); - } else { - console.log("❓ UNEXPECTED ERROR:", error.message); - } -} - -// Test 2: Write to scripts directory (should succeed) -console.log("\nTest 2: Attempting to write to scripts directory (should succeed)..."); -try { - const scriptsPath = path.join(__dirname, '../../data/scripts/test_output.txt'); - fs.writeFileSync(scriptsPath, 'This is a test file'); - console.log("✅ PASSED: Successfully wrote to scripts directory"); - fs.unlinkSync(scriptsPath); -} catch (error) { - console.log("❌ FAILED: Could not write to allowed scripts directory:", error.message); - process.exit(1); -} - -console.log("\n✅ Basic sandbox tests passed!"); diff --git a/shell/preload/test_sandbox_direct.py b/shell/preload/test_sandbox_direct.py deleted file mode 100644 index 901737a1..00000000 --- a/shell/preload/test_sandbox_direct.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 -# Minimal test of Python sandbox module -import os -import sys -from pathlib import Path - -# Set up environment -script_dir = Path(__file__).parent.resolve() -ql_dir = script_dir.parent.parent -os.environ['QL_DIR'] = str(ql_dir) -os.environ['QL_DATA_DIR'] = str(ql_dir / 'data') - -# Add preload to path -sys.path.insert(0, str(script_dir)) - -# Load sandbox -import sandbox - -print("Testing Python filesystem sandbox...\n") - -# Test 1: Try to write to config directory (should fail) -print("Test 1: Attempting to write to config/test.txt (should fail)...") -try: - config_path = ql_dir / 'data' / 'config' / 'test.txt' - with open(config_path, 'w') as f: - f.write('test') - print("❌ FAILED: Was able to write to protected config directory!") - sys.exit(1) -except PermissionError as e: - if 'Security Error' in str(e): - print("✅ PASSED: Correctly blocked write to config directory") - print(f"Error message: {str(e).split(chr(10))[0]}") - else: - print(f"❓ UNEXPECTED ERROR: {e}") -except Exception as e: - print(f"❓ UNEXPECTED ERROR: {e}") - -# Test 2: Write to scripts directory (should succeed) -print("\nTest 2: Attempting to write to scripts directory (should succeed)...") -try: - scripts_path = ql_dir / 'data' / 'scripts' / 'test_output.txt' - with open(scripts_path, 'w') as f: - f.write('This is a test file') - print("✅ PASSED: Successfully wrote to scripts directory") - os.remove(scripts_path) -except Exception as e: - print(f"❌ FAILED: Could not write to allowed scripts directory: {e}") - sys.exit(1) - -print("\n✅ Basic Python sandbox tests passed!")