Преглед изворни кода

Merge pull request #15216 from overleaf/csh-issue-11625-mongo-ug-5-filestore

Upgrade mongodb module for filestore from 3.5.9 to 6.1.0

GitOrigin-RevId: 96993d561a5aa188cdcd0af1e4938dec7c374b56
Christopher Hoskin пре 2 година
родитељ
комит
40e243f2e4

+ 107 - 8
package-lock.json

@@ -6039,7 +6039,7 @@
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.0.tgz",
       "integrity": "sha512-Xfijy7HvfzzqiOAhAepF4SGN5e9leLkMvg/OPOF97XemjfVCYN/oWa75wnkc6mltMSTwY+XlbhWgUOJmkFspSw==",
-      "optional": true,
+      "devOptional": true,
       "dependencies": {
         "sparse-bitfield": "^3.0.3"
       }
@@ -32597,7 +32597,7 @@
       "version": "1.5.0",
       "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
       "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
-      "optional": true
+      "devOptional": true
     },
     "node_modules/mensch": {
       "version": "0.3.4",
@@ -38828,7 +38828,7 @@
       "version": "3.0.3",
       "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
       "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
-      "optional": true,
+      "devOptional": true,
       "dependencies": {
         "memory-pager": "^1.0.2"
       }
@@ -43155,7 +43155,7 @@
         "chai-as-promised": "^7.1.1",
         "disrequire": "^1.1.0",
         "mocha": "^10.2.0",
-        "mongodb": "^3.5.9",
+        "mongodb": "^6.1.0",
         "sandboxed-module": "2.0.4",
         "sinon": "9.0.2",
         "sinon-chai": "^3.7.0",
@@ -43163,6 +43163,15 @@
         "timekeeper": "^2.2.0"
       }
     },
+    "services/filestore/node_modules/bson": {
+      "version": "6.1.0",
+      "resolved": "https://registry.npmjs.org/bson/-/bson-6.1.0.tgz",
+      "integrity": "sha512-yiQ3KxvpVoRpx1oD1uPz4Jit9tAVTJgjdmjDKtUErkOoL9VNoF8Dd58qtAOL5E40exx2jvAT9sqdRSK/r+SHlA==",
+      "dev": true,
+      "engines": {
+        "node": ">=16.20.1"
+      }
+    },
     "services/filestore/node_modules/diff": {
       "version": "4.0.2",
       "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
@@ -43172,6 +43181,67 @@
         "node": ">=0.3.1"
       }
     },
