Skip to content

Commit dc4c03f

Browse files
committed
fix(BKSA): Mutations MUST NOT default to HV-1
1 parent cb9347b commit dc4c03f

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/src/AwsCryptographyKeyStoreAdminOperations.dfy

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ module AwsCryptographyKeyStoreAdminOperations refines AbstractAwsCryptographyKey
204204
return Success(internal);
205205
}
206206

207-
method ResolveHierarchyVersion(
207+
method ResolveHierarchyVersionForCreateKey(
208208
hierarchyVersion?: Option<KeyStoreTypes.HierarchyVersion>,
209209
config: InternalConfig
210210
)
@@ -279,7 +279,7 @@ module AwsCryptographyKeyStoreAdminOperations refines AbstractAwsCryptographyKey
279279
// See Smithy-Dafny : https://github.com/smithy-lang/smithy-dafny/pull/543
280280
assume {:axiom} legacyConfig.kmsClient.Modifies < MutationLie();
281281

282-
var hvInput :- ResolveHierarchyVersion(input.HierarchyVersion, config);
282+
var hvInput :- ResolveHierarchyVersionForCreateKey(input.HierarchyVersion, config);
283283
:- Need(
284284
hvInput.v1?,
285285
Types.KeyStoreAdminException(message :="Only hierarchy-version-1 is supported at this time.")
@@ -349,11 +349,12 @@ module AwsCryptographyKeyStoreAdminOperations refines AbstractAwsCryptographyKey
349349
Types.KeyStoreAdminException(message := "At this time, Mutations do not support KeyManagementStrategy#AwsKmsSimple.")
350350
);
351351

352-
var hvInput :- ResolveHierarchyVersion(input.Mutations.TerminalHierarchyVersion, config);
353-
:- Need(
354-
hvInput.v1?,
355-
Types.KeyStoreAdminException(message :="Only hierarchy-version-1 is supported at this time.")
356-
);
352+
if (
353+
&& input.Mutations.TerminalHierarchyVersion.Some?
354+
&& input.Mutations.TerminalHierarchyVersion.value.v2?
355+
) {
356+
return Failure(Types.KeyStoreAdminException(message :="At this time, Mutations do not support mutations to hierarchy-version-2."));
357+
}
357358
var internalInput := KSAInitializeMutation.InternalInitializeMutationInput(
358359
Identifier := input.Identifier,
359360
Mutations := input.Mutations,

AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStoreAdmin/test/AdminFixtures.dfy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ module {:options "/functionSyntax:4" } AdminFixtures {
176176
requires DDB.Types.IsValid_TableName(physicalName)
177177
requires UTF8.IsASCIIString(physicalName) && UTF8.IsASCIIString(logicalName)
178178
// Either the keyValue is NOT reserved, or this is violating a reserved attribute
179-
requires !violateReservedAttribute || keyValue.key !in Structure.BRANCH_KEY_RESTRICTED_FIELD_NAMES
179+
requires violateReservedAttribute || keyValue.key !in Structure.BRANCH_KEY_RESTRICTED_FIELD_NAMES
180180
requires DDB.Types.IsValid_AttributeName(keyValue.key)
181181
requires ddbClient?.Some? ==> ddbClient?.value.ValidState()
182182
modifies (if ddbClient?.Some? then ddbClient?.value.Modifies else {})
@@ -217,7 +217,7 @@ module {:options "/functionSyntax:4" } AdminFixtures {
217217
modifies kmsClient.Modifies
218218
ensures kmsClient.ValidState()
219219
// Either the keyValue is NOT reserved, or this is violating a reserved attribute
220-
requires !violateReservedAttribute || keyValue.key !in Structure.BRANCH_KEY_RESTRICTED_FIELD_NAMES
220+
requires violateReservedAttribute || keyValue.key !in Structure.BRANCH_KEY_RESTRICTED_FIELD_NAMES
221221
requires DDB.Types.IsValid_AttributeName(keyValue.key)
222222
requires DDB.Types.IsValid_TableName(physicalName)
223223
{

0 commit comments

Comments
 (0)