From bb5d5b7464798b45e2f72c1783cd81960552f3a2 Mon Sep 17 00:00:00 2001 From: Christoph Tavan Date: Tue, 13 Aug 2019 23:23:39 +0200 Subject: [PATCH 1/2] Upgrade uuid dependency --- electron/package-lock.json | 11 ++++++++--- electron/package.json | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/electron/package-lock.json b/electron/package-lock.json index b2dfd46..bb8ad7c 100644 --- a/electron/package-lock.json +++ b/electron/package-lock.json @@ -1075,6 +1075,11 @@ "os-homedir": "^1.0.0", "os-tmpdir": "^1.0.0" } + }, + "uuid": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" } } }, @@ -4920,9 +4925,9 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", - "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, "validate-npm-package-license": { "version": "3.0.4", diff --git a/electron/package.json b/electron/package.json index f33e80c..b0a0847 100644 --- a/electron/package.json +++ b/electron/package.json @@ -33,7 +33,7 @@ "simple-statistics": "^1.0.1", "tipsy": "^1.0.0", "tipsy-browserify": "^1.0.0", - "uuid": "^2.0.1" + "uuid": "^3.3.2" }, "devDependencies": { "babel-eslint": "^6.0.2", From 65863b5617a590aab67dc9d19c328c73f4123937 Mon Sep 17 00:00:00 2001 From: Christoph Tavan Date: Tue, 13 Aug 2019 23:23:54 +0200 Subject: [PATCH 2/2] Use v4 UUID instead of v1 for temporary files This uses a purely random v4 UUID instead of a time-based v1 UUID for temporary file names (as introduced in 10f9bef1591fd55f4626c1a7ac6492eaa54164f0). v1 UUID are based on current time and the hardware MAC address of the machine where they are being generated (although the implementation in the npm uuid module uses generates a random fake MAC address). As such they have much more complex semantics than v4 UUIDs which are simply randomly generated. Unless there's a specific requirement for the special semantics of v1 UUIDs it is simpler and less error prone to simply go for v4 UUIDs whenever just a unique identifier is needed. --- electron/app.js | 4 ++-- electron/js/controller.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/electron/app.js b/electron/app.js index cd5be51..8c95fc3 100644 --- a/electron/app.js +++ b/electron/app.js @@ -2,7 +2,7 @@ const {app, BrowserWindow, Menu, ipcMain} = require("electron"); // Module to control application life. // Module to create native browser window. var defaultMenu = require("electron-default-menu"); -var uuid = require("uuid"); +var uuidV4 = require("uuid/v4"); // We can listen to messages from the renderer here: var fs = require("fs"); @@ -126,7 +126,7 @@ function createWindow() { var filename = test.filename; if(!filename) { // we need to create a filename - filename = uuid.v1(); + filename = uuidV4(); } fs.writeFile(savedTestsStorage + "/" + filename, JSON.stringify(test)); }); diff --git a/electron/js/controller.js b/electron/js/controller.js index 5fc87f1..cb9f54b 100644 --- a/electron/js/controller.js +++ b/electron/js/controller.js @@ -9,7 +9,7 @@ var ipc = require("electron").ipcRenderer; // libraries required to run test inline // var requireFromString = require("require-from-string"); var DataprooferTest = require("dataproofertest-js"); -var uuid = require("uuid"); +var uuidV4 = require("uuid/v4"); console.log("dataproofer app version", require("./package.json").version); console.log("dataproofer lib version", require("dataproofer").version); @@ -84,7 +84,7 @@ function duplicateTest(test) { var newTest = { name: test.name() + " copy", description: test.description(), - filename: uuid.v1(), + filename: uuidV4(), local: true, active: true, methodology: test._methodology.toString() @@ -689,7 +689,7 @@ function renderTestEditor(test) { // saving without passing in the filename will inform the server // to generate a new filename /* - var newTestFile = save(uuid.v1()); + var newTestFile = save(uuidV4()); var newTest = loadTest(newTestFile); SUITES[0].tests.push(newTest); // assuming the first suite is always local renderCurrentStep(); // we should only be here on step 2