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.
This commit is contained in:
Christoph Tavan 2019-07-15 08:01:02 +02:00 committed by Fabien O'Carroll
parent 07215bd040
commit 834a5a0521
4 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,7 @@ const common = require('../../../lib/common');
*/ */
module.exports = function logRequest(req, res, next) { module.exports = function logRequest(req, res, next) {
const startTime = Date.now(), const startTime = Date.now(),
requestId = req.get('X-Request-ID') || uuid.v1(); requestId = req.get('X-Request-ID') || uuid.v4();
function logResponse() { function logResponse() {
res.responseTime = (Date.now() - startTime) + 'ms'; res.responseTime = (Date.now() - startTime) + 'ms';

View File

@ -25,7 +25,7 @@ describe('Themes API', function () {
.attach(fieldName, themePath); .attach(fieldName, themePath);
}, },
editor: null editor: null
}, ghostServer, contentFolder = path.join(os.tmpdir(), uuid.v1(), 'ghost-test'); }, ghostServer, contentFolder = path.join(os.tmpdir(), uuid.v4(), 'ghost-test');
before(function () { before(function () {
return ghost() return ghost()

View File

@ -68,7 +68,7 @@ describe('DB API', () => {
}); });
it('can export & import', () => { 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'); const exportPath = path.join(exportFolder, 'export.json');
return request.put(localUtils.API.getApiQuery('settings/')) return request.put(localUtils.API.getApiQuery('settings/'))

View File

@ -851,7 +851,7 @@ startGhost = function startGhost(options) {
forceStart: false, forceStart: false,
copyThemes: true, copyThemes: true,
copySettings: true, copySettings: true,
contentFolder: path.join(os.tmpdir(), uuid.v1(), 'ghost-test'), contentFolder: path.join(os.tmpdir(), uuid.v4(), 'ghost-test'),
subdir: false subdir: false
}, options); }, options);