feat(server): harden hostile input and overload behavior (#15)
quality-gate / quality (push) Failing after 1m5s

This commit is contained in:
KyuubiYoru
2026-07-16 12:37:38 +02:00
parent 2ff7cd6d9d
commit 88ef946af5
22 changed files with 2159 additions and 93 deletions
@@ -149,5 +149,45 @@ public sealed class OpenApiCompatibilityTests
parameter.GetProperty("in").GetString() == "header"
&& parameter.GetProperty("name").GetString() == "X-Rendezvous-Lease-Token");
Assert.True(leaseToken.GetProperty("required").GetBoolean());
int overloadContracts = 0;
foreach (JsonProperty pathItem in root.GetProperty("paths").EnumerateObject())
{
foreach (JsonProperty operation in pathItem.Value.EnumerateObject().Where(
static item => item.Name is "get" or "post" or "put" or "delete"))
{
JsonElement responses = operation.Value.GetProperty("responses");
if (!responses.TryGetProperty("429", out JsonElement overloaded))
{
continue;
}
overloadContracts++;
JsonElement retryAfter = overloaded.GetProperty("headers")
.GetProperty("Retry-After");
Assert.Equal(
"integer",
retryAfter.GetProperty("schema").GetProperty("type").GetString());
}
}
Assert.Equal(12, overloadContracts);
(string Path, string Method)[] bodyOperations =
[
("/v1/sessions", "post"),
("/v1/sessions/{listingId}/renew", "post"),
("/v1/sessions/{listingId}", "put"),
("/v1/sessions/{listingId}", "delete"),
("/v1/join-attempts", "post"),
("/v1/join-attempts/{attemptId}/outcome", "post"),
];
foreach ((string operationPath, string method) in bodyOperations)
{
Assert.True(root.GetProperty("paths")
.GetProperty(operationPath)
.GetProperty(method)
.GetProperty("responses")
.TryGetProperty("413", out _));
}
}
}