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.

Validate source-adapter filters

rcourtmand6ad348dfa18
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 662efafdca..318cf7a47d 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -100,6 +100,9 @@ Those same dedicated reads also accept governed timeline filters for change
kind, source type, and source adapter, and the underlying store owns the
filtered counts so agent lifecycle routing still stays on canonical
fleet-continuity ownership instead of re-deriving resource history locally.
+Invalid `sourceAdapter` values are rejected at the API boundary, so the fleet
+lane continues to consume only the canonical adapter set rather than
+introducing a broader compatibility escape hatch.
The dedicated profile client now also routes list, schema, and validation
parsing through shared response helpers in `frontend-modern/src/api/agentProfiles.ts`,
so profile transport stays aligned with the governed API contract instead of
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 252502f1f3..dfd0c01083 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -127,6 +127,9 @@ Those history reads now also accept governed `kind`, `sourceType`, and
`sourceAdapter` query filters, and the backend store owns the corresponding
filtered counts, so the timeline contract can narrow by change class and
adapter provenance without inventing a frontend-only slice of the graph.
+Invalid `sourceAdapter` values are rejected at the API boundary, so the filter
+contract stays aligned with the canonical adapter set rather than silently
+falling back to an empty slice.
The same API contract now also exposes the unified-resource control-plane
history through dedicated enterprise audit reads. The action, lifecycle, and
export history endpoints live in `internal/api/activity_audit_handlers.go` and
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index f95b135dd4..94ba38ff70 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -124,6 +124,9 @@ Those resource timeline reads now also accept governed kind and source-type
filters plus source-adapter filters, with filtered history counts owned by the
unified-resource store so storage and recovery views can consume the same
canonical history contract without re-deriving their own timeline slices.
+Invalid `sourceAdapter` values are rejected at the API boundary, which keeps
+storage and recovery reads aligned with the canonical adapter set instead of
+turning the timeline filter into an arbitrary free-text escape hatch.
The shared unified-resource consumer hook now also preserves `capabilities`,
`relationships`, `recentChanges`, `facetCounts`, `policy`, and `aiSafeSummary`
fields when storage and recovery surfaces read unified resources, so those
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index daa0131c3f..4b203e585e 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -205,6 +205,9 @@ The same timeline and facet-bundle reads now also accept governed `kind` and
`sourceType` filters, plus a governed `sourceAdapter` filter for adapter-level
provenance drill-down, so history can narrow by canonical change class and
integration source while the store still owns the filtered total counts.
+Invalid `sourceAdapter` values are rejected at the API boundary, keeping the
+timeline query contract aligned with the canonical adapter set instead of
+silently accepting arbitrary strings.
The Connected infrastructure settings surface now also depends on a backend
owned `connectedInfrastructure` projection derived from unified resources plus
reporting-ignore state. That projection is now also the only v6 client
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 5b496baade..bb4b0f64dd 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -6,6 +6,7 @@ import (
"encoding/json"
"net/http"
"net/http/httptest"
+ "net/url"
"os"
"path/filepath"
"reflect"
@@ -3849,6 +3850,15 @@ func TestContract_ResourceFacetsJSONSnapshot(t *testing.T) {
assertJSONSnapshot(t, got, want)
}
+func TestContract_ResourceTimelineRejectsInvalidSourceAdapter(t *testing.T) {
+ _, err := parseResourceChangeFilters(url.Values{
+ "sourceAdapter": []string{"unsupported_adapter"},
+ })
+ if err == nil {
+ t.Fatal("expected invalid sourceAdapter to be rejected")
+ }
+}
+
func TestContract_UnifiedActionAuditsJSONSnapshot(t *testing.T) {
now := time.Date(2026, 3, 18, 16, 0, 0, 0, time.UTC)
payload := struct {
diff --git a/internal/api/resources.go b/internal/api/resources.go
index e9602e4908..a54ca18007 100644
--- a/internal/api/resources.go
+++ b/internal/api/resources.go
@@ -365,11 +365,22 @@ func parseResourceChangeSourceAdapters(values []string) ([]unified.ChangeSourceA
parsed := make([]unified.ChangeSourceAdapter, 0, len(values))
for _, value := range values {
for _, token := range strings.Split(value, ",") {
- normalized := strings.TrimSpace(token)
+ normalized := strings.TrimSpace(strings.ToLower(token))
if normalized == "" {
continue
}
- parsed = append(parsed, unified.ChangeSourceAdapter(normalized))
+ switch normalized {
+ case string(unified.AdapterDocker):
+ parsed = append(parsed, unified.AdapterDocker)
+ case string(unified.AdapterProxmox):
+ parsed = append(parsed, unified.AdapterProxmox)
+ case string(unified.AdapterTrueNAS):
+ parsed = append(parsed, unified.AdapterTrueNAS)
+ case string(unified.AdapterOpsAgent):
+ parsed = append(parsed, unified.AdapterOpsAgent)
+ default:
+ return nil, fmt.Errorf("invalid sourceAdapter value %q", token)
+ }
}
}
return parsed, nil
diff --git a/internal/api/resources_test.go b/internal/api/resources_test.go
index 50c8962d6d..47b177fa0e 100644
--- a/internal/api/resources_test.go
+++ b/internal/api/resources_test.go
@@ -1177,6 +1177,15 @@ func TestResourceGetFacetsAndTimeline(t *testing.T) {
t.Fatalf("unexpected adapter-filtered facets change: %#v", payload.RecentChanges[0])
}
})
+
+ t.Run("invalid source adapter filter", func(t *testing.T) {
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest(http.MethodGet, "/api/resources/vm:42/timeline?sourceAdapter=unknown_adapter", nil)
+ h.HandleResourceRoutes(rec, req)
+ if rec.Code != http.StatusBadRequest {
+ t.Fatalf("status = %d, body=%s", rec.Code, rec.Body.String())
+ }
+ })
}
func containsSource(sources []unified.DataSource, target unified.DataSource) bool {
diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.go
index 5f9c6a698f..297433ad0e 100644
--- a/internal/unifiedresources/code_standards_test.go
+++ b/internal/unifiedresources/code_standards_test.go
@@ -249,6 +249,7 @@ func TestResourceAPIExposesDedicatedFacetReads(t *testing.T) {
"GetRecentChangesFiltered(resourceID, since, limit, filters)",
"CountRecentChangesFiltered(resourceID, since, filters)",
"sourceAdapter",
+ "invalid sourceAdapter value",
"strings.HasSuffix(r.URL.Path, \"/facets\")",
"strings.HasSuffix(r.URL.Path, \"/capabilities\")",
"strings.HasSuffix(r.URL.Path, \"/relationships\")",