Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(cyclops-cs): fail closed on flag type mismatch (#6858)
r33drichards3af8db7111fe
diff --git a/libs/fleet/backend/auth/flags_test.go b/libs/fleet/backend/auth/flags_test.goindex 1c7a2aeffb..49e4a4d137 100644--- a/libs/fleet/backend/auth/flags_test.go+++ b/libs/fleet/backend/auth/flags_test.go@@ -113,6 +113,19 @@ func TestFlagsDataLoadsCardRequirementExemptSubs(t *testing.T) {}}+func TestComputeFlagsDataFailsClosedOnTypeMismatch(t *testing.T) {+ t.Setenv("CYCLOPS_CS_ADMIN_SUBS", `["admin-sub"]`)+ t.Setenv("CYCLOPS_CS_BILLING_ENABLED", "true")+ if err := featureflags.SetupProvider(context.Background(), "development", featureflags.AWSCredentials{}); err != nil {+ t.Fatalf("setup dev provider: %v", err)+ }++ got := computeFlagsData(context.Background())+ if len(got) != 0 {+ t.Fatalf("computeFlagsData() = %v, want empty flags after type mismatch", got)+ }+}+func asStrings(v any) []string {items, ok := v.([]interface{})if !ok {diff --git a/libs/fleet/backend/auth/middlewares.go b/libs/fleet/backend/auth/middlewares.goindex cb76693894..6670596aaa 100644--- a/libs/fleet/backend/auth/middlewares.go+++ b/libs/fleet/backend/auth/middlewares.go@@ -212,7 +212,12 @@ func computeFlagsData(ctx context.Context) map[string]interface{} {if name == "" {continue}- flags[name] = loadStringList(ctx, ffClient, key)+ items, err := loadStringList(ctx, ffClient, key)+ if err != nil {+ slog.Warn("auth: flag load failed; flags will be empty", "flag", key, "err", err)+ return map[string]interface{}{}+ }+ flags[name] = items}callCtx, cancel := context.WithTimeout(ctx, 3*time.Second)defer cancel()@@ -240,30 +245,27 @@ func opaNameFromFlagKey(key string) string {}// loadStringList resolves a JSON-array flag to []interface{} for OPA's-// input.flags document. The value is StringValue with default "[]"; a-// malformed payload yields an empty list and a warn log so OPA still-// evaluates.+// input.flags document. Evaluation and decoding failures are returned so+// computeFlagsData can discard the entire authorization flag set.//// A 3s per-call deadline keeps an unreachable Parameter Store from// stalling pod startup; the from-env fallback kicks in on timeout.-func loadStringList(ctx context.Context, client *openfeature.Client, flagKey string) []interface{} {+func loadStringList(ctx context.Context, client *openfeature.Client, flagKey string) ([]interface{}, error) {callCtx, cancel := context.WithTimeout(ctx, 3*time.Second)defer cancel()raw, err := client.StringValue(callCtx, flagKey, "[]", openfeature.EvaluationContext{})if err != nil {- slog.Warn("auth: flag eval failed; using empty list", "flag", flagKey, "err", err)- return []interface{}{}+ return nil, fmt.Errorf("evaluate %s as string list: %w", flagKey, err)}var items []stringif err := json.Unmarshal([]byte(raw), &items); err != nil {- slog.Warn("auth: flag value is not a JSON string array; using empty list", "flag", flagKey, "err", err)- return []interface{}{}+ return nil, fmt.Errorf("decode %s as JSON string array: %w", flagKey, err)}out := make([]interface{}, len(items))for i, v := range items {out[i] = v}- return out+ return out, nil}// LoadOpa prepares the embedded Rego policy and all derived queries.