(scans, options = {})
| 18871 | liveStatus.textContent = 'Initializing Lynis audit...'; |
| 18872 | liveStatus.className = 'text-sm text-blue-600 mt-2'; |
| 18873 | } |
| 18874 | |
| 18875 | if (submitBtn) { |
| 18876 | submitBtn.disabled = true; |
| 18877 | submitBtn.textContent = 'Starting audit...'; |
| 18878 | submitBtn.classList.add('bg-blue-600', 'cursor-wait'); |
| 18879 | submitBtn.classList.remove('bg-red-600', 'hover:bg-red-700'); |
| 18880 | } |
| 18881 | |
| 18882 | try { |
| 18883 | const response = await networkAwareFetch('/api/manual/pentest/lynis', { |
| 18884 | method: 'POST', |
| 18885 | headers: { 'Content-Type': 'application/json' }, |
| 18886 | body: JSON.stringify({ ip, username, password }) |
| 18887 | }); |
| 18888 | |
| 18889 | let payload = {}; |
| 18890 | try { |
| 18891 | payload = await response.json(); |
| 18892 | } catch (parseError) { |
| 18893 | console.warn('Unable to parse manual Lynis response JSON', parseError); |
| 18894 | } |
| 18895 | |
| 18896 | if (!response.ok || (payload && payload.success === false)) { |
| 18897 | throw new Error((payload && (payload.error || payload.message)) || `Request failed (${response.status})`); |
| 18898 | } |
| 18899 | |
| 18900 | const successMessage = (payload && payload.message) || `Lynis pentest initiated for ${ip}`; |
| 18901 | setStatus(successMessage, 'success'); |
| 18902 | addConsoleMessage(successMessage, 'success'); |
| 18903 | passInput.value = ''; |
| 18904 | |
| 18905 | // Live status will be updated via WebSocket events |
| 18906 | // Don't reset the button here - let WebSocket handler do it |
| 18907 | return; |
| 18908 | |
| 18909 | } catch (error) { |
| 18910 | console.error('Error running manual Lynis pentest:', error); |
| 18911 | setStatus(`Failed to start Lynis pentest: ${error.message}`, 'error'); |
| 18912 | addConsoleMessage(`Manual Lynis error: ${error.message}`, 'error'); |
| 18913 | |
| 18914 | // Reset UI on error |
| 18915 | if (submitBtn) { |
| 18916 | submitBtn.disabled = false; |
| 18917 | submitBtn.textContent = 'Run Lynis Pentest'; |
| 18918 | submitBtn.classList.remove('bg-blue-600', 'cursor-wait'); |
| 18919 | submitBtn.classList.add('bg-red-600', 'hover:bg-red-700'); |
| 18920 | } |
| 18921 | if (liveStatus) { |
| 18922 | liveStatus.textContent = `Error: ${error.message}`; |
| 18923 | liveStatus.className = 'text-sm text-red-600 mt-2'; |
| 18924 | } |
| 18925 | } |
| 18926 | } |
| 18927 | |
| 18928 | // ============================================================================ |
| 18929 | // API HELPERS |
| 18930 | // ============================================================================ |
no test coverage detected