From 834a5a052142392a63ff96e84c6b5b4202d8f2b5 Mon Sep 17 00:00:00 2001 From: Christoph Tavan Date: Mon, 15 Jul 2019 08:01:02 +0200 Subject: [PATCH] Replaced v1 for v4 uuids (#10871) * Swapped v1 with v4 UUID as requestId when logging no issue v1 UUID are based on current time and the hardware MAC address of the machine where they are being generated. 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. * Swapped v1 with v4 UUID when creating a temporary contentFolder no issue v1 UUID are based on current time and the hardware MAC address of the machine where they are being generated. 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. * Swapped v1 with v4 UUID when creating a temporary exportFolder no issue v1 UUID are based on current time and the hardware MAC address of the machine where they are being generated. 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. --- core/server/web/shared/middlewares/log-request.js | 2 +- core/test/regression/api/v0.1/themes_spec.js | 2 +- core/test/regression/api/v2/admin/db_spec.js | 2 +- core/test/utils/index.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/server/web/shared/middlewares/log-request.js b/core/server/web/shared/middlewares/log-request.js index c536cd816a..f45bc521f5 100644 --- a/core/server/web/shared/middlewares/log-request.js +++ b/core/server/web/shared/middlewares/log-request.js @@ -7,7 +7,7 @@ const common = require('../../../lib/common'); */ module.exports = function logRequest(req, res, next) { const startTime = Date.now(), - requestId = req.get('X-Request-ID') || uuid.v1(); + requestId = req.get('X-Request-ID') || uuid.v4(); function logResponse() { res.responseTime = (Date.now() - startTime) + 'ms'; diff --git a/core/test/regression/api/v0.1/themes_spec.js b/core/test/regression/api/v0.1/themes_spec.js index 7d4c191a9e..8a6e7ab01c 100644 --- a/core/test/regression/api/v0.1/themes_spec.js +++ b/core/test/regression/api/v0.1/themes_spec.js @@ -25,7 +25,7 @@ describe('Themes API', function () { .attach(fieldName, themePath); }, editor: null - }, ghostServer, contentFolder = path.join(os.tmpdir(), uuid.v1(), 'ghost-test'); + }, ghostServer, contentFolder = path.join(os.tmpdir(), uuid.v4(), 'ghost-test'); before(function () { return ghost() diff --git a/core/test/regression/api/v2/admin/db_spec.js b/core/test/regression/api/v2/admin/db_spec.js index 1addd89f88..0b68fc1ed6 100644 --- a/core/test/regression/api/v2/admin/db_spec.js +++ b/core/test/regression/api/v2/admin/db_spec.js @@ -68,7 +68,7 @@ describe('DB API', () => { }); it('can export & import', () => { - const exportFolder = path.join(os.tmpdir(), uuid.v1()); + const exportFolder = path.join(os.tmpdir(), uuid.v4()); const exportPath = path.join(exportFolder, 'export.json'); return request.put(localUtils.API.getApiQuery('settings/')) diff --git a/core/test/utils/index.js b/core/test/utils/index.js index 1fbe7e538d..2603d8240d 100644 --- a/core/test/utils/index.js +++ b/core/test/utils/index.js @@ -851,7 +851,7 @@ startGhost = function startGhost(options) { forceStart: false, copyThemes: true, copySettings: true, - contentFolder: path.join(os.tmpdir(), uuid.v1(), 'ghost-test'), + contentFolder: path.join(os.tmpdir(), uuid.v4(), 'ghost-test'), subdir: false }, options);