From 559026b65c3e1a5fda3806b8fc4d0ce7eb5036e9 Mon Sep 17 00:00:00 2001 From: naman-bruno Date: Thu, 27 Mar 2025 16:36:22 +0530 Subject: [PATCH 1/4] Fix: right Agent for system proxy --- .../bruno-electron/src/utils/proxy-util.js | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/bruno-electron/src/utils/proxy-util.js b/packages/bruno-electron/src/utils/proxy-util.js index dc249f493..dc8dd5382 100644 --- a/packages/bruno-electron/src/utils/proxy-util.js +++ b/packages/bruno-electron/src/utils/proxy-util.js @@ -88,15 +88,12 @@ function createTimelineAgentClass(BaseAgentClass) { return class extends BaseAgentClass { constructor(options, timeline) { // For proxy agents, the first argument is the proxy URI and the second is options - if (options.proxy || typeof options === 'string') { - const proxyUri = typeof options === 'string' ? options : options.proxy; - const agentOptions = typeof options === 'string' ? {} : { ...options }; - delete agentOptions.proxy; - + if (options?.proxy) { + const { proxy: proxyUri, ...agentOptions } = options; // Ensure TLS options are properly set const tlsOptions = { ...agentOptions, - rejectUnauthorized: agentOptions.rejectUnauthorized !== undefined ? agentOptions.rejectUnauthorized : true, + rejectUnauthorized: agentOptions.rejectUnauthorized ?? true, }; super(proxyUri, tlsOptions); this.timeline = Array.isArray(timeline) ? timeline : []; @@ -109,12 +106,19 @@ function createTimelineAgentClass(BaseAgentClass) { type: 'info', message: `SSL validation: ${tlsOptions.rejectUnauthorized ? 'enabled' : 'disabled'}`, }); + + // Log the proxy details + this.timeline.push({ + timestamp: new Date(), + type: 'info', + message: `Using proxy: ${proxyUri}`, + }); } else { // This is a regular HTTPS agent case const tlsOptions = { ...options, - rejectUnauthorized: options.rejectUnauthorized !== undefined ? options.rejectUnauthorized : true, - }; + rejectUnauthorized: options.rejectUnauthorized ?? true, + }; super(tlsOptions); this.timeline = Array.isArray(timeline) ? timeline : []; this.alpnProtocols = options.ALPNProtocols || ['h2', 'http/1.1']; @@ -129,6 +133,7 @@ function createTimelineAgentClass(BaseAgentClass) { } } + createConnection(options, callback) { const { host, port } = options; @@ -343,7 +348,7 @@ function setupProxyAgents({ try { if (https_proxy?.length) { new URL(https_proxy); - const TimelineHttpsProxyAgent = createTimelineAgentClass(HttpsProxyAgent); + const TimelineHttpsProxyAgent = createTimelineAgentClass(PatchedHttpsProxyAgent); requestConfig.httpsAgent = new TimelineHttpsProxyAgent( { proxy: https_proxy,...tlsOptions }, timeline From b928ec112eb6a0a8ec862cbb13875d8f47133540 Mon Sep 17 00:00:00 2001 From: naman-bruno Date: Thu, 27 Mar 2025 16:36:42 +0530 Subject: [PATCH 2/4] add: protocol verification for certificate domain --- .../CollectionSettings/ClientCertSettings/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js index 0bc91b5c3..e4eb6c290 100644 --- a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js @@ -25,7 +25,10 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { passphrase: '' }, validationSchema: Yup.object({ - domain: Yup.string().required(), + domain: Yup.string() + .required() + .test('no-protocol', 'Domain should not include protocols (http://, https://, etc.)', + value => !value || !/^(https?:\/\/|ftp:\/\/)/i.test(value)), type: Yup.string().required().oneOf(['cert', 'pfx']), certFilePath: Yup.string().when('type', { is: (type) => type == 'cert', From 741576526d008b204c658ca8487e1e18fc6d1e01 Mon Sep 17 00:00:00 2001 From: naman-bruno Date: Thu, 27 Mar 2025 18:24:45 +0530 Subject: [PATCH 3/4] Fix: logic and design --- .../ClientCertSettings/index.js | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js index e4eb6c290..c5d39b6c3 100644 --- a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js @@ -27,8 +27,8 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { validationSchema: Yup.object({ domain: Yup.string() .required() - .test('no-protocol', 'Domain should not include protocols (http://, https://, etc.)', - value => !value || !/^(https?:\/\/|ftp:\/\/)/i.test(value)), + .trim() + .test('not-empty-after-trim', 'Domain is required', value => value && value.trim().length > 0), type: Yup.string().required().oneOf(['cert', 'pfx']), certFilePath: Yup.string().when('type', { is: (type) => type == 'cert', @@ -45,10 +45,17 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { passphrase: Yup.string() }), onSubmit: (values) => { + // Handle domain processing - extract the part after protocol if "://" is present + let processedDomain = values.domain.trim(); + const protocolSeparatorIndex = processedDomain.indexOf('://'); + if (protocolSeparatorIndex !== -1) { + processedDomain = processedDomain.substring(protocolSeparatorIndex + 3); + } + let relevantValues = {}; if (values.type === 'cert') { relevantValues = { - domain: values.domain, + domain: processedDomain, type: values.type, certFilePath: values.certFilePath, keyFilePath: values.keyFilePath, @@ -56,7 +63,7 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { }; } else { relevantValues = { - domain: values.domain, + domain: processedDomain, type: values.type, pfxFilePath: values.pfxFilePath, passphrase: values.passphrase @@ -130,15 +137,20 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { - +
+
+ https:// +
+ +
{formik.touched.domain && formik.errors.domain ? (
{formik.errors.domain}
) : null} From 20c9e1d40671f8c336f2d950286d767a8e195a0f Mon Sep 17 00:00:00 2001 From: lohit Date: Thu, 27 Mar 2025 19:28:00 +0530 Subject: [PATCH 4/4] removed the domain protocol check --- .../CollectionSettings/ClientCertSettings/index.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js index c5d39b6c3..7ae9ac85e 100644 --- a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js @@ -45,17 +45,10 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { passphrase: Yup.string() }), onSubmit: (values) => { - // Handle domain processing - extract the part after protocol if "://" is present - let processedDomain = values.domain.trim(); - const protocolSeparatorIndex = processedDomain.indexOf('://'); - if (protocolSeparatorIndex !== -1) { - processedDomain = processedDomain.substring(protocolSeparatorIndex + 3); - } - let relevantValues = {}; if (values.type === 'cert') { relevantValues = { - domain: processedDomain, + domain: values.domain?.trim(), type: values.type, certFilePath: values.certFilePath, keyFilePath: values.keyFilePath, @@ -63,7 +56,7 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { }; } else { relevantValues = { - domain: processedDomain, + domain: values.domain?.trim(), type: values.type, pfxFilePath: values.pfxFilePath, passphrase: values.passphrase