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.

Guard SSH key generation in containers

rcourtmanf8c4a28600b3
diff --git a/internal/api/security_regression_test.go b/internal/api/security_regression_test.go
index 1761d7923b..29c6dc3418 100644
--- a/internal/api/security_regression_test.go
+++ b/internal/api/security_regression_test.go
@@ -4,8 +4,11 @@ import (
"bytes"
"context"
"encoding/json"
+ "errors"
"net/http"
"net/http/httptest"
+ "os"
+ "path/filepath"
"strconv"
"strings"
"testing"
@@ -2799,6 +2802,24 @@ func TestPublicEndpointsBypassAuthInAPIMode(t *testing.T) {
}
}
+func TestSSHKeyGenerationBlockedInContainer(t *testing.T) {
+ t.Setenv("PULSE_DOCKER", "true")
+ t.Setenv("PULSE_DEV_ALLOW_CONTAINER_SSH", "")
+ homeDir := t.TempDir()
+ t.Setenv("HOME", homeDir)
+
+ handler := NewConfigHandlers(nil, nil, func() error { return nil }, nil, nil, func() {})
+ keys := handler.getOrGenerateSSHKeys()
+ if keys.SensorsPublicKey != "" {
+ t.Fatalf("expected empty key when container SSH generation is blocked")
+ }
+
+ pubKeyPath := filepath.Join(homeDir, ".ssh", "id_ed25519_sensors.pub")
+ if _, err := os.Stat(pubKeyPath); !errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("expected no key files to be written, got err=%v", err)
+ }
+}
+
func TestOIDCLoginBypassesAuth(t *testing.T) {
cfg := newTestConfigWithTokens(t)
cfg.AuthUser = "admin"