Skip to content

Commit 06c1cc8

Browse files
Merge branch 'fix-leading-slash-fuzz-exit' of github.com:prestonvasquez/mongo-go-driver into fix-leading-slash-fuzz-exit
2 parents fd8cdbd + c3a08f2 commit 06c1cc8

24 files changed

+754
-216
lines changed

.evergreen/config.yml

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ functions:
5858
export PROJECT_DIRECTORY="$(pwd)"
5959
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
6060
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
61-
export UPLOAD_BUCKET="${project}"
6261
export PROJECT="${project}"
6362
6463
# If on Windows, convert paths with cygpath. GOROOT should not be converted as Windows expects it
@@ -70,7 +69,6 @@ functions:
7069
export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY)
7170
export MONGO_ORCHESTRATION_HOME=$(cygpath -m $MONGO_ORCHESTRATION_HOME)
7271
export MONGODB_BINARIES=$(cygpath -m $MONGODB_BINARIES)
73-
export UPLOAD_BUCKET=$(cygpath -m $UPLOAD_BUCKET)
7472
export PROJECT=$(cygpath -m $PROJECT)
7573
7674
# Set home variables for Windows, too.
@@ -108,7 +106,6 @@ functions:
108106
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
109107
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
110108
MONGODB_BINARIES: "$MONGODB_BINARIES"
111-
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
112109
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
113110
PREPARE_SHELL: |
114111
set -o errexit
@@ -120,7 +117,6 @@ functions:
120117
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
121118
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
122119
export MONGODB_BINARIES="$MONGODB_BINARIES"
123-
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
124120
export PROJECT="$PROJECT"
125121
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
126122
export PKG_CONFIG_PATH=$(pwd)/install/libmongocrypt/lib64/pkgconfig
@@ -154,24 +150,29 @@ functions:
154150
params:
155151
files:
156152
- "src/go.mongodb.org/mongo-driver/*.suite"
153+
- command: ec2.assume_role
154+
params:
155+
role_arn: ${assume_role_arn}
157156
- command: s3.put
158157
params:
159-
aws_key: ${aws_key}
160-
aws_secret: ${aws_secret}
158+
aws_key: ${AWS_ACCESS_KEY_ID}
159+
aws_secret: ${AWS_SECRET_ACCESS_KEY}
160+
aws_session_token: ${AWS_SESSION_TOKEN}
161161
local_file: ${DRIVERS_TOOLS}/.evergreen/test_logs.tar.gz
162-
remote_file: ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-drivers-tools-logs.tar.gz
163-
bucket: mciuploads
162+
remote_file: ${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-drivers-tools-logs.tar.gz
163+
bucket: ${aws_bucket}
164164
permissions: public-read
165165
content_type: ${content_type|application/x-gzip}
166166
display_name: "drivers-tools-logs.tar.gz"
167167
- command: s3.put
168168
params:
169-
aws_key: ${aws_key}
170-
aws_secret: ${aws_secret}
169+
aws_key: ${AWS_ACCESS_KEY_ID}
170+
aws_secret: ${AWS_SECRET_ACCESS_KEY}
171+
aws_session_token: ${AWS_SESSION_TOKEN}
171172
optional: true
172173
local_file: ${PROJECT_DIRECTORY}/fuzz.tgz
173-
remote_file: ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/${task_id}-${execution}-fuzz.tgz
174-
bucket: mciuploads
174+
remote_file: ${build_variant}/${revision}/${version_id}/${build_id}/${task_id}-${execution}-fuzz.tgz
175+
bucket: ${aws_bucket}
175176
permissions: public-read
176177
content_type: application/x-gzip
177178
display_name: "fuzz.tgz"
@@ -184,12 +185,13 @@ functions:
184185
find . -name \*.suite | xargs tar czf test_suite.tgz
185186
- command: s3.put
186187
params:
187-
aws_key: ${aws_key}
188-
aws_secret: ${aws_secret}
188+
aws_key: ${AWS_ACCESS_KEY_ID}
189+
aws_secret: ${AWS_SECRET_ACCESS_KEY}
190+
aws_session_token: ${AWS_SESSION_TOKEN}
189191
local_file: src/go.mongodb.org/mongo-driver/test_suite.tgz
190192
optional: true
191-
remote_file: ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-test_suite.tgz
192-
bucket: mciuploads
193+
remote_file: ${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-test_suite.tgz
194+
bucket: ${aws_bucket}
193195
permissions: public-read
194196
content_type: ${content_type|text/plain}
195197
display_name: "test_suite.tgz"
@@ -1715,7 +1717,7 @@ tasks:
17151717
- name: "testgcpkms-task"
17161718
commands:
17171719
- command: shell.exec
1718-
type: setup
1720+
type: test
17191721
params:
17201722
shell: "bash"
17211723
working_dir: src/go.mongodb.org/mongo-driver
@@ -1796,7 +1798,7 @@ tasks:
17961798
- name: "testazurekms-task"
17971799
commands:
17981800
- command: shell.exec
1799-
type: setup
1801+
type: test
18001802
params:
18011803
shell: "bash"
18021804
working_dir: src/go.mongodb.org/mongo-driver
@@ -1825,7 +1827,7 @@ tasks:
18251827
script: |
18261828
${PREPARE_SHELL}
18271829
source $DRIVERS_TOOLS/.evergreen/csfle/azurekms/secrets-export.sh
1828-
AZUREKMS_CMD="LD_LIBRARY_PATH=./install/libmongocrypt/lib64 MONGODB_URI='mongodb://localhost:27017' PROVIDER='azure' AZUREKMS_KEY_NAME='${AZUREKMS_KEY_NAME}' AZUREKMS_KEY_VAULT_ENDPOINT='${AZUREKMS_KEY_VAULT_ENDPOINT}' ./testkms" $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh
1830+
AZUREKMS_CMD="LD_LIBRARY_PATH=./install/libmongocrypt/lib64 MONGODB_URI='mongodb://localhost:27017' PROVIDER='azure' AZUREKMS_KEY_NAME=$AZUREKMS_KEYNAME AZUREKMS_KEY_VAULT_ENDPOINT=$AZUREKMS_KEYVAULTENDPOINT ./testkms" $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh
18291831
18301832
- name: "testazurekms-fail-task"
18311833
# testazurekms-fail-task runs without environment variables.
@@ -1844,10 +1846,11 @@ tasks:
18441846
make build-kms-test
18451847
echo "Building build-kms-test ... end"
18461848
1849+
. ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/setup-secrets.sh
18471850
LD_LIBRARY_PATH=./install/libmongocrypt/lib64 \
18481851
MONGODB_URI='mongodb://localhost:27017' \
18491852
EXPECT_ERROR='unable to retrieve azure credentials' \
1850-
PROVIDER='azure' AZUREKMS_KEY_NAME='${AZUREKMS_KEY_NAME}' AZUREKMS_KEY_VAULT_ENDPOINT='${AZUREKMS_KEY_VAULT_ENDPOINT}' \
1853+
PROVIDER='azure' AZUREKMS_KEY_NAME=$AZUREKMS_KEYNAME AZUREKMS_KEY_VAULT_ENDPOINT=$AZUREKMS_KEYVAULTENDPOINT \
18511854
./testkms
18521855
18531856
- name: "test-fuzz"
@@ -1862,6 +1865,7 @@ tasks:
18621865
role_arn: ${LAMBDA_AWS_ROLE_ARN}
18631866
duration_seconds: 3600
18641867
- command: shell.exec
1868+
type: test
18651869
params:
18661870
working_dir: src/go.mongodb.org/mongo-driver
18671871
shell: bash
@@ -1884,6 +1888,7 @@ tasks:
18841888
- name: "oidc-auth-test-azure"
18851889
commands:
18861890
- command: shell.exec
1891+
type: test
18871892
params:
18881893
working_dir: src/go.mongodb.org/mongo-driver
18891894
shell: bash
@@ -1909,6 +1914,7 @@ tasks:
19091914
- name: "oidc-auth-test-gcp"
19101915
commands:
19111916
- command: shell.exec
1917+
type: test
19121918
params:
19131919
working_dir: src/go.mongodb.org/mongo-driver
19141920
shell: bash
@@ -2337,7 +2343,7 @@ buildvariants:
23372343
tags: ["pullrequest"]
23382344
display_name: "Static Analysis"
23392345
run_on:
2340-
- rhel8.7-large
2346+
- rhel8.7-small
23412347
expansions:
23422348
GO_DIST: "/opt/golang/go1.22"
23432349
tasks:
@@ -2366,7 +2372,7 @@ buildvariants:
23662372
tags: ["pullrequest"]
23672373
display_name: "Compile Only Checks"
23682374
run_on:
2369-
- rhel8.7-large
2375+
- rhel8.7-small
23702376
expansions:
23712377
GO_DIST: "/opt/golang/go1.22"
23722378
tasks:
@@ -2604,7 +2610,7 @@ buildvariants:
26042610
- name: testoidc-variant
26052611
display_name: "OIDC"
26062612
run_on:
2607-
- ubuntu2204-large
2613+
- ubuntu2204-small
26082614
expansions:
26092615
GO_DIST: "/opt/golang/go1.22"
26102616
tasks:

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ repos:
4040
rev: "v2.2.6"
4141
hooks:
4242
- id: codespell
43-
args: ["-L", "te,fo,fle,alo,nin,compres,wil,collone,asess,sav,ot,wll,dne,nulll,hellow"]
44-
exclude: ^(vendor/|internal/cmd/benchmark/operation_test.go|bson/testdata/lorem.txt)
43+
args: ["-L", "te,fo,fle,alo,nin,compres,wil,collone,asess,sav,ot,wll,dne,nulll,hellow,aks"]
44+
exclude: ^(vendor/|internal/cmd/benchmark/operation_test.go|bson/testdata/)
4545
exclude_types: [json,yaml,pem]
4646

4747
- repo: https://github.com/tcort/markdown-link-check

internal/integration/unified/database_operation_execution.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,37 @@ func executeListCollectionNames(ctx context.Context, operation *operation) (*ope
223223
return newValueResult(bson.TypeArray, data, nil), nil
224224
}
225225

226+
func executeModifyCollection(ctx context.Context, operation *operation) (*operationResult, error) {
227+
db, err := entities(ctx).database(operation.Object)
228+
if err != nil {
229+
return nil, err
230+
}
231+
232+
collModCmd := bson.D{}
233+
234+
elems, _ := operation.Arguments.Elements()
235+
for _, elem := range elems {
236+
key := elem.Key()
237+
val := elem.Value()
238+
239+
switch key {
240+
case "collection":
241+
collModCmd = append(collModCmd, bson.E{"collMod", val.StringValue()})
242+
case "changeStreamPreAndPostImages":
243+
collModCmd = append(collModCmd, bson.E{"changeStreamPreAndPostImages", val.Document()})
244+
case "validator":
245+
collModCmd = append(collModCmd, bson.E{"validator", val.Document()})
246+
case "index":
247+
collModCmd = append(collModCmd, bson.E{"index", val.Document()})
248+
default:
249+
return nil, fmt.Errorf("unrecognized modifyCollection option %q", key)
250+
}
251+
}
252+
253+
res, err := db.RunCommand(ctx, collModCmd).Raw()
254+
return newDocumentResult(res, err), nil
255+
}
256+
226257
func executeRunCommand(ctx context.Context, operation *operation) (*operationResult, error) {
227258
db, err := entities(ctx).database(operation.Object)
228259
if err != nil {

internal/integration/unified/operation.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ func (op *operation) run(ctx context.Context, loopDone <-chan struct{}) (*operat
145145
return executeListCollections(ctx, op)
146146
case "listCollectionNames":
147147
return executeListCollectionNames(ctx, op)
148+
case "modifyCollection":
149+
return executeModifyCollection(ctx, op)
148150
case "runCommand":
149151
return executeRunCommand(ctx, op)
150152
case "runCursorCommand":
@@ -268,7 +270,7 @@ func (op *operation) run(ctx context.Context, loopDone <-chan struct{}) (*operat
268270
return executeAddKeyAltName(ctx, op)
269271

270272
// Unsupported operations
271-
case "count", "listIndexNames", "modifyCollection":
273+
case "count", "listIndexNames":
272274
return nil, newSkipTestError(fmt.Sprintf("the %q operation is not supported", op.Name))
273275
default:
274276
return nil, fmt.Errorf("unrecognized entity operation %q", op.Name)

mongo/client.go

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -215,34 +215,13 @@ func newClient(opts ...options.Lister[options.ClientOptions]) (*Client, error) {
215215
}
216216

217217
if args.Auth != nil {
218-
var oidcMachineCallback auth.OIDCCallback
219-
if args.Auth.OIDCMachineCallback != nil {
220-
oidcMachineCallback = func(ctx context.Context, oargs *driver.OIDCArgs) (*driver.OIDCCredential, error) {
221-
cred, err := args.Auth.OIDCMachineCallback(ctx, convertOIDCArgs(oargs))
222-
return (*driver.OIDCCredential)(cred), err
223-
}
224-
}
225-
226-
var oidcHumanCallback auth.OIDCCallback
227-
if args.Auth.OIDCHumanCallback != nil {
228-
oidcHumanCallback = func(ctx context.Context, oargs *driver.OIDCArgs) (*driver.OIDCCredential, error) {
229-
cred, err := args.Auth.OIDCHumanCallback(ctx, convertOIDCArgs(oargs))
230-
return (*driver.OIDCCredential)(cred), err
231-
}
232-
}
233-
234-
// Create an authenticator for the client
235-
client.authenticator, err = auth.CreateAuthenticator(args.Auth.AuthMechanism, &auth.Cred{
236-
Source: args.Auth.AuthSource,
237-
Username: args.Auth.Username,
238-
Password: args.Auth.Password,
239-
PasswordSet: args.Auth.PasswordSet,
240-
Props: args.Auth.AuthMechanismProperties,
241-
OIDCMachineCallback: oidcMachineCallback,
242-
OIDCHumanCallback: oidcHumanCallback,
243-
}, args.HTTPClient)
218+
client.authenticator, err = auth.CreateAuthenticator(
219+
args.Auth.AuthMechanism,
220+
topology.ConvertCreds(args.Auth),
221+
args.HTTPClient,
222+
)
244223
if err != nil {
245-
return nil, err
224+
return nil, fmt.Errorf("error creating authenticator: %w", err)
246225
}
247226
}
248227

@@ -274,20 +253,7 @@ func newClient(opts ...options.Lister[options.ClientOptions]) (*Client, error) {
274253
return client, nil
275254
}
276255

277-
// convertOIDCArgs converts the internal *driver.OIDCArgs into the equivalent
278-
// public type *options.OIDCArgs.
279-
func convertOIDCArgs(args *driver.OIDCArgs) *options.OIDCArgs {
280-
if args == nil {
281-
return nil
282-
}
283-
return &options.OIDCArgs{
284-
Version: args.Version,
285-
IDPInfo: (*options.IDPInfo)(args.IDPInfo),
286-
RefreshToken: args.RefreshToken,
287-
}
288-
}
289-
290-
// connect initializes the Client by starting background monitoring goroutines.
256+
// Connect initializes the Client by starting background monitoring goroutines.
291257
// If the Client was created using the NewClient function, this method must be called before a Client can be used.
292258
//
293259
// Connect starts background goroutines to monitor the state of the deployment and does not do any I/O in the main

0 commit comments

Comments
 (0)