mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(secretsmanager): validate stage destinations before moving labels (#8112)
UpdateSecretVersionStage removed the label from the old version and only then found that the target version does not exist, so the refused request left the secret without that label. Look the target version up before any label is moved. Validate the attached stage and removal version before checking the destination, keeping both checks ahead of any label mutation. Cover omitted and mismatched removal IDs with missing destinations through the AWS SDK for current and custom stages. Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> Co-authored-by: Andre Kurait <akurait@amazon.com>
This commit is contained in:
1 parent
637e62d0c3
commit
3f1dcc9173
3 files changed
+146
-7
No files matched your search
@@ -1986,7 +1986,16 @@ public class SecretsManagerService implements ResourceProvider {
|
||||
+ "version that currently has the staging label %s.")
|
||||
.formatted(versionStage, currentVersionId), 400);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the destination before any staging label is changed.
|
||||
if (moveToVersionId != null && !secret.getVersions().containsKey(moveToVersionId)) {
|
||||
throw new AwsException("ResourceNotFoundException",
|
||||
"Secrets Manager can't find the specified secret value for VersionId: %s.".formatted(moveToVersionId),
|
||||
400);
|
||||
}
|
||||
|
||||
if (currentVersionId != null) {
|
||||
List<String> mutableStages = new ArrayList<>(secret.getVersions()
|
||||
.get(removeFromVersionId).getVersionStages());
|
||||
mutableStages.remove(versionStage);
|
||||
@@ -2009,13 +2018,6 @@ public class SecretsManagerService implements ResourceProvider {
|
||||
}
|
||||
|
||||
if (moveToVersionId != null) {
|
||||
// check whether it exists
|
||||
if (!secret.getVersions().containsKey(moveToVersionId)) {
|
||||
throw new AwsException("ResourceNotFoundException",
|
||||
"Secrets Manager can't find the specified secret value for VersionId: %s.".formatted(moveToVersionId),
|
||||
400);
|
||||
}
|
||||
|
||||
// we are adding versionStage to this ID
|
||||
List<String> mutableStages = new ArrayList<>(secret.getVersions().get(moveToVersionId).getVersionStages());
|
||||
mutableStages.add(versionStage);
|
||||
|
||||
Reference in new issue
Block a user