fix(rds): reject malformed parameter reset flags (#5454)

This commit is contained in:
David Phillips authored and GitHub committed 2026-10-11 16:32:15 -04:00
1 parent 8c61aa441d
commit 4fd8df2b00
4 files changed
+124 -7

No files matched your search

+12 -5
View File
@@ -177,12 +177,19 @@ 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
## Boolean parameters
The following parameters accept `true` or `false` (case-insensitive). Other values,
including empty strings, return `InvalidParameterValue` before changing resources.
| Actions | Parameters | When omitted |
|---|---|---|
| `CreateDBProxy` | `RequireTLS`, `DebugLogging` | Defaults to `false` |
| `ModifyDBProxy` | `RequireTLS`, `DebugLogging` | Preserves the current value |
| `ResetDBParameterGroup`, `ResetDBClusterParameterGroup` | `ResetAllParameters` | Defaults to `false`; named parameter resets keep their existing behavior |
Malformed reset flags leave saved parameter overrides unchanged.
`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
@@ -1288,7 +1288,7 @@ public class RdsQueryHandler {
}
try {
DbParameterGroup group = service.resetDbParameterGroup(name,
Boolean.parseBoolean(params.getFirst("ResetAllParameters")), parameterNames(params), region);
Boolean.TRUE.equals(parseOptionalBoolean(params, "ResetAllParameters")), parameterNames(params), region);
String result = new XmlBuilder()
.elem("DBParameterGroupName", group.getDbParameterGroupName())
.build();
@@ -1443,7 +1443,7 @@ public class RdsQueryHandler {
}
try {
DbClusterParameterGroup group = service.resetDbClusterParameterGroup(name,
Boolean.parseBoolean(params.getFirst("ResetAllParameters")), parameterNames(params), region);
Boolean.TRUE.equals(parseOptionalBoolean(params, "ResetAllParameters")), parameterNames(params), region);
String result = new XmlBuilder()
.elem("DBClusterParameterGroupName", group.getDbClusterParameterGroupName())
.build();
@@ -6,6 +6,10 @@ import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.util.List;
import static io.restassured.RestAssured.given;
import static io.restassured.http.ContentType.URLENC;
@@ -42,6 +46,48 @@ class RdsParameterGroupCopyResetIntegrationTest {
.formParam("Version", "2014-10-31");
}
@ParameterizedTest
@CsvSource({
"DBParameterGroup, postgres15, reset-boolean-instance",
"DBClusterParameterGroup, aurora-postgresql15, reset-boolean-cluster"
})
void malformedResetAllPreservesParameterOverrides(String groupType, String family, String name) {
String nameParameter = groupType + "Name";
String describeAction = groupType.equals("DBParameterGroup")
? "DescribeDBParameters" : "DescribeDBClusterParameters";
query("Create" + groupType)
.formParam(nameParameter, name)
.formParam("DBParameterGroupFamily", family)
.formParam("Description", "boolean regression")
.when().post("/").then().statusCode(200);
try {
query("Modify" + groupType)
.formParam(nameParameter, name)
.formParam("Parameters.member.1.ParameterName", "max_connections")
.formParam("Parameters.member.1.ParameterValue", "250")
.when().post("/").then().statusCode(200);
for (String invalid : List.of("yes", "", "1", "0", " true", "false ", "not-a-boolean")) {
query("Reset" + groupType)
.formParam(nameParameter, name)
.formParam("ResetAllParameters", invalid)
.formParam("Parameters.Parameter.1.ParameterName", "max_connections")
.formParam("Parameters.Parameter.1.ApplyMethod", "immediate")
.when().post("/").then().statusCode(400)
.body(containsString("<Code>InvalidParameterValue</Code>"))
.body(containsString("ResetAllParameters must be true or false."));
query(describeAction).formParam(nameParameter, name)
.when().post("/").then().statusCode(200)
.body(containsString("<ParameterName>max_connections</ParameterName>"))
.body(containsString("<ParameterValue>250</ParameterValue>"));
}
} finally {
query("Delete" + groupType).formParam(nameParameter, name)
.when().post("/").then().statusCode(200);
}
}
@Test
@Order(1)
void copyDbParameterGroupCarriesFamilyOverridesAndTags() {
@@ -63,6 +63,70 @@ class RdsQueryHandlerTest {
handler = new RdsQueryHandler(service, config, docDbHandler, neptuneHandler);
}
@ParameterizedTest
@CsvSource({
"ResetDBParameterGroup, DBParameterGroupName",
"ResetDBClusterParameterGroup, DBClusterParameterGroupName"
})
void parameterResetRejectsMalformedBooleanBeforeServiceCalls(String action, String nameParameter) {
DbParameterGroup instanceGroup = new DbParameterGroup();
instanceGroup.setDbParameterGroupName("custom-group");
DbClusterParameterGroup clusterGroup = new DbClusterParameterGroup();
clusterGroup.setDbClusterParameterGroupName("custom-group");
when(service.resetDbParameterGroup(any(), anyBoolean(), anyList(), any())).thenReturn(instanceGroup);
when(service.resetDbClusterParameterGroup(any(), anyBoolean(), anyList(), any())).thenReturn(clusterGroup);
for (String invalid : List.of("yes", "", "1", "0", " true", "false ", "not-a-boolean")) {
MultivaluedMap<String, String> p = params();
p.putSingle(nameParameter, "custom-group");
p.putSingle("ResetAllParameters", invalid);
p.putSingle("Parameters.Parameter.1.ParameterName", "max_connections");
Response response = handler.handle(action, p, "us-west-2");
assertEquals(400, response.getStatus(), action + ": " + invalid);
String body = (String) response.getEntity();
assertTrue(body.contains("<Code>InvalidParameterValue</Code>"));
assertTrue(body.contains("ResetAllParameters must be true or false."));
verifyNoInteractions(service);
}
}
@ParameterizedTest
@NullSource
@ValueSource(strings = {"true", "false", "TrUe", "FaLsE"})
void parameterResetPreservesBooleanValuesAndOmission(String value) {
boolean resetAll = Boolean.parseBoolean(value);
DbParameterGroup instanceGroup = new DbParameterGroup();
instanceGroup.setDbParameterGroupName("custom-group");
DbClusterParameterGroup clusterGroup = new DbClusterParameterGroup();
clusterGroup.setDbClusterParameterGroupName("custom-group");
List<String> names = resetAll ? List.of() : List.of("max_connections");
when(service.resetDbParameterGroup("custom-group", resetAll, names, "us-west-2"))
.thenReturn(instanceGroup);
when(service.resetDbClusterParameterGroup("custom-group", resetAll, names, "us-west-2"))
.thenReturn(clusterGroup);
for (String nameParameter : List.of("DBParameterGroupName", "DBClusterParameterGroupName")) {
String action = nameParameter.equals("DBParameterGroupName")
? "ResetDBParameterGroup" : "ResetDBClusterParameterGroup";
MultivaluedMap<String, String> p = params();
p.putSingle(nameParameter, "custom-group");
if (value != null) {
p.putSingle("ResetAllParameters", value);
}
if (!resetAll) {
p.putSingle("Parameters.Parameter.1.ParameterName", "max_connections");
}
Response response = handler.handle(action, p, "us-west-2");
assertEquals(200, response.getStatus());
assertTrue(((String) response.getEntity()).contains("<" + nameParameter
+ ">custom-group</" + nameParameter + ">"));
}
verify(service).resetDbParameterGroup("custom-group", resetAll, names, "us-west-2");
verify(service).resetDbClusterParameterGroup("custom-group", resetAll, names, "us-west-2");
}
@ParameterizedTest
@CsvSource({
"CreateDBInstance, MultiAZ",