From 53cef9e5a92fff1ce63d00389da195bd7017ac03 Mon Sep 17 00:00:00 2001 From: CyberSecurityUP Date: Thu, 3 Dec 2026 09:23:06 -0300 Subject: [PATCH 1/2] fix(web): authentication button always opens the Target login tab - reset the Auth & Keys tab on every open instead of keeping the last one - Authentication -> Target login, rules -> Scope, infra creds -> Files --- web/public/app.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/web/public/app.js b/web/public/app.js index d238fd6..7d264c8 100644 --- a/web/public/app.js +++ b/web/public/app.js @@ -2601,15 +2601,23 @@ function renderDetailCoverage(detail) { // Auth & Keys modal // --------------------------------------------------------------------------- -function openAuthModal() { +function selectAuthTab(name) { + $$('.modal-tab').forEach((t) => t.classList.toggle('active', t.dataset.mtab === name)); + $$('.modal-panel').forEach((p) => show(p, p.dataset.mpanel === name)); +} + +// The tab state survives between opens, so reset it explicitly: opening from +// "Authentication" must show Target login, not whatever tab was used last. +function openAuthModal(tab = 'target') { show($('#authModal'), true); + selectAuthTab(tab); renderRoleList(); $('#credsPath').value = state.credsPath; $('#collectionPath').value = state.collectionPath; refreshKeyStatus(); } -['#btnOpenAuth2', '#btnOpenAuth3'].forEach((sel) => $(sel)?.addEventListener('click', openAuthModal)); +['#btnOpenAuth2', '#btnOpenAuth3'].forEach((sel) => $(sel)?.addEventListener('click', () => openAuthModal('target'))); $('#btnCloseAuth').addEventListener('click', () => show($('#authModal'), false)); $('#authModal').addEventListener('click', (e) => { if (e.target.id === 'authModal') show($('#authModal'), false); }); @@ -7227,10 +7235,7 @@ function updateScopeAuthSummary() { : state.auth.header ? `Auth header set${roles ? ` · ${roles} role(s)` : ''}` : roles ? `${roles} role(s)` : 'Not set — agents test as an anonymous user.'; } -$('[data-open-authz]')?.addEventListener('click', () => { - openAuthModal(); - $('.modal-tab[data-mtab="authz"]')?.click(); -}); +$('[data-open-authz]')?.addEventListener('click', () => openAuthModal('authz')); $('#btnCloseAuth')?.addEventListener('click', updateScopeAuthSummary); // ---- new pentest entry points ---------------------------------------------- @@ -9495,7 +9500,7 @@ function applyModeFields() { $('.card-title', authCard).textContent = m.auth === 'infra' ? 'Domain or host credentials' : 'Authentication'; if (m.auth === 'infra') $('#scopeAuthSummary').textContent = state.credsPath ? `Using ${state.credsPath}` : 'None — add user/password, NTLM hash or SSH key in a creds file.'; else if (typeof updateScopeAuthSummary === 'function') updateScopeAuthSummary(); - authBtn.onclick = m.auth === 'infra' ? (e) => { e.stopImmediatePropagation(); openAuthModal(); $('.modal-tab[data-mtab="creds"]')?.click(); } : null; + authBtn.onclick = m.auth === 'infra' ? (e) => { e.stopImmediatePropagation(); openAuthModal('creds'); } : null; } // Launch: only the knobs that mean something for this kind of test. const web = ['run', 'greybox', 'aitest'].includes(state.mode); From 80748b0c749dc6b4caba349339f7d10ee1f0ea75 Mon Sep 17 00:00:00 2001 From: CyberSecurityUP Date: Thu, 3 Dec 2026 09:28:15 -0300 Subject: [PATCH 2/2] fix(web): keep the saved default model after the live catalog loads - the saved model can exist only in the live /models list, not the seed list; the select fell back to the first model and Save persisted it - Settings and the wizard now re-select the saved/preferred model after the live catalog replaces the options --- web/public/app.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/web/public/app.js b/web/public/app.js index 7d264c8..e7bf05a 100644 --- a/web/public/app.js +++ b/web/public/app.js @@ -669,7 +669,7 @@ async function loadProviders() { const parts = cfg.defaultModel.split(':'); if (parts.length >= 2) { sel.value = parts[0]; - onProviderChange(); + onProviderChange(parts.slice(1).join(':')); $('#fieldModelSelect').value = parts.slice(1).join(':'); sanitizeModelSelect(); return; @@ -687,12 +687,13 @@ function sanitizeModelSelect(prefer) { if (!opts.includes(ms.value)) ms.value = opts[0]; } -function onProviderChange() { +function onProviderChange(preferredModel) { + const prefer = typeof preferredModel === 'string' ? preferredModel : ''; const p = state.providers.find((x) => x.key === $('#fieldProvider').value) || state.providers[0]; const modelSel = $('#fieldModelSelect'); const prev = modelSel.value; modelSel.innerHTML = (p?.models || []).map((m) => ``).join(''); - sanitizeModelSelect(prev); + sanitizeModelSelect(prefer || prev); // The seeded list is only a fallback — pull the provider's full live catalog // (OpenRouter, OpenAI, DeepSeek, Groq, Gemini, local runtimes, …). const provKey = p?.key; @@ -701,7 +702,7 @@ function onProviderChange() { if ($('#fieldProvider')?.value !== provKey) return; const list = r.models || []; if (!list.length) return; - const keep = modelSel.value; + const keep = (prefer && list.includes(prefer)) ? prefer : modelSel.value; modelSel.innerHTML = list.map((m) => ``).join(''); if (list.includes(keep)) modelSel.value = keep; sanitizeModelSelect(); @@ -7634,6 +7635,7 @@ loadSettings = async function loadSettingsV5() { const provSel = $('#settingProvider'); const modelSel = $('#settingModel'); const parts = curDefault.split(':'); + const savedModel = parts.slice(1).join(':'); const setModel = (key, prefer) => { if (!modelSel) return; const p = providers.find((x) => x.key === key); @@ -7641,20 +7643,23 @@ loadSettings = async function loadSettingsV5() { modelSel.innerHTML = list.map((m) => ``).join(''); if (prefer && list.includes(prefer)) modelSel.value = prefer; }; - const loadCatalog = async (key) => { + const loadCatalog = async (key, prefer) => { if (!key || !modelSel) return; try { const r = await api(`/api/providers/${encodeURIComponent(key)}/models`); const list = r.models || []; if (!list.length || $('#settingProvider')?.value !== key) return; - const keep = modelSel.value; + // The saved model may only exist in the live catalog, not the seed + // list; apply it after the catalog replaces the options or the + // Settings page would show (and then save) the first model. + const keep = (prefer && list.includes(prefer)) ? prefer : modelSel.value; modelSel.innerHTML = list.map((m) => ``).join(''); if (list.includes(keep)) modelSel.value = keep; } catch { /* keep the seed list */ } }; if (provSel && parts.length >= 2) provSel.value = parts[0]; - setModel(provSel?.value || '', parts.slice(1).join(':')); - loadCatalog(provSel?.value); + setModel(provSel?.value || '', savedModel); + loadCatalog(provSel?.value, savedModel); provSel?.addEventListener('change', () => { const key = provSel.value; setModel(key, providers.find((x) => x.key === key)?.models?.[0]); @@ -7804,7 +7809,7 @@ function pickProvider(provider, model) { const sel = $('#fieldProvider'); if (!sel || !provider || ![...sel.options].some((o) => o.value === provider)) return; sel.value = provider; - onProviderChange(); + onProviderChange(model); const ms = $('#fieldModelSelect'); if (model && ms && [...ms.options].some((o) => o.value === model)) ms.value = model; syncAiSummary();