Skip to content

Commit e4f3dfe

Browse files
authored
chore: Refactor to build into single artifact (#74)
1 parent 7b7f5c4 commit e4f3dfe

File tree

481 files changed

+5043
-7067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

481 files changed

+5043
-7067
lines changed

.github/workflows/ci_test_java.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ jobs:
1212
strategy:
1313
matrix:
1414
library: [
15-
StructuredEncryption,
16-
DynamoDbItemEncryptor,
17-
DynamoDbEncryptionMiddlewareInternal,
1815
DynamoDbEncryption,
1916
]
2017
java-version: [ 8, 11, 16, 17 ]
@@ -49,7 +46,7 @@ jobs:
4946
AUTH="$(echo -n "pat:${PRIVATE_ESDK_PAT}" | base64 | tr -d '\n')"
5047
git config --global http.https://github.com/.extraheader "AUTHORIZATION: basic $AUTH"
5148
git config --global --add url.https://github.com/.insteadOf [email protected]:
52-
git submodule update --init --recursive private-aws-encryption-sdk-dafny-staging
49+
git submodule update --init --recursive submodules/MaterialProviders
5350
5451
# Set up env vars for CodeArtifact
5552
- name: Set Up Env Vars for CodeArtifact

.github/workflows/ci_test_net.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
library: [
15-
DynamoDbEncryptionMiddlewareInternal,
16-
DynamoDbItemEncryptor,
17-
StructuredEncryption,
15+
DynamoDbEncryption,
1816
]
1917
dotnet-version: [ '6.0.x' ]
2018
os: [
@@ -43,7 +41,7 @@ jobs:
4341
AUTH="$(echo -n "pat:${PRIVATE_ESDK_PAT}" | base64 | tr -d '\n')"
4442
git config --global http.https://github.com/.extraheader "AUTHORIZATION: basic $AUTH"
4543
git config --global --add url.https://github.com/.insteadOf [email protected]:
46-
git submodule update --init --recursive private-aws-encryption-sdk-dafny-staging
44+
git submodule update --init --recursive submodules/MaterialProviders
4745
4846
- name: Setup Dafny
4947
uses: dafny-lang/[email protected]

.github/workflows/ci_verification.yml

+10-7
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ jobs:
1111
verification:
1212
strategy:
1313
matrix:
14-
library: [
15-
DynamoDbEncryptionMiddlewareInternal,
14+
# Break up verification between namespaces over multiple
15+
# actions to take advantage of parallelization
16+
namespace: [
17+
DynamoDbEncryption,
18+
DynamoDbEncryptionTransforms,
1619
DynamoDbItemEncryptor,
17-
StructuredEncryption,
20+
StructuredEncryption
1821
]
1922
os: [
2023
macos-latest,
@@ -34,7 +37,7 @@ jobs:
3437
AUTH="$(echo -n "pat:${PRIVATE_ESDK_PAT}" | base64 | tr -d '\n')"
3538
git config --global http.https://github.com/.extraheader "AUTHORIZATION: basic $AUTH"
3639
git config --global --add url.https://github.com/.insteadOf [email protected]:
37-
git submodule update --init --recursive private-aws-encryption-sdk-dafny-staging
40+
git submodule update --init --recursive submodules/MaterialProviders
3841
3942
- name: Setup Dafny
4043
uses: dafny-lang/setup-dafny-action@v1
@@ -43,14 +46,14 @@ jobs:
4346

4447
- name: Verify ${{ matrix.library }} Dafny code
4548
shell: bash
46-
working-directory: ./${{ matrix.library }}
49+
working-directory: ./DynamoDbEncryption
4750
run: |
4851
# This works because `node` is installed by default on GHA runners
4952
CORES=$(node -e 'console.log(os.cpus().length)')
50-
make verify CORES=$CORES
53+
make verify_namespace CORES=$CORES SMITHY_NAMESPACE=${{ matrix.namespace }}
5154
5255
- name: Check solver resource use
5356
shell: bash
54-
working-directory: ./${{ matrix.library }}
57+
working-directory: ./DynamoDbEncryption
5558
run: |
5659
make dafny-reportgenerator

.gitmodules

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "polymorph"]
2-
path = polymorph
3-
url = [email protected]:awslabs/polymorph.git
4-
[submodule "private-aws-encryption-sdk-dafny-staging"]
5-
path = private-aws-encryption-sdk-dafny-staging
1+
[submodule "submodules/MaterialProviders"]
2+
path = submodules/MaterialProviders
63
url = [email protected]:aws/private-aws-encryption-sdk-dafny-staging.git

DynamoDbEncryption/Makefile

+63-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,70 @@
11
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
5-
DEPS_DIR:=$(ROOT_DIR)/../private-aws-encryption-sdk-dafny-staging
4+
CORES=2
65

7-
build_java_dependencies:
8-
$(MAKE) -C $(ROOT_DIR)/../DynamoDbEncryptionMiddlewareInternal build_java
9-
$(MAKE) -C $(ROOT_DIR)/../DynamoDbEncryptionMiddlewareInternal mvn_local_deploy
6+
include ../SharedMakefile.mk
107

11-
build_java: build_java_dependencies
12-
gradle -p runtimes/java build
8+
SMITHY_NAMESPACES := \
9+
aws.cryptography.structuredEncryption \
10+
aws.cryptography.dynamoDbEncryption \
11+
aws.cryptography.dynamoDbEncryption.itemEncryptor \
12+
aws.cryptography.dynamoDbEncryption.transforms
13+
MAX_RESOURCE_COUNT=10000000
14+
# Order is important
15+
# In java they MUST be built
16+
# in the order they depend on each other
17+
LIBRARIES := \
18+
submodules/MaterialProviders/AwsCryptographyPrimitives \
19+
submodules/MaterialProviders/ComAmazonawsKms \
20+
submodules/MaterialProviders/ComAmazonawsDynamodb \
21+
submodules/MaterialProviders/AwsCryptographicMaterialProviders
22+
STD_LIBRARY=submodules/MaterialProviders/StandardLibrary
23+
SMITHY_DEPS=submodules/MaterialProviders/model
1324

14-
mvn_local_deploy:
15-
gradle -p runtimes/java publishToMavenLocal
25+
format_net:
26+
pushd runtimes/net && dotnet format DynamoDbEncryption.csproj && popd
1627

17-
test_java:
18-
gradle -p runtimes/java test
28+
# Transpiling the entire project can take a while (~10 minutes),
29+
# So these custom written targets can be used to short-circuit the process
30+
# and only transpile Dafny code for a specific namespace,
31+
# e.g. No transpiling other namespaces
32+
# and no transpiling and deploying dependencies.
33+
# Note that these targets don't do any sort of 'clean'.
34+
# If you are adding/renaming files, you should use `make build_java` first,
35+
# and then can use these targets if you need to re-transpile after making
36+
# smaller adjustments.
37+
# TODO Improve/Generalize these targets into the SharedMakefile
38+
transpile_impl_namespace_%: TARGET=java
39+
transpile_impl_namespace_%: OUT=runtimes/java/ImplementationFromDafny
40+
transpile_impl_namespace_%:
41+
dafny \
42+
-vcsCores:$(CORES) \
43+
-compileTarget:$(TARGET) \
44+
-spillTargetCode:3 \
45+
-compile:0 \
46+
-optimizeErasableDatatypeWrapper:0 \
47+
-useRuntimeLib \
48+
-out $(OUT) \
49+
./src/$*/Index.dfy \
50+
-library:$(PROJECT_ROOT)/$(STD_LIBRARY)/src/Index.dfy \
51+
$(patsubst %, -library:$(PROJECT_ROOT)/%/src/Index.dfy, $(LIBRARIES));
52+
cp -R runtimes/java/ImplementationFromDafny-java/* runtimes/java/src/main/dafny-generated
53+
rm -rf runtimes/java/ImplementationFromDafny-java/
54+
55+
transpile_test_namespace_%: TARGET=java
56+
transpile_test_namespace_%: OUT=runtimes/java/TestsFromDafny
57+
transpile_test_namespace_%:
58+
dafny \
59+
-vcsCores:$(CORES) \
60+
-compileTarget:$(TARGET) \
61+
-spillTargetCode:3 \
62+
-runAllTests:1 \
63+
-compile:0 \
64+
-optimizeErasableDatatypeWrapper:0 \
65+
-useRuntimeLib \
66+
-out $(OUT) \
67+
`find ./test/$* -name '*.dfy'` \
68+
-library:src/Index.dfy;
69+
cp -R runtimes/java/TestsFromDafny-java/* runtimes/java/src/test/dafny-generated
70+
rm -rf runtimes/java/TestsFromDafny-java

DynamoDbItemEncryptor/Model/AwsCryptographyDynamoDbItemEncryptorTypes.dfy renamed to DynamoDbEncryption/Model/AwsCryptographyDynamoDbEncryptionItemEncryptorTypes.dfy

+15-61
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
4-
include "../../private-aws-encryption-sdk-dafny-staging/StandardLibrary/src/Index.dfy"
5-
include "../../StructuredEncryption/src/Index.dfy"
6-
include "../../private-aws-encryption-sdk-dafny-staging/AwsCryptographicMaterialProviders/src/Index.dfy"
7-
include "../../private-aws-encryption-sdk-dafny-staging/AwsCryptographyPrimitives/src/Index.dfy"
8-
include "../../private-aws-encryption-sdk-dafny-staging/ComAmazonawsDynamodb/src/Index.dfy"
9-
module {:extern "Dafny.Aws.Cryptography.DynamoDbItemEncryptor.Types" } AwsCryptographyDynamoDbItemEncryptorTypes
4+
include "../../submodules/MaterialProviders/StandardLibrary/src/Index.dfy"
5+
include "../src/Index.dfy"
6+
include "../../submodules/MaterialProviders/AwsCryptographicMaterialProviders/src/Index.dfy"
7+
include "../../submodules/MaterialProviders/AwsCryptographyPrimitives/src/Index.dfy"
8+
include "../../submodules/MaterialProviders/ComAmazonawsDynamodb/src/Index.dfy"
9+
module {:extern "Dafny.Aws.Cryptography.DynamoDbEncryption.ItemEncryptor.Types" } AwsCryptographyDynamoDbEncryptionItemEncryptorTypes
1010
{
1111
import opened Wrappers
1212
import opened StandardLibrary.UInt
1313
import opened UTF8
14-
import AwsCryptographyStructuredEncryptionTypes
14+
import AwsCryptographyDynamoDbEncryptionTypes
1515
import AwsCryptographyMaterialProvidersTypes
1616
import AwsCryptographyPrimitivesTypes
1717
import ComAmazonawsDynamodbTypes
@@ -20,7 +20,6 @@ include "../../private-aws-encryption-sdk-dafny-staging/StandardLibrary/src/Inde
2020

2121
// Begin Generated Types
2222

23-
type AttributeActions = map<ComAmazonawsDynamodbTypes.AttributeName, AwsCryptographyStructuredEncryptionTypes.CryptoAction>
2423
datatype DecryptItemInput = | DecryptItemInput (
2524
nameonly encryptedItem: ComAmazonawsDynamodbTypes.AttributeMap
2625
)
@@ -97,72 +96,27 @@ include "../../private-aws-encryption-sdk-dafny-staging/StandardLibrary/src/Inde
9796
nameonly tableName: ComAmazonawsDynamodbTypes.TableName ,
9897
nameonly partitionKeyName: ComAmazonawsDynamodbTypes.KeySchemaAttributeName ,
9998
nameonly sortKeyName: Option<ComAmazonawsDynamodbTypes.KeySchemaAttributeName> ,
100-
nameonly attributeActions: AttributeActions ,
99+
nameonly attributeActions: AwsCryptographyDynamoDbEncryptionTypes.AttributeActions ,
101100
nameonly allowedUnauthenticatedAttributes: Option<ComAmazonawsDynamodbTypes.AttributeNameList> ,
102101
nameonly allowedUnauthenticatedAttributePrefix: Option<string> ,
103102
nameonly algorithmSuiteId: Option<AwsCryptographyMaterialProvidersTypes.DBEAlgorithmSuiteId> ,
104103
nameonly keyring: Option<AwsCryptographyMaterialProvidersTypes.IKeyring> ,
105104
nameonly cmm: Option<AwsCryptographyMaterialProvidersTypes.ICryptographicMaterialsManager> ,
106-
nameonly legacyConfig: Option<LegacyConfig>
105+
nameonly legacyConfig: Option<AwsCryptographyDynamoDbEncryptionTypes.LegacyConfig>
107106
)
108107
datatype EncryptItemInput = | EncryptItemInput (
109108
nameonly plaintextItem: ComAmazonawsDynamodbTypes.AttributeMap
110109
)
111110
datatype EncryptItemOutput = | EncryptItemOutput (
112111
nameonly encryptedItem: ComAmazonawsDynamodbTypes.AttributeMap
113112
)
114-
datatype LegacyConfig = | LegacyConfig (
115-
nameonly policy: LegacyPolicy ,
116-
nameonly encryptor: ILegacyDynamoDbEncryptor ,
117-
nameonly attributeFlags: AttributeActions ,
118-
nameonly defaultAttributeFlag: Option<AwsCryptographyStructuredEncryptionTypes.CryptoAction>
119-
)
120-
class ILegacyDynamoDbEncryptorCallHistory {
121-
ghost constructor() {
122-
123-
}
124-
125-
}
126-
trait {:termination false} ILegacyDynamoDbEncryptor
127-
{
128-
// Helper to define any additional modifies/reads clauses.
129-
// If your operations need to mutate state,
130-
// add it in your constructor function:
131-
// Modifies := {your, fields, here, History};
132-
// If you do not need to mutate anything:
133-
// Modifies := {History};
134-
135-
ghost const Modifies: set<object>
136-
// For an unassigned field defined in a trait,
137-
// Dafny can only assign a value in the constructor.
138-
// This means that for Dafny to reason about this value,
139-
// it needs some way to know (an invariant),
140-
// about the state of the object.
141-
// This builds on the Valid/Repr paradigm
142-
// To make this kind requires safe to add
143-
// to methods called from unverified code,
144-
// the predicate MUST NOT take any arguments.
145-
// This means that the correctness of this requires
146-
// MUST only be evaluated by the class itself.
147-
// If you require any additional mutation,
148-
// then you MUST ensure everything you need in ValidState.
149-
// You MUST also ensure ValidState in your constructor.
150-
predicate ValidState()
151-
ensures ValidState() ==> History in Modifies
152-
ghost const History: ILegacyDynamoDbEncryptorCallHistory
153-
154-
}
155-
datatype LegacyPolicy =
156-
| REQUIRE_ENCRYPT_ALLOW_DECRYPT
157-
| FORBID_ENCRYPT_ALLOW_DECRYPT
158-
| FORBID_ENCRYPT_FORBID_DECRYPT
159113
datatype Error =
160114
// Local Error structures are listed here
161115
| DynamoDbItemEncryptorException (
162116
nameonly message: string
163117
)
164118
// Any dependent models are listed here
165-
| AwsCryptographyStructuredEncryption(AwsCryptographyStructuredEncryption: AwsCryptographyStructuredEncryptionTypes.Error)
119+
| AwsCryptographyDynamoDbEncryption(AwsCryptographyDynamoDbEncryption: AwsCryptographyDynamoDbEncryptionTypes.Error)
166120
| AwsCryptographyMaterialProviders(AwsCryptographyMaterialProviders: AwsCryptographyMaterialProvidersTypes.Error)
167121
| AwsCryptographyPrimitives(AwsCryptographyPrimitives: AwsCryptographyPrimitivesTypes.Error)
168122
| ComAmazonawsDynamodb(ComAmazonawsDynamodb: ComAmazonawsDynamodbTypes.Error)
@@ -194,13 +148,13 @@ include "../../private-aws-encryption-sdk-dafny-staging/StandardLibrary/src/Inde
194148
| Opaque(obj: object)
195149
type OpaqueError = e: Error | e.Opaque? witness *
196150
}
197-
abstract module AbstractAwsCryptographyDynamoDbItemEncryptorService
151+
abstract module AbstractAwsCryptographyDynamoDbEncryptionItemEncryptorService
198152
{
199153
import opened Wrappers
200154
import opened StandardLibrary.UInt
201155
import opened UTF8
202-
import opened Types = AwsCryptographyDynamoDbItemEncryptorTypes
203-
import Operations : AbstractAwsCryptographyDynamoDbItemEncryptorOperations
156+
import opened Types = AwsCryptographyDynamoDbEncryptionItemEncryptorTypes
157+
import Operations : AbstractAwsCryptographyDynamoDbEncryptionItemEncryptorOperations
204158
function method DefaultDynamoDbItemEncryptorConfig(): DynamoDbItemEncryptorConfig
205159
method DynamoDbItemEncryptor(config: DynamoDbItemEncryptorConfig := DefaultDynamoDbItemEncryptorConfig())
206160
returns (res: Result<DynamoDbItemEncryptorClient, Error>)
@@ -297,11 +251,11 @@ include "../../private-aws-encryption-sdk-dafny-staging/StandardLibrary/src/Inde
297251

298252
}
299253
}
300-
abstract module AbstractAwsCryptographyDynamoDbItemEncryptorOperations {
254+
abstract module AbstractAwsCryptographyDynamoDbEncryptionItemEncryptorOperations {
301255
import opened Wrappers
302256
import opened StandardLibrary.UInt
303257
import opened UTF8
304-
import opened Types = AwsCryptographyDynamoDbItemEncryptorTypes
258+
import opened Types = AwsCryptographyDynamoDbEncryptionItemEncryptorTypes
305259
type InternalConfig
306260
predicate ValidInternalConfig?(config: InternalConfig)
307261
function ModifiesInternalConfig(config: InternalConfig): set<object>

0 commit comments

Comments
 (0)