From be4f33d0574c6f655a0051ce9ae2f685d4cff2eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 10:54:35 +0000 Subject: [PATCH 1/4] Initial plan From 60cc9edac524834acb70c10b07d290f57511dc73 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 11:06:03 +0000 Subject: [PATCH 2/4] Add sandbox security tests to verify 0f4f974 web security fix Co-authored-by: suchi <74622+suchi@users.noreply.github.com> --- spec/sucheme/evaluator_spec.rb | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/spec/sucheme/evaluator_spec.rb b/spec/sucheme/evaluator_spec.rb index 933ff53..ad3ac31 100644 --- a/spec/sucheme/evaluator_spec.rb +++ b/spec/sucheme/evaluator_spec.rb @@ -420,4 +420,42 @@ def eval_str(source, e = env) expect(eval_str('x', env)).to eq(1) end end + + describe 'make_sandbox_env' do + let(:sandbox) { described_class.make_sandbox_env } + + it 'allows normal arithmetic in sandbox' do + expect(described_class.eval_source('(+ 1 2)', sandbox)).to eq(3) + end + + it 'blocks open-input-file in sandbox' do + expect { described_class.eval_source('(open-input-file "test.txt")', sandbox) } + .to raise_error(Sucheme::EvalError, /open-input-file.*not available in sandbox/) + end + + it 'blocks open-output-file in sandbox' do + expect { described_class.eval_source('(open-output-file "test.txt")', sandbox) } + .to raise_error(Sucheme::EvalError, /open-output-file.*not available in sandbox/) + end + + it 'blocks load in sandbox' do + expect { described_class.eval_source('(load "file.scm")', sandbox) } + .to raise_error(Sucheme::EvalError, /load.*not available in sandbox/) + end + + it 'blocks exit in sandbox' do + expect { described_class.eval_source('(exit)', sandbox) } + .to raise_error(Sucheme::EvalError, /exit.*not available in sandbox/) + end + + it 'blocks call-with-input-file in sandbox' do + expect { described_class.eval_source('(call-with-input-file "f" (lambda (p) #f))', sandbox) } + .to raise_error(Sucheme::EvalError, /call-with-input-file.*not available in sandbox/) + end + + it 'blocks call-with-output-file in sandbox' do + expect { described_class.eval_source('(call-with-output-file "f" (lambda (p) #f))', sandbox) } + .to raise_error(Sucheme::EvalError, /call-with-output-file.*not available in sandbox/) + end + end end From 0c47e2b00f7bd6e650121da605101ef4aad59029 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 11:12:44 +0000 Subject: [PATCH 3/4] Add with-input/output-from/to-file sandbox tests; add Windows usage to README Co-authored-by: suchi <74622+suchi@users.noreply.github.com> --- README.md | 19 +++++++++++++++++++ spec/sucheme/evaluator_spec.rb | 10 ++++++++++ 2 files changed, 29 insertions(+) diff --git a/README.md b/README.md index cbb22a1..5662ec9 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,25 @@ bundle exec ruby bin/sucheme -e '(+ 1 2 3)' bundle exec ruby web/app.rb ``` +### Windows (PowerShell) + +```powershell +# REPL起動 +bundle exec ruby bin/sucheme + +# ファイル実行 +bundle exec ruby bin/sucheme samples\01_basics\variables.scm + +# 式の評価(シングルクォートの代わりにダブルクォートを使用) +bundle exec ruby bin/sucheme -e "(+ 1 2 3)" + +# バッチラッパー経由(bin\sucheme.bat) +bundle exec ruby bin\sucheme -e "(+ 1 2 3)" + +# Web UI +bundle exec ruby web\app.rb +``` + ## クイックスタート ```scheme diff --git a/spec/sucheme/evaluator_spec.rb b/spec/sucheme/evaluator_spec.rb index ad3ac31..43c15e5 100644 --- a/spec/sucheme/evaluator_spec.rb +++ b/spec/sucheme/evaluator_spec.rb @@ -457,5 +457,15 @@ def eval_str(source, e = env) expect { described_class.eval_source('(call-with-output-file "f" (lambda (p) #f))', sandbox) } .to raise_error(Sucheme::EvalError, /call-with-output-file.*not available in sandbox/) end + + it 'blocks with-input-from-file in sandbox' do + expect { described_class.eval_source('(with-input-from-file "f" (lambda () #f))', sandbox) } + .to raise_error(Sucheme::EvalError, /with-input-from-file.*not available in sandbox/) + end + + it 'blocks with-output-to-file in sandbox' do + expect { described_class.eval_source('(with-output-to-file "f" (lambda () #f))', sandbox) } + .to raise_error(Sucheme::EvalError, /with-output-to-file.*not available in sandbox/) + end end end From 905a19c286086437c9597ba9ad52690967f61d7d Mon Sep 17 00:00:00 2001 From: suchi Date: Mon, 23 Feb 2026 20:45:59 +0900 Subject: [PATCH 4/4] Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5662ec9..faf47e3 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ bundle exec ruby bin/sucheme samples\01_basics\variables.scm bundle exec ruby bin/sucheme -e "(+ 1 2 3)" # バッチラッパー経由(bin\sucheme.bat) -bundle exec ruby bin\sucheme -e "(+ 1 2 3)" +.\bin\sucheme.bat -e "(+ 1 2 3)" # Web UI bundle exec ruby web\app.rb