mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
fix(security): resolve SSRF lint errors
This commit is contained in:
@@ -35,6 +35,7 @@ import {
|
||||
isPrivateIpAsync,
|
||||
safeLookup,
|
||||
isLoopbackHost,
|
||||
safeFetch,
|
||||
} from '../utils/fetch.js';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
|
||||
@@ -58,11 +59,6 @@ interface InternalGrpcExtensions {
|
||||
grpcChannelOptions: Record<string, unknown>;
|
||||
}
|
||||
|
||||
// Local extension of RequestInit to support Node.js/undici dispatcher
|
||||
interface NodeFetchInit extends RequestInit {
|
||||
dispatcher?: UndiciAgent;
|
||||
}
|
||||
|
||||
// Remote agents can take 10+ minutes (e.g. Deep Research).
|
||||
// Use a dedicated dispatcher so the global 5-min timeout isn't affected.
|
||||
const A2A_TIMEOUT = 1800000; // 30 minutes
|
||||
@@ -74,10 +70,8 @@ const a2aDispatcher = new UndiciAgent({
|
||||
lookup: safeLookup,
|
||||
},
|
||||
});
|
||||
const a2aFetch: typeof fetch = (input, init) => {
|
||||
const nodeInit: NodeFetchInit = { ...init, dispatcher: a2aDispatcher };
|
||||
return fetch(input, nodeInit as RequestInit);
|
||||
};
|
||||
const a2aFetch: typeof fetch = (input, init) =>
|
||||
safeFetch(input, { ...init, dispatcher: a2aDispatcher });
|
||||
|
||||
/**
|
||||
* Orchestrates communication with remote A2A agents.
|
||||
|
||||
@@ -240,16 +240,16 @@ function handleFetchError(error: unknown, url: string): never {
|
||||
*/
|
||||
export async function safeFetch(
|
||||
input: RequestInfo | URL,
|
||||
init?: RequestInit,
|
||||
init?: NodeFetchInit,
|
||||
): Promise<Response> {
|
||||
const nodeInit: NodeFetchInit = {
|
||||
...init,
|
||||
dispatcher: safeDispatcher,
|
||||
...init,
|
||||
};
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
return await fetch(input, nodeInit);
|
||||
return await fetch(input, nodeInit as RequestInit);
|
||||
} catch (error) {
|
||||
const url =
|
||||
input instanceof Request
|
||||
|
||||
Reference in New Issue
Block a user