feat(core): Use WebCrypto to generate all random numbers and strings (#9786)
This commit is contained in:
committed by
GitHub
parent
cfc4db00e3
commit
65c5609ab5
@@ -4,6 +4,7 @@ import { snakeCase } from 'lodash-es';
|
||||
import { useSessionStorage } from '@vueuse/core';
|
||||
|
||||
import { N8nButton, N8nInput, N8nTooltip } from 'n8n-design-system/components';
|
||||
import { randomInt } from 'n8n-workflow';
|
||||
import type { CodeExecutionMode, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import type { BaseTextKey } from '@/plugins/i18n';
|
||||
@@ -208,7 +209,7 @@ function triggerLoadingChange() {
|
||||
|
||||
// Loading phrase change
|
||||
if (!lastPhraseChange || timestamp - lastPhraseChange >= loadingPhraseUpdateMs) {
|
||||
loadingPhraseIndex.value = Math.floor(Math.random() * loadingPhrasesCount);
|
||||
loadingPhraseIndex.value = randomInt(loadingPhrasesCount);
|
||||
lastPhraseChange = timestamp;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { faker } from '@faker-js/faker';
|
||||
import { STORES, VIEWS } from '@/constants';
|
||||
import ExecutionsList from '@/components/executions/global/GlobalExecutionsList.vue';
|
||||
import type { IWorkflowDb } from '@/Interface';
|
||||
import type { ExecutionSummary } from 'n8n-workflow';
|
||||
import { randomInt, type ExecutionSummary } from 'n8n-workflow';
|
||||
import { retry, SETTINGS_STORE_DEFAULT_STATE, waitAllPromises } from '@/__tests__/utils';
|
||||
import { createComponentRenderer } from '@/__tests__/render';
|
||||
import { waitFor } from '@testing-library/vue';
|
||||
@@ -22,7 +22,7 @@ vi.mock('vue-router', () => ({
|
||||
let pinia: ReturnType<typeof createTestingPinia>;
|
||||
|
||||
const generateUndefinedNullOrString = () => {
|
||||
switch (Math.floor(Math.random() * 4)) {
|
||||
switch (randomInt(4)) {
|
||||
case 0:
|
||||
return undefined;
|
||||
case 1:
|
||||
|
||||
@@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import { createPinia, PiniaVuePlugin, setActivePinia } from 'pinia';
|
||||
import type { ExecutionSummary } from 'n8n-workflow';
|
||||
import { randomInt, type ExecutionSummary } from 'n8n-workflow';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import WorkflowExecutionsPreview from '@/components/executions/workflow/WorkflowExecutionsPreview.vue';
|
||||
import { EnterpriseEditionFeature, VIEWS } from '@/constants';
|
||||
@@ -33,7 +33,7 @@ const $route = {
|
||||
};
|
||||
|
||||
const generateUndefinedNullOrString = () => {
|
||||
switch (Math.floor(Math.random() * 4)) {
|
||||
switch (randomInt(4)) {
|
||||
case 0:
|
||||
return undefined;
|
||||
case 1:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CLOUD_BASE_URL_PRODUCTION, CLOUD_BASE_URL_STAGING, STORES } from '@/constants';
|
||||
import type { RootState } from '@/Interface';
|
||||
import { setGlobalState } from 'n8n-workflow';
|
||||
import { randomString, setGlobalState } from 'n8n-workflow';
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
@@ -26,7 +26,7 @@ export const useRootStore = defineStore(STORES.ROOT, () => {
|
||||
versionCli: '0.0.0',
|
||||
oauthCallbackUrls: {},
|
||||
n8nMetadata: {},
|
||||
pushRef: Math.random().toString(36).substring(2, 15),
|
||||
pushRef: randomString(10).toLowerCase(),
|
||||
urlBaseWebhook: 'http://localhost:5678/',
|
||||
urlBaseEditor: 'http://localhost:5678',
|
||||
isNpmAvailable: false,
|
||||
|
||||
Reference in New Issue
Block a user