Repository navigation
fix: code interprter updates #354
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
+126
−2
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1c6bfb5
fix: refresh code interpreter certificate trust stores
matthewlouisbrockman d8dd71c
fix: use system certificate trust for Node.js
matthewlouisbrockman fe09f19
fix: persist Node trust settings and refresh Java certificates
matthewlouisbrockman b7c6429
fix: clean certificate directory and secure pip upgrades
matthewlouisbrockman 20d2473
fix: remove blocked certificate copies on trust-store refresh
matthewlouisbrockman 5925a04
fix: use the updated Debian certificate package
matthewlouisbrockman 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,3 +42,4 @@ urllib3==2.7.0 | |
| xarray==2025.4.0 | ||
| xlrd==2.0.2 | ||
| sympy==1.14.0 | ||
| certifi==2026.10.19 | ||
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 |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ websockets==12.0 | |
| uvicorn[standard]==0.30.1 | ||
| requests==2.33.0 | ||
| pydantic==2.9.1 | ||
| certifi==2026.10.19 | ||
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,106 @@ | ||
| import json | ||
| import shlex | ||
|
|
||
| import pytest | ||
| from e2b import Sandbox | ||
|
|
||
| from harness import CodeInterpreter | ||
|
|
||
| pytestmark = pytest.mark.skip_debug | ||
|
|
||
| CHECK_CERTIFICATES = """ | ||
| import ssl | ||
| from importlib.metadata import version | ||
| from pathlib import Path | ||
|
|
||
| import certifi | ||
| from pip._vendor import certifi as pip_certifi | ||
|
|
||
| assert tuple(map(int, version('certifi').split('.'))) >= (2026, 10, 19) | ||
| assert tuple(map(int, version('pip').split('.'))) >= (26, 2, 2) | ||
|
|
||
| blocked = {'emSign ECC Root CA - G3', 'AAA Certificate Services'} | ||
| for bundle in (None, certifi.where(), pip_certifi.where()): | ||
| context = ssl.create_default_context(cafile=bundle) | ||
| if bundle is None: | ||
| for path in Path('/etc/ssl/certs').iterdir(): | ||
| if path.is_file(): | ||
| try: | ||
| context.load_verify_locations(cafile=str(path)) | ||
| except ssl.SSLError: | ||
| pass | ||
| certificates = context.get_ca_certs() | ||
| assert certificates, f'Empty trust store: {bundle}' | ||
| names = { | ||
| value | ||
| for certificate in certificates | ||
| for rdn in certificate['subject'] | ||
| for key, value in rdn | ||
| if key == 'commonName' | ||
| } | ||
| assert not names & blocked, f'{bundle}: still trusts {names & blocked}' | ||
| print('Certificate stores verified') | ||
| """ | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("python", ["python", "/root/.server/.venv/bin/python"]) | ||
| def test_certificate_stores(sandbox: Sandbox, python: str): | ||
| result = sandbox.commands.run( | ||
| f"{python} -c {shlex.quote(CHECK_CERTIFICATES)}", user="root" | ||
| ) | ||
| assert result.exit_code == 0 | ||
| assert "Certificate stores verified" in result.stdout | ||
|
|
||
|
|
||
| CHECK_NODE_HTTPS = """ | ||
| (async () => { | ||
| const https = require('node:https'); | ||
| const probe = (host) => new Promise((resolve, reject) => { | ||
| const request = https.get(`https://${host}/`, (response) => { | ||
| response.resume(); | ||
| resolve('connected'); | ||
| }); | ||
| request.setTimeout(15000, () => request.destroy(new Error('TLS probe timed out'))); | ||
| request.on('error', (error) => { | ||
| if (error.code === 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' || | ||
| error.code === 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' || | ||
| error.code === 'SELF_SIGNED_CERT_IN_CHAIN') { | ||
| resolve('untrusted'); | ||
| } else { | ||
| reject(error); | ||
| } | ||
| }); | ||
| }); | ||
| const results = await Promise.all([ | ||
| probe('dv-g3b-emudhra.we-have-a-problem.com'), | ||
| probe('dv-g3b-aaa-emudhra.we-have-a-problem.com'), | ||
| probe('nodejs.org'), | ||
| ]); | ||
| console.log(JSON.stringify(results)); | ||
| })() | ||
| """ | ||
|
|
||
|
|
||
| def test_node_certificate_stores(sandbox: Sandbox, client: CodeInterpreter): | ||
| command = CHECK_NODE_HTTPS | ||
| result = sandbox.commands.run(f"node -e {shlex.quote(command)}") | ||
| assert json.loads(result.stdout) == ["untrusted", "untrusted", "connected"] | ||
|
|
||
| execution = client.run_code("await " + command, language="js") | ||
| assert execution.error is None | ||
| assert json.loads("".join(execution.stdout)) == [ | ||
| "untrusted", | ||
| "untrusted", | ||
| "connected", | ||
| ] | ||
|
|
||
|
|
||
| def test_java_certificate_store(sandbox: Sandbox): | ||
| result = sandbox.commands.run( | ||
| "/usr/lib/jvm/jdk-11/bin/keytool -J-Duser.language=en -list -v -cacerts -storepass changeit", | ||
| user="root", | ||
| ) | ||
| assert result.exit_code == 0 | ||
| assert "trustedCertEntry" in result.stdout | ||
| assert "CN=AAA Certificate Services," not in result.stdout | ||
| assert "CN=emSign ECC Root CA - G3," not in result.stdout |
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.