mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(rds): reject malformed proxy boolean flags (#5453)
This commit is contained in:
1 parent
09a2d5c005
commit
af3672ed0c
3 files changed
+61
-2
No files matched your search
@@ -177,6 +177,13 @@ checked against the instance's other window. Modifications apply immediately —
|
||||
`arn:aws:rds:<region>:<account>:cluster-snapshot:<name>`. RDS reserved instances aren't
|
||||
modeled (there's no reserved-instance API), so tagging doesn't apply to them.
|
||||
|
||||
## DB proxy boolean parameters
|
||||
|
||||
`CreateDBProxy` accepts `true` or `false` (case-insensitive) for `RequireTLS` and
|
||||
`DebugLogging`, defaulting each omitted flag to `false`. Other values, including empty
|
||||
strings, return `InvalidParameterValue` before a proxy is created. `ModifyDBProxy`
|
||||
uses the same boolean parsing and preserves an omitted flag's current value.
|
||||
|
||||
## Event notification subscriptions
|
||||
|
||||
The four subscription actions manage the resource itself. **Nothing is published to the topic.**
|
||||
|
||||
@@ -1786,8 +1786,8 @@ public class RdsQueryHandler {
|
||||
validateDbProxyNetworkType(targetConnectionNetworkType, "TargetConnectionNetworkType", false, "IPV4 or IPV6");
|
||||
String name = params.getFirst("DBProxyName");
|
||||
String engineFamily = params.getFirst("EngineFamily");
|
||||
boolean requireTls = "true".equalsIgnoreCase(params.getFirst("RequireTLS"));
|
||||
boolean debugLogging = "true".equalsIgnoreCase(params.getFirst("DebugLogging"));
|
||||
boolean requireTls = Boolean.TRUE.equals(parseOptionalBoolean(params, "RequireTLS"));
|
||||
boolean debugLogging = Boolean.TRUE.equals(parseOptionalBoolean(params, "DebugLogging"));
|
||||
int idleClientTimeout = 1800;
|
||||
String idleClientTimeoutValue = params.getFirst("IdleClientTimeout");
|
||||
if (idleClientTimeoutValue != null) {
|
||||
|
||||
@@ -1592,6 +1592,58 @@ class RdsQueryHandlerTest {
|
||||
eq(1800), eq(false), eq(Map.of()), eq("us-west-2"), isNull(), isNull());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"RequireTLS", "DebugLogging"})
|
||||
void createDbProxyRejectsMalformedBooleanFlagsBeforeCallingService(String parameter) {
|
||||
when(service.createDbProxy(any(), any(), anyBoolean(), anyBoolean(), any(), any(),
|
||||
anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any(), any(), any()))
|
||||
.thenReturn(new DbProxy());
|
||||
for (String invalid : List.of("yes", "", "1", "0", " true", "false ", "not-a-boolean")) {
|
||||
MultivaluedMap<String, String> p = params();
|
||||
p.putSingle("DBProxyName", "app-proxy");
|
||||
p.putSingle("EngineFamily", "POSTGRESQL");
|
||||
p.putSingle(parameter, invalid);
|
||||
|
||||
Response response = handler.handle("CreateDBProxy", p, "us-west-2");
|
||||
|
||||
assertEquals(400, response.getStatus(), parameter + "=" + invalid);
|
||||
String body = (String) response.getEntity();
|
||||
assertTrue(body.contains("<Code>InvalidParameterValue</Code>"));
|
||||
assertTrue(body.contains(parameter + " must be true or false."));
|
||||
verifyNoInteractions(service);
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@NullSource
|
||||
@ValueSource(strings = {"true", "false", "TrUe", "FaLsE"})
|
||||
void createDbProxyBooleanFlagsPreserveValuesAndDefaults(String value) {
|
||||
boolean enabled = Boolean.parseBoolean(value);
|
||||
DbProxy proxy = new DbProxy();
|
||||
proxy.setRequireTls(enabled);
|
||||
proxy.setDebugLogging(enabled);
|
||||
when(service.createDbProxy(eq("app-proxy"), eq("POSTGRESQL"), eq(enabled), eq(false),
|
||||
isNull(), isNull(), eq(List.of()), eq(List.of()), eq(List.of()), eq(1800),
|
||||
eq(enabled), eq(Map.of()), eq("us-west-2"), isNull(), isNull())).thenReturn(proxy);
|
||||
MultivaluedMap<String, String> p = params();
|
||||
p.putSingle("DBProxyName", "app-proxy");
|
||||
p.putSingle("EngineFamily", "POSTGRESQL");
|
||||
if (value != null) {
|
||||
p.putSingle("RequireTLS", value);
|
||||
p.putSingle("DebugLogging", value);
|
||||
}
|
||||
|
||||
Response response = handler.handle("CreateDBProxy", p, "us-west-2");
|
||||
|
||||
assertEquals(200, response.getStatus());
|
||||
String body = (String) response.getEntity();
|
||||
assertTrue(body.contains("<RequireTLS>" + enabled + "</RequireTLS>"));
|
||||
assertTrue(body.contains("<DebugLogging>" + enabled + "</DebugLogging>"));
|
||||
verify(service).createDbProxy(eq("app-proxy"), eq("POSTGRESQL"), eq(enabled), eq(false),
|
||||
isNull(), isNull(), eq(List.of()), eq(List.of()), eq(List.of()), eq(1800),
|
||||
eq(enabled), eq(Map.of()), eq("us-west-2"), isNull(), isNull());
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDbProxyRejectsInvalidNetworkTypeValuesBeforeCallingService() {
|
||||
// TargetConnectionNetworkType has no DUAL value on real AWS (only EndpointNetworkType does).
|
||||
|
||||
Reference in new issue
Block a user