Skip to content

Commit e1fdbc6

Browse files
Potential fix for code scanning alert no. 4: Incomplete URL substring sanitization
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 5ae4573 commit e1fdbc6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/cache-handlers/test/deno/security.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ Deno.test("Security - Extremely long cache keys", () => {
4545

4646
// Should not throw and should handle gracefully
4747
const cacheKey = defaultGetCacheKey(request);
48+
const parsedUrl = new URL(cacheKey);
4849
assert(
49-
cacheKey.startsWith("https://example.com"),
50-
"Cache key should start with origin",
50+
parsedUrl.host === "example.com",
51+
"Cache key should have host 'example.com'",
5152
);
5253
assert(cacheKey.length > 100000, "Cache key should be long");
5354
});
@@ -75,9 +76,10 @@ Deno.test("Security - Vary header bomb attack", () => {
7576

7677
// Should complete in reasonable time (less than 100ms)
7778
assert(duration < 100, `Cache key generation took too long: ${duration}ms`);
79+
const parsedUrl = new URL(cacheKey);
7880
assert(
79-
cacheKey.startsWith("https://example.com"),
80-
"Cache key should start with origin",
81+
parsedUrl.host === "example.com",
82+
"Cache key should have host 'example.com'",
8183
);
8284
});
8385

0 commit comments

Comments
 (0)