-
-
Notifications
You must be signed in to change notification settings - Fork 6
🔙 Backport Support talking to Colab from the JKC #34
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
Changes from all commits
e155fff
89066e2
9194e6e
841526b
bbf47ba
3c31bd4
251e71e
7f3258e
d93ec59
beb6355
57fda74
f18e982
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |||||
| from __future__ import annotations | ||||||
|
|
||||||
| import datetime | ||||||
| import logging | ||||||
| import os | ||||||
| import re | ||||||
| import typing as t | ||||||
|
|
@@ -30,13 +31,12 @@ def fetch( | |||||
| """Fetch a network resource as a context manager.""" | ||||||
| method = kwargs.pop("method", "GET") | ||||||
| f = getattr(requests, method.lower()) | ||||||
| headers = kwargs.pop("headers", {}) | ||||||
| if len(headers) == 0: | ||||||
| headers = { | ||||||
| "Accept": "application/json", | ||||||
| "Content-Type": "application/json", | ||||||
| "User-Agent": "Jupyter kernels CLI", | ||||||
| } | ||||||
| headers = { | ||||||
| "Accept": "application/json", | ||||||
| "Content-Type": "application/json", | ||||||
| "User-Agent": "Jupyter Kernel Client" | ||||||
|
||||||
| "User-Agent": "Jupyter Kernel Client" | |
| "User-Agent": "Jupyter kernels CLI" |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The headers parameter allows arbitrary headers to be passed without validation. This could potentially allow malicious headers to be injected if the headers come from untrusted sources. Consider adding validation or documentation about the security implications of passing custom headers.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
|
|
||
| # Copyright (c) 2023-2024 Datalayer, Inc. | ||
| # Copyright (c) 2025 Google | ||
| # | ||
| # BSD 3-Clause License | ||
|
|
||
| from jupyter_kernel_client.manager import KernelHttpManager | ||
| from jupyter_kernel_client import KernelClient | ||
|
|
||
|
|
||
| def test_list_kernels(jupyter_server): | ||
| port, token = jupyter_server | ||
|
|
||
| # Start a kernel to ensure the list is not empty | ||
| with KernelClient(server_url=f"http://localhost:{port}", token=token) as kernel: | ||
| kernel_id = kernel.id | ||
| # The manager is created after the kernel is started to ensure we can list it. | ||
| manager = KernelHttpManager(server_url=f"http://localhost:{port}", token=token) | ||
| kernels = manager.list_kernels() | ||
|
|
||
| assert isinstance(kernels, list) | ||
| assert len(kernels) > 0 | ||
|
|
||
| # Check that the kernel we started is in the list | ||
| found = False | ||
| for k in kernels: | ||
| assert "id" in k | ||
| assert "name" in k | ||
| if k["id"] == kernel_id: | ||
| found = True | ||
|
|
||
| assert found, f"Kernel with id {kernel_id} not found in the list of running kernels." | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'logging' is not used.