Fix critical and high audit findings
Fixed findings from the audit reports (SECURITY, QUALITY, PERFORMANCE): - P-001 · Dashboard re-downloads the entire dataset every 5 seconds Re-synced the vendored shared/ snapshot from shared commit 199a5ef. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7dd0d34383
commit
a84a36349b
31 files changed
+653
-6055
No files matched your search
+5
-1
@@ -715,9 +715,13 @@ public final class AuthClient {
|
||||
if (candidate.startsWith(prefix)) {
|
||||
String value = candidate.substring(prefix.length());
|
||||
try {
|
||||
return URLDecoder.decode(value, StandardCharsets.UTF_8.name());
|
||||
// URLDecoder would turn a literal "+" into a space; escape it first so it survives, as in Node.
|
||||
return URLDecoder.decode(value.replace("+", "%2B"), StandardCharsets.UTF_8.name());
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
return value;
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// A malformed escape such as a bare "%" is not a usable token, so treat the cookie as absent.
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+28
@@ -218,6 +218,34 @@ class AuthClientTest {
|
||||
assertEquals("right", token);
|
||||
}
|
||||
|
||||
@Test
|
||||
void extractTokenKeepsALiteralPlusSignInTheCookieValue() {
|
||||
AuthClient client = new AuthClient("https://auth.example.com");
|
||||
|
||||
String token = client.extractToken(name -> null, "auth_session=ab+cd%2Bef");
|
||||
|
||||
assertEquals("ab+cd+ef", token);
|
||||
}
|
||||
|
||||
@Test
|
||||
void extractTokenTreatsAMalformedCookieEscapeAsNoToken() {
|
||||
AuthClient client = new AuthClient("https://auth.example.com");
|
||||
|
||||
String token = client.extractToken(name -> null, "auth_session=bad%zz; other=1");
|
||||
|
||||
assertEquals("", token);
|
||||
}
|
||||
|
||||
@Test
|
||||
void middlewareFailsClosedOnAMalformedCookieInsteadOfThrowing() throws Exception {
|
||||
AuthClient client = new AuthClient("https://auth.example.com");
|
||||
|
||||
String result = client.middleware(name -> null, "auth_session=100%",
|
||||
user -> "authenticated", () -> "unauthorized");
|
||||
|
||||
assertEquals("unauthorized", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void middlewareFailsClosedAndDoesNotInvokeTheHandlerOnAnInvalidSession() throws Exception {
|
||||
server = fakeAuthGuard(401, "{\"valid\":false}");
|
||||
|
||||
Reference in new issue
Block a user