fix(security): replace Math.random with crypto.randomUUID in generateTaskId/ActivityId and fix URL hostname check in test (#2461) (#2489)

Co-authored-by: diegosouzapw <diego.souza.pw@gmail.com>
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-05-21 10:35:24 -03:00
committed by GitHub
parent 4f70ef3d2a
commit 0ade48bd04
2 changed files with 3 additions and 3 deletions

View File

@@ -86,10 +86,10 @@ export abstract class CloudAgentBase {
}
protected generateTaskId(): string {
return `task_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
return `task_${Date.now()}_${crypto.randomUUID().replace(/-/g, "").substring(0, 9)}`;
}
protected generateActivityId(): string {
return `act_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
return `act_${Date.now()}_${crypto.randomUUID().replace(/-/g, "").substring(0, 9)}`;
}
}

View File

@@ -152,7 +152,7 @@ describe("ensureAntigravityProjectAssigned", () => {
const mockFetch = async (url: string, _init?: RequestInit): Promise<Response> => {
hitUrls.push(url);
if (url.includes("daily-cloudcode-pa.googleapis.com")) {
if (new URL(url).hostname === "daily-cloudcode-pa.googleapis.com") {
// First URL fails
return new Response("not found", { status: 404 });
}