File tree Expand file tree Collapse file tree 5 files changed +15
-6
lines changed
DynamoDbEncryption/dafny/DynamoDbEncryptionTransforms/src Expand file tree Collapse file tree 5 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ module BatchWriteItemTransform {
32
32
// = specification/dynamodb-encryption-client/ddb-sdk-integration.md#encrypt-before-batchwriteitem
33
33
// # If the table name does not refer to an [encrypted-table](#encrypted-table),
34
34
// # the list of operations MUST be unchanged.
35
- if tableName in config. tableEncryptionConfigs {
35
+ if ! IsPlainWrite ( config, tableName) {
36
36
var tableConfig := config. tableEncryptionConfigs[tableName];
37
37
var encryptedItems : seq < DDB. WriteRequest> := [];
38
38
for x := 0 to |writeRequests|
Original file line number Diff line number Diff line change @@ -16,9 +16,17 @@ module DdbMiddlewareConfig {
16
16
partitionKeyName: string ,
17
17
sortKeyName: Option <string >,
18
18
itemEncryptor: DynamoDbItemEncryptor .DynamoDbItemEncryptorClient,
19
- search : Option <SearchableEncryptionInfo .ValidSearchInfo>
19
+ search : Option <SearchableEncryptionInfo .ValidSearchInfo>,
20
+ plaintextOverride: AwsCryptographyDbEncryptionSdkDynamoDbTypes .PlaintextOverride
20
21
)
21
22
23
+ // return true if records written to the table should NOT be encrypted or otherwise modified
24
+ predicate method IsPlainWrite (config : Config , tableName : string )
25
+ {
26
+ || tableName ! in config. tableEncryptionConfigs
27
+ || config. tableEncryptionConfigs[tableName]. plaintextOverride == AwsCryptographyDbEncryptionSdkDynamoDbTypes. PlaintextOverride. FORCE_PLAINTEXT_WRITE_ALLOW_PLAINTEXT_READ
28
+ }
29
+
22
30
predicate ValidTableConfig?(config: TableConfig) {
23
31
var encryptorConfig := config. itemEncryptor. config;
24
32
&& config. logicalTableName == encryptorConfig. logicalTableName
Original file line number Diff line number Diff line change @@ -199,7 +199,8 @@ module
199
199
partitionKeyName := inputConfig.partitionKeyName,
200
200
sortKeyName := inputConfig.sortKeyName,
201
201
itemEncryptor := itemEncryptor,
202
- search := search
202
+ search := search,
203
+ plaintextOverride := inputConfig.plaintextOverride.UnwrapOr(AwsCryptographyDbEncryptionSdkDynamoDbTypes.PlaintextOverride.FORBID_PLAINTEXT_WRITE_FORBID_PLAINTEXT_READ)
203
204
);
204
205
205
206
internalConfigs := internalConfigs[tableName := internalConfig];
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ module PutItemTransform {
26
26
ensures output. Success? && input. sdkInput. TableName ! in config. tableEncryptionConfigs ==>
27
27
output. value. transformedInput == input. sdkInput
28
28
29
- ensures output. Success? && input. sdkInput. TableName in config . tableEncryptionConfigs ==>
29
+ ensures output. Success? && ! IsPlainWrite (config, input.sdkInput.TableName) ==>
30
30
&& var tableConfig := config. tableEncryptionConfigs[input. sdkInput. TableName];
31
31
// = specification/dynamodb-encryption-client/ddb-sdk-integration.md#encrypt-before-putitem
32
32
// = type=implication
@@ -55,7 +55,7 @@ module PutItemTransform {
55
55
input.sdkInput.ExpressionAttributeValues). Success?
56
56
57
57
{
58
- if input. sdkInput. TableName ! in config . tableEncryptionConfigs {
58
+ if IsPlainWrite (config, input.sdkInput.TableName) {
59
59
return Success (PutItemInputTransformOutput(transformedInput := input.sdkInput));
60
60
}
61
61
var tableConfig := config. tableEncryptionConfigs[input. sdkInput. TableName];
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ module TransactWriteItemsTransform {
75
75
item.Update.value.ExpressionAttributeValues);
76
76
}
77
77
78
- if item. Put. Some? && item. Put. value. TableName in config . tableEncryptionConfigs {
78
+ if item. Put. Some? && ! IsPlainWrite (config, item.Put.value.TableName) {
79
79
var tableConfig := config. tableEncryptionConfigs[item. Put. value. TableName];
80
80
81
81
// = specification/dynamodb-encryption-client/ddb-sdk-integration.md#encrypt-before-transactwriteitems
You can’t perform that action at this time.
0 commit comments