Package pinned native Claude and prove isolated startup
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a0726e-5232-73f2-aaca-2c05ceb62efb
This commit is contained in:
parent
cfc79d51af
commit
174dba17b6
7 changed files with 299 additions and 8 deletions
|
|
@ -38,6 +38,17 @@ assert not source.exists()
|
|||
help_result = subprocess.run(['rein-aharness', '--help'], capture_output=True, timeout=15)
|
||||
assert help_result.returncode == 0
|
||||
assert b'usage:' in help_result.stdout
|
||||
claude_version = None
|
||||
proxy_present = False
|
||||
if sys.argv[2]:
|
||||
assert 'ANTHROPIC_API_KEY' not in os.environ
|
||||
proxy_present = os.environ['HTTPS_PROXY'].startswith('http://127.0.0.1:')
|
||||
assert proxy_present
|
||||
cli = subprocess.run([str(runtime / 'bin/claude'), '--version'],
|
||||
capture_output=True, text=True, timeout=20)
|
||||
assert cli.returncode == 0, cli.stderr
|
||||
claude_version = cli.stdout.strip()
|
||||
assert claude_version == sys.argv[2] + ' (Claude Code)', claude_version
|
||||
assert subprocess.check_output(['git', 'status', '--porcelain', '--ignored=matching']) == b''
|
||||
interfaces = [line.split(':', 1)[0].strip()
|
||||
for line in Path('/proc/net/dev').read_text().splitlines()[2:]]
|
||||
|
|
@ -47,6 +58,8 @@ print(json.dumps({'rein_cli_started': True, 'adapter_imported': True,
|
|||
'home_outside_workspace': True, 'home_mode': '0700',
|
||||
'worktree_clean': True, 'interfaces': interfaces,
|
||||
'python_prefix': sys.prefix,
|
||||
'claude_version': claude_version, 'https_proxy_present': proxy_present,
|
||||
'claude_provider_request_proven': False,
|
||||
'credential_refs': json.loads(os.environ['SANDBOXER_CREDENTIAL_ROUTE_REFS'])}))
|
||||
'''
|
||||
|
||||
|
|
@ -55,22 +68,26 @@ def main() -> int:
|
|||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--runtime-path", required=True)
|
||||
parser.add_argument("--runtime-sha256", required=True)
|
||||
parser.add_argument("--claude-version", default="")
|
||||
args = parser.parse_args()
|
||||
with tempfile.TemporaryDirectory(prefix="sandboxer-runtime-proof-") as temporary:
|
||||
root = Path(temporary)
|
||||
source = root / "source"
|
||||
source.mkdir()
|
||||
subprocess.run(["git", "init", "-q", str(source)], check=True)
|
||||
egress = ["api.anthropic.com:443"] if args.claude_version else []
|
||||
extension = BwrapExtension({
|
||||
"allowed_egress": egress,
|
||||
"base_dir": str(root / "sandboxes"),
|
||||
"runtime": {"path": args.runtime_path, "sha256": args.runtime_sha256},
|
||||
})
|
||||
profile = Profile(id="profile.runtime-proof", version="1", extension="ext.bwrap")
|
||||
profile = Profile(id="profile.runtime-proof", version="1", extension="ext.bwrap",
|
||||
network={"default": "deny", "egress": egress})
|
||||
handle = extension.provision(profile, {"repo": str(source)}, "localhost")
|
||||
try:
|
||||
extension.wait_ready(handle)
|
||||
result = extension.execute(
|
||||
handle, ["python3", "-c", PROBE, str(source)],
|
||||
handle, ["python3", "-c", PROBE, str(source), args.claude_version],
|
||||
credential_route_refs=[],
|
||||
execution_context={"actor": "agt", "project": "sand-boxer-runtime-proof",
|
||||
"run_id": "sand-wp-0015-proof"},
|
||||
|
|
@ -91,12 +108,17 @@ def main() -> int:
|
|||
facts = json.loads(result["stdout"]) if passed else {}
|
||||
private_state_persisted = persistence["exit_code"] == 0
|
||||
passed = passed and private_state_persisted and teardown["workspace_removed"] == "True"
|
||||
proxy_removed = not egress or (
|
||||
not Path(handle["egress_dir"]).exists()
|
||||
and not extension._pid_alive(int(handle["egress_pid"]))
|
||||
)
|
||||
passed = passed and proxy_removed
|
||||
print(json.dumps({
|
||||
"ok": passed, "sandbox_id": handle["sandbox_id"],
|
||||
"runtime_sha256": args.runtime_sha256, "proof": facts,
|
||||
"workspace_removed": teardown["workspace_removed"] == "True",
|
||||
"exit_code": result["exit_code"], "model_run_proven": False,
|
||||
"private_state_persisted": private_state_persisted,
|
||||
"private_state_persisted": private_state_persisted, "proxy_removed": proxy_removed,
|
||||
}, indent=2))
|
||||
return 0 if passed else 1
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue