mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-03 18:43:38 +01:00
I added Schema v26 content-free Infrastructure Map topology read telemetry for external live GET /api/agent/topology requests (total read days, CLI days, MCP days, anonymized days, and an explicit availability flag) alongside hardened opt-out zero-write boundaries, credential-binding checks, and read-only SQLite/config guards. Key changes: - Added a dedicated root-scoped daily tally store (infrastructure_map_topology_tally.json) with strict schema validation, fail-closed degraded sidecar accounting, and strict zero-write guarantees when telemetry is disabled by settings or PULSE_TELEMETRY=false. - Added X-Pulse-Agent-Surface attribution for pulse-cli and MCP clients while filtering out first-party browser traffic, mock-mode snapshots, and unverified monitor states. - Updated Settings payload preview, localization copy, shipped PRIVACY.md disclosure, integration specs, and schema parity tooling for Schema v26. - Hardened host/agent token hash binding, self-uninstall live authority and durable hash-scoped tombstones, Patrol investigation replay-floor provenance, bounded non-blocking regular-file config reads, and cold read-only legacy SQLite history queries.
94 lines
3.8 KiB
Go
94 lines
3.8 KiB
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/rcourtman/pulse-go-rewrite/internal/config"
|
|
"github.com/rcourtman/pulse-go-rewrite/internal/utils"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
// RuntimeDisplayResponse is the presentation-only slice of system settings that
|
|
// every authenticated session needs to render the app shell as configured. It
|
|
// follows the same rule as RuntimeBrandingResponse: define an explicit whitelist
|
|
// rather than projecting config.SystemSettings, which also contains sensitive
|
|
// operator configuration.
|
|
//
|
|
// Adding a field here publishes it to every authenticated viewer, including
|
|
// non-admins and monitoring:read API tokens. Only add values that control how the
|
|
// authenticated shell renders.
|
|
type RuntimeDisplayResponse struct {
|
|
Theme string `json:"theme"`
|
|
FullWidthMode bool `json:"fullWidthMode"`
|
|
DisableDockerUpdateActions bool `json:"disableDockerUpdateActions"`
|
|
TelemetryEnabled bool `json:"telemetryEnabled"`
|
|
ReduceProUpsellNoise bool `json:"reduceProUpsellNoise"`
|
|
// PVEPollingInterval is the effective PVE polling cadence in seconds. The
|
|
// Settings shell renders it read-only for viewers; without it the
|
|
// Monitoring Cadence card falls back to the Realtime preset and misreports
|
|
// how often the server actually polls.
|
|
PVEPollingInterval int `json:"pvePollingInterval"`
|
|
}
|
|
|
|
// HandleGetRuntimeDisplay returns the effective display defaults needed by an
|
|
// authenticated session without widening access to the admin settings payload.
|
|
func (h *SystemSettingsHandler) HandleGetRuntimeDisplay(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
writeErrorResponse(w, http.StatusMethodNotAllowed, "method_not_allowed", "Method not allowed", nil)
|
|
return
|
|
}
|
|
|
|
cfg := h.currentConfig()
|
|
response := RuntimeDisplayResponse{TelemetryEnabled: true}
|
|
if h != nil {
|
|
response.TelemetryEnabled = ResolveEffectiveTelemetryEnabled(cfg, h.persistence)
|
|
}
|
|
disableDockerEnvLocked := false
|
|
if cfg != nil {
|
|
// Match HandleGetSystemSettings so the environment override wins over
|
|
// the persisted value for every role. These booleans reveal only the
|
|
// effective operator policy, not the admin-only configuration or
|
|
// telemetry payload.
|
|
config.Mu.RLock()
|
|
response.DisableDockerUpdateActions = cfg.DisableDockerUpdateActions
|
|
disableDockerEnvLocked = cfg.EnvOverrides["disableDockerUpdateActions"] || cfg.EnvOverrides["PULSE_DISABLE_DOCKER_UPDATE_ACTIONS"]
|
|
// config carries the effective interval for every role: persisted
|
|
// settings are applied to it at startup unless PVE_POLLING_INTERVAL
|
|
// wins, and runtime saves mutate it. HandleGetSystemSettings serves
|
|
// exactly this value to admins, so serving it here keeps both roles
|
|
// reading the same number.
|
|
response.PVEPollingInterval = int(cfg.PVEPollingInterval.Seconds())
|
|
config.Mu.RUnlock()
|
|
}
|
|
|
|
if h == nil || h.persistence == nil {
|
|
_ = utils.WriteJSONResponse(w, response)
|
|
return
|
|
}
|
|
|
|
settings, err := h.persistence.LoadSystemSettings()
|
|
if err != nil {
|
|
log.Warn().Err(err).Msg("Failed to load runtime display settings")
|
|
_ = utils.WriteJSONResponse(w, response)
|
|
return
|
|
}
|
|
if settings != nil {
|
|
response.Theme = settings.Theme
|
|
response.FullWidthMode = settings.FullWidthMode
|
|
response.ReduceProUpsellNoise = settings.ReduceProUpsellNoise
|
|
if cfg == nil || !disableDockerEnvLocked {
|
|
response.DisableDockerUpdateActions = settings.DisableDockerUpdateActions
|
|
}
|
|
// Unlike the booleans above, persisted state is only a fallback for a
|
|
// missing runtime config, never an override of it — config is already
|
|
// the effective value.
|
|
if response.PVEPollingInterval <= 0 && settings.PVEPollingInterval > 0 {
|
|
response.PVEPollingInterval = settings.PVEPollingInterval
|
|
}
|
|
}
|
|
|
|
if err := utils.WriteJSONResponse(w, response); err != nil {
|
|
log.Error().Err(err).Msg("Failed to write runtime display response")
|
|
}
|
|
}
|