Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
.\bin\sucheme.bat -e "(+ 1 2 3)"

# Web UI
bundle exec ruby web\app.rb
```

## クイックスタート

```scheme
Expand Down
48 changes: 48 additions & 0 deletions spec/sucheme/evaluator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,4 +420,52 @@ 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
Comment on lines +424 to +459

Copilot AI Feb 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make_sandbox_env blocks with-input-from-file / with-output-to-file as well (see SANDBOX_BLOCKED in lib/sucheme/evaluator.rb), but this spec only asserts blocking for open-*-file, load, exit, and call-with-*-file. Add examples for the remaining two to ensure sandbox restrictions are fully covered and avoid regressions.

Copilot generated this review using guidance from repository custom instructions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コミット 0c47e2b で with-input-from-file と with-output-to-file のブロックテストを追加しました。これで SANDBOX_BLOCKED の全8プリミティブ(open-input-file, open-output-file, with-input-from-file, with-output-to-file, call-with-input-file, call-with-output-file, load, exit)がテストでカバーされています。


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
Loading