+    "services/filestore/node_modules/gcp-metadata": {
+      "version": "5.3.0",
+      "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz",
+      "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==",
+      "dev": true,
+      "optional": true,
+      "peer": true,
+      "dependencies": {
+        "gaxios": "^5.0.0",
+        "json-bigint": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=12"
+      }
+    },
+    "services/filestore/node_modules/mongodb": {
+      "version": "6.1.0",
+      "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz",
+      "integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==",
+      "dev": true,
+      "dependencies": {
+        "@mongodb-js/saslprep": "^1.1.0",
+        "bson": "^6.1.0",
+        "mongodb-connection-string-url": "^2.6.0"
+      },
+      "engines": {
+        "node": ">=16.20.1"
+      },
+      "peerDependencies": {
+        "@aws-sdk/credential-providers": "^3.188.0",
+        "@mongodb-js/zstd": "^1.1.0",
+        "gcp-metadata": "^5.2.0",
+        "kerberos": "^2.0.1",
+        "mongodb-client-encryption": ">=6.0.0 <7",
+        "snappy": "^7.2.2",
+        "socks": "^2.7.1"
+      },
+      "peerDependenciesMeta": {
+        "@aws-sdk/credential-providers": {
+          "optional": true
+        },
+        "@mongodb-js/zstd": {
+          "optional": true
+        },
+        "gcp-metadata": {
+          "optional": true
+        },
+        "kerberos": {
+          "optional": true
+        },
+        "mongodb-client-encryption": {
+          "optional": true
+        },
+        "snappy": {
+          "optional": true
+        },
+        "socks": {
+          "optional": true
+        }
+      }
+    },
     "services/filestore/node_modules/sinon": {
       "version": "9.0.2",
       "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.2.tgz",
@@ -50016,7 +50086,7 @@
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.0.tgz",
       "integrity": "sha512-Xfijy7HvfzzqiOAhAepF4SGN5e9leLkMvg/OPOF97XemjfVCYN/oWa75wnkc6mltMSTwY+XlbhWgUOJmkFspSw==",
-      "optional": true,
+      "devOptional": true,
       "requires": {
         "sparse-bitfield": "^3.0.3"
       }
@@ -51807,7 +51877,7 @@
         "glob": "^7.1.6",
         "lodash.once": "^4.1.1",
         "mocha": "^10.2.0",
-        "mongodb": "^3.5.9",
+        "mongodb": "^6.1.0",
         "node-fetch": "^2.6.7",
         "range-parser": "^1.2.1",
         "sandboxed-module": "2.0.4",
@@ -51818,12 +51888,41 @@
         "tiny-async-pool": "^1.1.0"
       },
       "dependencies": {
+        "bson": {
+          "version": "6.1.0",
+          "resolved": "https://registry.npmjs.org/bson/-/bson-6.1.0.tgz",
+          "integrity": "sha512-yiQ3KxvpVoRpx1oD1uPz4Jit9tAVTJgjdmjDKtUErkOoL9VNoF8Dd58qtAOL5E40exx2jvAT9sqdRSK/r+SHlA==",
+          "dev": true
+        },
         "diff": {
           "version": "4.0.2",
           "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
           "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
           "dev": true
         },
+        "gcp-metadata": {
+          "version": "5.3.0",
+          "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz",
+          "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==",
+          "dev": true,
+          "optional": true,
+          "peer": true,
+          "requires": {
+            "gaxios": "^5.0.0",
+            "json-bigint": "^1.0.0"
+          }
+        },
+        "mongodb": {
+          "version": "6.1.0",
+          "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz",
+          "integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==",
+          "dev": true,
+          "requires": {
+            "@mongodb-js/saslprep": "^1.1.0",
+            "bson": "^6.1.0",
+            "mongodb-connection-string-url": "^2.6.0"
+          }
+        },
         "sinon": {
           "version": "9.0.2",
           "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.2.tgz",
@@ -72227,7 +72326,7 @@
       "version": "1.5.0",
       "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
       "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
-      "optional": true
+      "devOptional": true
     },
     "mensch": {
       "version": "0.3.4",
@@ -77176,7 +77275,7 @@
       "version": "3.0.3",
       "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
       "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
-      "optional": true,
+      "devOptional": true,
       "requires": {
         "memory-pager": "^1.0.2"
       }

+ 1 - 1
services/filestore/package.json

@@ -40,7 +40,7 @@
     "chai-as-promised": "^7.1.1",
     "disrequire": "^1.1.0",
     "mocha": "^10.2.0",
-    "mongodb": "^3.5.9",
+    "mongodb": "^6.1.0",
     "sandboxed-module": "2.0.4",
     "sinon": "9.0.2",
     "sinon-chai": "^3.7.0",

+ 16 - 16
services/filestore/test/acceptance/js/FilestoreTests.js

@@ -136,8 +136,8 @@ describe('Filestore', function () {
             `${metricPrefix}_egress`
           )
         }
-        projectId = ObjectId().toString()
-        otherProjectId = ObjectId().toString()
+        projectId = new ObjectId().toString()
+        otherProjectId = new ObjectId().toString()
       })
 
       it('should send a 200 for the status endpoint', async function () {
@@ -155,7 +155,7 @@ describe('Filestore', function () {
           '/tmp/filestore_acceptance_tests_file_read.txt'
 
         beforeEach(async function () {
-          fileId = ObjectId().toString()
+          fileId = new ObjectId().toString()
           fileUrl = `${filestoreUrl}/project/${projectId}/file/${fileId}`
           constantFileContent = [
             'hello world',
@@ -238,8 +238,8 @@ describe('Filestore', function () {
         })
 
         it('should be able to copy files', async function () {
-          const newProjectID = ObjectId().toString()
-          const newFileId = ObjectId().toString()
+          const newProjectID = new ObjectId().toString()
+          const newFileId = new ObjectId().toString()
           const newFileUrl = `${filestoreUrl}/project/${newProjectID}/file/${newFileId}`
           let response = await fetch(newFileUrl, {
             method: 'PUT',
@@ -343,9 +343,9 @@ describe('Filestore', function () {
           projectUrl = `${filestoreUrl}/project/${projectId}`
           otherProjectUrl = `${filestoreUrl}/project/${otherProjectId}`
           fileIds = [
-            ObjectId().toString(),
-            ObjectId().toString(),
-            ObjectId().toString(),
+            new ObjectId().toString(),
+            new ObjectId().toString(),
+            new ObjectId().toString(),
           ]
           fileUrls = [
             `${projectUrl}/file/${fileIds[0]}`,
@@ -416,7 +416,7 @@ describe('Filestore', function () {
         let fileId, fileUrl, largeFileContent, error
 
         beforeEach(async function () {
-          fileId = ObjectId().toString()
+          fileId = new ObjectId().toString()
           fileUrl = `${filestoreUrl}/project/${projectId}/file/${fileId}`
 
           largeFileContent = '_wombat_'.repeat(1024 * 1024) // 8 megabytes
@@ -457,8 +457,8 @@ describe('Filestore', function () {
 
           beforeEach(async function () {
             constantFileContent = `This is a file in a different S3 bucket ${Math.random()}`
-            fileId = ObjectId().toString()
-            bucketName = ObjectId().toString()
+            fileId = new ObjectId().toString()
+            bucketName = new ObjectId().toString()
             fileUrl = `${filestoreUrl}/bucket/${bucketName}/key/${fileId}`
 
             const s3ClientSettings = {
@@ -501,7 +501,7 @@ describe('Filestore', function () {
           beforeEach(async function () {
             date = new Date()
             tk.freeze(date)
-            fileId = ObjectId()
+            fileId = new ObjectId()
             fileUrl = `${filestoreUrl}/project/${projectId}/file/${fileId}`
 
             content = '_wombat_' + Math.random()
@@ -549,7 +549,7 @@ describe('Filestore', function () {
 
           beforeEach(function () {
             constantFileContent = `This is yet more file content ${Math.random()}`
-            fileId = ObjectId().toString()
+            fileId = new ObjectId().toString()
             fileKey = `${projectId}/${fileId}`
             fileUrl = `${filestoreUrl}/project/${projectId}/file/${fileId}`
 
@@ -637,8 +637,8 @@ describe('Filestore', function () {
               let newFileId, newFileUrl, newFileKey, opts
 
               beforeEach(function () {
-                const newProjectID = ObjectId().toString()
-                newFileId = ObjectId().toString()
+                const newProjectID = new ObjectId().toString()
+                newFileId = new ObjectId().toString()
                 newFileUrl = `${filestoreUrl}/project/${newProjectID}/file/${newFileId}`
                 newFileKey = `${newProjectID}/${newFileId}`
 
@@ -857,7 +857,7 @@ describe('Filestore', function () {
         )
 
         beforeEach(async function () {
-          fileId = ObjectId().toString()
+          fileId = new ObjectId().toString()
           fileUrl = `${filestoreUrl}/project/${projectId}/file/${fileId}`
           const stat = await fsStat(localFileReadPath)
           localFileSize = stat.size

+ 3 - 3
services/filestore/test/unit/js/FileHandlerTests.js

@@ -20,9 +20,9 @@ describe('FileHandler', function () {
     fs
 
   const bucket = 'my_bucket'
-  const key = `${ObjectId()}/${ObjectId()}`
-  const convertedFolderKey = `${ObjectId()}/${ObjectId()}`
-  const projectKey = `${ObjectId()}/`
+  const key = `${new ObjectId()}/${new ObjectId()}`
+  const convertedFolderKey = `${new ObjectId()}/${new ObjectId()}`
+  const projectKey = `${new ObjectId()}/`
   const sourceStream = 'sourceStream'
   const convertedKey = 'convertedKey'
   const redirectUrl = 'https://wombat.potato/giraffe'