Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Allow SMTP auth over unencrypted connections, fix rate limit persistence, sanitize diagnostics export

rcourtmanb3fa409b74c6
diff --git a/frontend-modern/src/components/Settings/DiagnosticsPanel.tsx b/frontend-modern/src/components/Settings/DiagnosticsPanel.tsx
index 2d8b32c563..d3f025331e 100644
--- a/frontend-modern/src/components/Settings/DiagnosticsPanel.tsx
+++ b/frontend-modern/src/components/Settings/DiagnosticsPanel.tsx
@@ -257,6 +257,118 @@ export const DiagnosticsPanel: Component = () => {
}
};
+ // sanitizeDiagnostics redacts IPs, hostnames, subnets, and token hints
+ // so the export is safe to attach to a public GitHub issue.
+ const sanitizeDiagnostics = (raw: DiagnosticsData): DiagnosticsData => {
+ const data: DiagnosticsData = JSON.parse(JSON.stringify(raw));
+
+ // Regex matching IPv4 addresses, IPv6 addresses, hostnames with dots, and CIDR notation
+ const ipv4Re = /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\/\d{1,2})?\b/g;
+
+ const redactString = (s: string): string => s.replace(ipv4Re, '[REDACTED_IP]');
+
+ // Redact node hosts
+ data.nodes = data.nodes.map((node, i) => ({
+ ...node,
+ host: `node-${i + 1}`,
+ name: `node-${i + 1}`,
+ id: `node-${i + 1}`,
+ error: node.error ? redactString(node.error) : undefined,
+ }));
+
+ // Redact PBS hosts
+ data.pbs = data.pbs.map((p, i) => ({
+ ...p,
+ host: `pbs-${i + 1}`,
+ name: `pbs-${i + 1}`,
+ id: `pbs-${i + 1}`,
+ error: p.error ? redactString(p.error) : undefined,
+ }));
+
+ // Redact discovery subnets
+ if (data.discovery) {
+ data.discovery = {
+ ...data.discovery,
+ configuredSubnet: data.discovery.configuredSubnet ? '[REDACTED_SUBNET]' : undefined,
+ activeSubnet: data.discovery.activeSubnet ? '[REDACTED_SUBNET]' : undefined,
+ environmentOverride: data.discovery.environmentOverride ? '[REDACTED]' : undefined,
+ subnetAllowlist: data.discovery.subnetAllowlist?.map(() => '[REDACTED_SUBNET]'),
+ subnetBlocklist: data.discovery.subnetBlocklist?.map(() => '[REDACTED_SUBNET]'),
+ };
+ // Redact IPs in discovery history (field exists in backend but not in TS interface)
+ const disc = data.discovery as any;
+ if (Array.isArray(disc.history)) {
+ disc.history = disc.history.map((h: Record<string, unknown>) => ({
+ ...h,
+ subnet: '[REDACTED_SUBNET]',
+ }));
+ }
+ }
+
+ // Redact API token details (tokens/usage arrays exist in backend but not in TS interface)
+ if (data.apiTokens) {
+ const tokens = data.apiTokens as any;
+ if (Array.isArray(tokens.tokens)) {
+ tokens.tokens = tokens.tokens.map((t: Record<string, unknown>, i: number) => ({
+ ...t,
+ hint: '[REDACTED]',
+ id: `token-${i + 1}`,
+ name: `token-${i + 1}`,
+ }));
+ }
+ if (Array.isArray(tokens.usage)) {
+ tokens.usage = tokens.usage.map((u: Record<string, unknown>) => ({
+ ...u,
+ hosts: undefined,
+ }));
+ }
+ }
+
+ // Redact Docker agent identifiers
+ if (data.dockerAgents) {
+ const agents = data.dockerAgents as any;
+ if (Array.isArray(agents.attention)) {
+ agents.attention = agents.attention.map((a: Record<string, unknown>, i: number) => ({
+ ...a,
+ hostId: `docker-host-${i + 1}`,
+ name: `docker-host-${i + 1}`,
+ tokenHint: a.tokenHint ? '[REDACTED]' : undefined,
+ }));
+ }
+ }
+
+ // Redact AI chat URL
+ if (data.aiChat?.url) {
+ data.aiChat.url = '[REDACTED]';
+ }
+
+ // Redact IPs in error messages
+ data.errors = data.errors.map(redactString);
+
+ // Redact IPs from any raw snapshot data that may be present
+ const raw2 = data as any;
+ if (Array.isArray(raw2.nodeSnapshots)) {
+ raw2.nodeSnapshots = raw2.nodeSnapshots.map((s: Record<string, unknown>, i: number) => ({
+ ...s,
+ instance: `node-${i + 1}`,
+ }));
+ }
+ if (Array.isArray(raw2.guestSnapshots)) {
+ raw2.guestSnapshots = raw2.guestSnapshots.map((s: Record<string, unknown>, i: number) => ({
+ ...s,
+ instance: `node-${i + 1}`,
+ }));
+ }
+ if (Array.isArray(raw2.memorySources)) {
+ raw2.memorySources = raw2.memorySources.map((s: Record<string, unknown>, i: number) => ({
+ ...s,
+ instance: `node-${i + 1}`,
+ }));
+ }
+
+ return data;
+ };
+
const exportDiagnostics = async (sanitize: boolean) => {
setExportLoading(true);
try {
@@ -266,7 +378,8 @@ export const DiagnosticsPanel: Component = () => {
return;
}
- const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
+ const exportData = sanitize ? sanitizeDiagnostics(data) : data;
+ const blob = new Blob([JSON.stringify(exportData, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
diff --git a/internal/notifications/email_enhanced.go b/internal/notifications/email_enhanced.go
index 6aef9d7af6..83bf052db8 100644
--- a/internal/notifications/email_enhanced.go
+++ b/internal/notifications/email_enhanced.go
@@ -17,18 +17,15 @@ import (
// Many mail servers (notably Microsoft 365) advertise only AUTH LOGIN
// and reject AUTH PLAIN with "504 5.7.4 Unrecognized authentication type".
type loginAuth struct {
- username, password, host string
+ username, password string
}
// LoginAuth returns an Auth that implements the LOGIN authentication mechanism.
-func LoginAuth(username, password, host string) smtp.Auth {
- return &loginAuth{username, password, host}
+func LoginAuth(username, password string) smtp.Auth {
+ return &loginAuth{username, password}
}
func (a *loginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
- if !server.TLS {
- return "", nil, fmt.Errorf("LOGIN auth requires TLS connection to %s", a.host)
- }
return "LOGIN", nil, nil
}
@@ -47,6 +44,27 @@ func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) {
}
}
+// plainAuth implements SMTP PLAIN authentication without requiring TLS.
+// Go's built-in smtp.PlainAuth refuses to send credentials over unencrypted
+// connections to non-localhost hosts. This implementation allows authenticated
+// SMTP over unencrypted connections when the user has explicitly configured
+// no TLS/STARTTLS — which is a conscious security decision on their part.
+type plainAuth struct {
+ identity, username, password string
+}
+
+func (a *plainAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
+ resp := []byte(a.identity + "\x00" + a.username + "\x00" + a.password)
+ return "PLAIN", resp, nil
+}
+
+func (a *plainAuth) Next(fromServer []byte, more bool) ([]byte, error) {
+ if more {
+ return nil, fmt.Errorf("unexpected server challenge")
+ }
+ return nil, nil
+}
+
// negotiateAuth queries the server for supported AUTH mechanisms after EHLO
// and returns the best smtp.Auth to use. Prefers PLAIN, falls back to LOGIN.
// Returns nil if auth is not configured.
@@ -61,17 +79,17 @@ func (e *EnhancedEmailManager) negotiateAuth(client *smtp.Client) (smtp.Auth, er
mechanisms := strings.ToUpper(mechanismsRaw)
if strings.Contains(mechanisms, "PLAIN") {
- return smtp.PlainAuth("", e.config.Username, e.config.Password, e.config.SMTPHost), nil
+ return &plainAuth{"", e.config.Username, e.config.Password}, nil
}
if strings.Contains(mechanisms, "LOGIN") {
- return LoginAuth(e.config.Username, e.config.Password, e.config.SMTPHost), nil
+ return LoginAuth(e.config.Username, e.config.Password), nil
}
// Server didn't advertise AUTH at all — try PLAIN as a default since
// it's the most widely supported. This handles servers that don't
// properly advertise their capabilities.
if !hasAuth || mechanisms == "" {
- return smtp.PlainAuth("", e.config.Username, e.config.Password, e.config.SMTPHost), nil
+ return &plainAuth{"", e.config.Username, e.config.Password}, nil
}
return nil, fmt.Errorf("server advertises AUTH mechanisms [%s] but none are supported (PLAIN, LOGIN)", mechanisms)
diff --git a/internal/notifications/notifications.go b/internal/notifications/notifications.go
index 3e4d43c14d..ab380d4982 100644
--- a/internal/notifications/notifications.go
+++ b/internal/notifications/notifications.go
@@ -330,16 +330,17 @@ type Alert interface {
// EmailConfig holds email notification settings
type EmailConfig struct {
- Enabled bool `json:"enabled"`
- Provider string `json:"provider"` // Email provider name (Gmail, SendGrid, etc.)
- SMTPHost string `json:"server"` // Changed from smtpHost to server for frontend consistency
- SMTPPort int `json:"port"` // Changed from smtpPort to port for frontend consistency
- Username string `json:"username"`
- Password string `json:"password"`
- From string `json:"from"`
- To []string `json:"to"`
- TLS bool `json:"tls"`
- StartTLS bool `json:"startTLS"` // STARTTLS support
+ Enabled bool `json:"enabled"`
+ Provider string `json:"provider"` // Email provider name (Gmail, SendGrid, etc.)
+ SMTPHost string `json:"server"` // Changed from smtpHost to server for frontend consistency
+ SMTPPort int `json:"port"` // Changed from smtpPort to port for frontend consistency
+ Username string `json:"username"`
+ Password string `json:"password"`
+ From string `json:"from"`
+ To []string `json:"to"`
+ TLS bool `json:"tls"`
+ StartTLS bool `json:"startTLS"` // STARTTLS support
+ RateLimit int `json:"rateLimit"` // Max emails per minute (0 = default 60)
}
// WebhookConfig holds webhook settings
@@ -474,12 +475,16 @@ func (n *NotificationManager) SetEmailConfig(config EmailConfig) {
n.emailConfig = config
// Recreate email manager with new config to preserve rate limiting state
+ rateLimit := config.RateLimit
+ if rateLimit <= 0 {
+ rateLimit = 60
+ }
providerConfig := EmailProviderConfig{
EmailConfig: config,
Provider: "",
MaxRetries: 3,
RetryDelay: 5,
- RateLimit: 60, // Default 60 emails/minute
+ RateLimit: rateLimit,
StartTLS: config.StartTLS,
SkipTLSVerify: false,
AuthRequired: config.Username != "" && config.Password != "",
@@ -1454,6 +1459,10 @@ func (n *NotificationManager) sendHTMLEmailWithError(subject, htmlBody, textBody
if manager == nil {
// Create email manager if not yet initialized
+ rl := config.RateLimit
+ if rl <= 0 {
+ rl = 60
+ }
enhancedConfig := EmailProviderConfig{
EmailConfig: EmailConfig{
From: config.From,
@@ -1467,7 +1476,7 @@ func (n *NotificationManager) sendHTMLEmailWithError(subject, htmlBody, textBody
StartTLS: config.StartTLS,
MaxRetries: 2,
RetryDelay: 3,
- RateLimit: 60,
+ RateLimit: rl,
SkipTLSVerify: false,
AuthRequired: config.Username != "" && config.Password != "",
}
@@ -1516,6 +1525,10 @@ func (n *NotificationManager) sendHTMLEmail(subject, htmlBody, textBody string,
}
// Create enhanced email configuration with proper STARTTLS support
+ rl := config.RateLimit
+ if rl <= 0 {
+ rl = 60
+ }
enhancedConfig := EmailProviderConfig{
EmailConfig: EmailConfig{
From: config.From,
@@ -1529,7 +1542,7 @@ func (n *NotificationManager) sendHTMLEmail(subject, htmlBody, textBody string,
StartTLS: config.StartTLS, // Use the configured StartTLS setting
MaxRetries: 2,
RetryDelay: 3,
- RateLimit: 60,
+ RateLimit: rl,
SkipTLSVerify: false,
AuthRequired: config.Username != "" && config.Password != "",
}