Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-6378

auto encryption options are mutated by the Encrypter

      Use Case

      As an auto encryption user,
      I want want my options to be unmodified,
      So that I can reuse them without being worried about unexpected data.

       

      Pretty easy to reproduce:

      // freeze auto encryption options
      const autoEncryption = Object.freeze({
          keyVaultNamespace,
          kmsProviders: getKmsProviders(),
          extraOptions
        });
      
      const client = new MongoClient(.., { autoEncryption });
      
      // throws:      TypeError: Cannot add property keyVaultClient, object is not extensible
      

      User Experience

      I don't think this has much of an actual impact - users are unlikely to re-use auto encryption options across multiple clients.  I noticed this when sharing auto encryption options across mocha tests, because after the first test finished and closed its client, the second test fails because the auto encryption options have been mutated and now contain a closed `keyVaultClient`.  This throws when we use it in the state machine because we cannot auto connect an explicitly closed client.

      color: Color value is invalid

      Dependencies

      n/a

      Risks/Unknowns

      None

      Acceptance Criteria

      Implementation Requirements

      • Prevent mutation of auto encryption options
        • We could deep copy them before using them, or store any properties we need to add to them somewhere else.

      Testing Requirements

       

      Documentation Requirements

      None.

      Follow Up Requirements

      None.

            Assignee:
            Unassigned Unassigned
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: