Repository navigation
First prepares for ms-* tasks (more network allowance + more run stability + remove mtime leak) #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
24ded77
miniswen: allow using free OpenRouter models
ardecvz e69cb5f
miniswen: a background process holding a command's output no longer h…
ardecvz cbf873c
miniswen: a turn that ends past the deadline runs no command
ardecvz 93837d7
Task files get one mtime
ardecvz 41f10b1
miniswen: add --workdir to run commands in a given directory
ardecvz 06eb886
miniswen: jailed commands take their environment from PID 1, not the …
ardecvz 3aee31b
miniswen: relax the jail to reach allowlisted hosts through a loopbac…
ardecvz c7b8429
Support verifier.environment.network to repeat gem installations duri…
ardecvz 3773f22
Update CHANGELOG.md
baygeldin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "fileutils" | ||
| require "socket" | ||
|
|
||
| module Miniswen | ||
| class Jail < Local | ||
| # An HTTP CONNECT proxy that lets jailed commands reach the allowed hosts only. | ||
| class Proxy | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yeah! That was on my list) 👍 |
||
| def self.forward(port, socket) | ||
| server = TCPServer.new("127.0.0.1", port) | ||
| exit!(0) if fork | ||
| serve(server) { pump(it, UNIXSocket.new(socket)) } | ||
| end | ||
|
|
||
| def self.serve(server) | ||
| Thread.report_on_exception = false | ||
| loop { Thread.new(server.accept) { yield it } } | ||
| end | ||
|
|
||
| def self.pump(client, upstream) | ||
| Thread.new do | ||
| IO.copy_stream(client, upstream) | ||
| upstream.close_write | ||
| end | ||
| IO.copy_stream(upstream, client) | ||
| ensure | ||
| client.close | ||
| upstream.close | ||
| end | ||
|
|
||
| def initialize(hosts:, socket:) | ||
| @hosts = hosts | ||
| @socket = socket | ||
| end | ||
|
|
||
| def start | ||
| FileUtils.rm_f(@socket) | ||
| server = UNIXServer.new(@socket) | ||
| @pid = fork { self.class.serve(server) { handle(it) } } | ||
| self | ||
| end | ||
|
|
||
| def stop | ||
| Process.kill(:KILL, @pid) | ||
| Process.wait(@pid) | ||
| end | ||
|
|
||
| def handle(client) | ||
| _, target = client.gets("\r\n\r\n").split(" ", 3) | ||
| host, port = target.split(":", 2) | ||
| return client.write("HTTP/1.1 403 Forbidden\r\n\r\n") unless @hosts.include?(host) | ||
|
|
||
| upstream = Socket.tcp(host, port.to_i, connect_timeout: 10) | ||
| client.write("HTTP/1.1 200 Connection Established\r\n\r\n") | ||
| self.class.pump(client, upstream) | ||
| ensure | ||
| client.close | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.