diff --git a/packages/bruno-app/src/utils/codemirror/brunoVarInfo.js b/packages/bruno-app/src/utils/codemirror/brunoVarInfo.js index a3a86dc31..d91db3376 100644 --- a/packages/bruno-app/src/utils/codemirror/brunoVarInfo.js +++ b/packages/bruno-app/src/utils/codemirror/brunoVarInfo.js @@ -44,8 +44,11 @@ if (!SERVER_RENDERED) { const into = document.createElement('div'); const descriptionDiv = document.createElement('div'); descriptionDiv.className = 'info-description'; - - descriptionDiv.appendChild(document.createTextNode(variableValue)); + if (options?.variables?.maskedEnvVariables?.includes(variableName)) { + descriptionDiv.appendChild(document.createTextNode('*****')); + } else { + descriptionDiv.appendChild(document.createTextNode(variableValue)); + } into.appendChild(descriptionDiv); return into; diff --git a/packages/bruno-app/src/utils/collections/index.js b/packages/bruno-app/src/utils/collections/index.js index cd925054d..94db723ca 100644 --- a/packages/bruno-app/src/utils/collections/index.js +++ b/packages/bruno-app/src/utils/collections/index.js @@ -815,6 +815,23 @@ export const getEnvironmentVariables = (collection) => { return variables; }; +export const getEnvironmentVariablesMasked = (collection) => { + // Return an empty array if the collection is invalid or not provided + if (!collection || !collection.activeEnvironmentUid) { + return []; + } + + // Find the active environment in the collection + const environment = findEnvironmentInCollection(collection, collection.activeEnvironmentUid); + if (!environment || !environment.variables) { + return []; + } + + // Filter the environment variables to get only the masked (secret) ones + return environment.variables + .filter((variable) => variable.name && variable.value && variable.enabled && variable.secret) + .map((variable) => variable.name); +}; const getPathParams = (item) => { let pathParams = {}; @@ -850,6 +867,13 @@ export const getAllVariables = (collection, item) => { const { globalEnvironmentVariables = {} } = collection; const { processEnvVariables = {}, runtimeVariables = {} } = collection; + const mergedVariables = { + ...folderVariables, + ...requestVariables, + ...runtimeVariables + }; + const maskedEnvVariables = getEnvironmentVariablesMasked(collection); + const filteredMaskedEnvVariables = maskedEnvVariables.filter((key) => !(key in mergedVariables)); return { ...globalEnvironmentVariables, @@ -861,6 +885,7 @@ export const getAllVariables = (collection, item) => { pathParams: { ...pathParams }, + maskedEnvVariables: filteredMaskedEnvVariables, process: { env: { ...processEnvVariables