From 6e8751a27a56f0f02ae64bc13a674c10089e9e91 Mon Sep 17 00:00:00 2001 From: Abhishek S Lal Date: Thu, 30 Oct 2025 18:14:39 +0530 Subject: [PATCH] Fix/client cert passphrase issues (#5898) * fix: added interpolation, warning and syntax highlight for passphrase input Changes: 1) When users add plain text in passphrase, warning message will be shown. 2) Passphrase will be interpolated from environment 3) Syntax highlighting for variables added. Closes #2685 * fix: global environment variables interpolation in cert passphrase implemented. * refactor: indentation refactoring --- .../ClientCertSettings/index.js | 37 ++-- .../components/CollectionSettings/index.js | 2 +- .../src/components/SingleLineEditor/index.js | 2 +- packages/bruno-electron/src/ipc/collection.js | 190 +++++++++--------- .../src/ipc/network/cert-utils.js | 4 +- .../src/ipc/network/grpc-event-handlers.js | 6 +- .../bruno-electron/src/ipc/network/index.js | 15 +- .../src/ipc/network/interpolate-string.js | 4 +- 8 files changed, 135 insertions(+), 125 deletions(-) diff --git a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js index 3f62fc23e..a9d7255ea 100644 --- a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js @@ -1,19 +1,20 @@ import React from 'react'; import { IconCertificate, IconTrash, IconWorld } from '@tabler/icons'; import { useFormik } from 'formik'; -import { uuid } from 'utils/common'; import * as Yup from 'yup'; -import { IconEye, IconEyeOff } from '@tabler/icons'; -import { useState } from 'react'; - import StyledWrapper from './StyledWrapper'; import { useRef } from 'react'; import path from 'utils/common/path'; +import SensitiveFieldWarning from 'components/SensitiveFieldWarning/index'; +import SingleLineEditor from 'components/SingleLineEditor/index'; +import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField/index'; +import { useTheme } from 'styled-components'; -const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { +const ClientCertSettings = ({ collection, clientCertConfig, onUpdate, onRemove }) => { const certFilePathInputRef = useRef(); const keyFilePathInputRef = useRef(); const pfxFilePathInputRef = useRef(); + const { storedTheme } = useTheme(); const formik = useFormik({ initialValues: { @@ -68,10 +69,13 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { } }); + const { isSensitive } = useDetectSensitiveField(collection); + const { showWarning, warningMessage } = isSensitive(formik.values.passphrase); + const getFile = (e) => { const filePath = window?.ipcRenderer?.getFilePath(e?.files?.[0]); if (filePath) { - let relativePath = path.relative(root, filePath); + let relativePath = path.relative(collection.pathname, filePath); formik.setFieldValue(e.name, relativePath); } }; @@ -82,8 +86,6 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { pfxFilePathInputRef.current.value = ''; }; - const [passwordVisible, setPasswordVisible] = useState(false); - const handleTypeChange = (e) => { formik.setFieldValue('type', e.target.value); if (e.target.value === 'cert') { @@ -314,21 +316,14 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { Passphrase
- formik.setFieldValue('passphrase', val)} + collection={collection} + isSecret={true} /> - + {showWarning && }
{formik.touched.passphrase && formik.errors.passphrase ? (
{formik.errors.passphrase}
diff --git a/packages/bruno-app/src/components/CollectionSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/index.js index 333ed69b8..beb4f040e 100644 --- a/packages/bruno-app/src/components/CollectionSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/index.js @@ -120,7 +120,7 @@ const CollectionSettings = ({ collection }) => { case 'clientCert': { return ( { return isSecret === true ? ( -