diff --git a/internal/registry/controller/plugin_controller.go b/internal/registry/controller/plugin_controller.go index ec54374c9..14531fc6f 100644 --- a/internal/registry/controller/plugin_controller.go +++ b/internal/registry/controller/plugin_controller.go @@ -13,6 +13,7 @@ import ( "github.com/agentregistry-dev/agentregistry/internal/cli/common/gitutil" "github.com/agentregistry-dev/agentregistry/internal/registry/plugins/bundle" + "github.com/agentregistry-dev/agentregistry/internal/registry/plugins/format" "github.com/agentregistry-dev/agentregistry/internal/registry/plugins/source" "github.com/agentregistry-dev/agentregistry/pkg/api/v1alpha1" pkgdb "github.com/agentregistry-dev/agentregistry/pkg/registry/database" @@ -266,14 +267,12 @@ func (c *PluginController) enqueueAll(ctx context.Context) error { const pluginReadyCondition = "Ready" -// pluginReconciled reports whether the controller has already acted on the -// plugin's current generation. It gates on ObservedGeneration ALONE (not -// Ready), because both success and terminal failure advance ObservedGeneration -// — a terminally-failed plugin must NOT be re-resolved on every resync tick. -// Retryable failures intentionally leave ObservedGeneration behind so they are -// re-enqueued (and the workqueue rate-limiter backs them off). +// pluginReconciled reports whether the current generation was scanned with +// the current rules. Retryable failures record neither, so they retry. Any +// other scan version rescans, including a newer one after a rollback. func pluginReconciled(p *v1alpha1.Plugin) bool { - return p.Metadata.Generation > 0 && p.Status.ObservedGeneration >= p.Metadata.Generation + return p.Metadata.Generation > 0 && p.Status.ObservedGeneration >= p.Metadata.Generation && + p.Status.ScanVersion == v1alpha1.PluginScanVersion } func (c *PluginController) reconcileKey(ctx context.Context, key pluginQueueKey) (outcome, message string, err error) { @@ -320,33 +319,49 @@ func (c *PluginController) reconcile(ctx context.Context, p *v1alpha1.Plugin) (s resolved, b, err := source.Resolve(ctx, p, c.Git) if err != nil { reason, terminal := classifyResolveErr(err) - bump := int64(0) if terminal { - bump = gen + return "failed", reason, c.patchStatus(ctx, ns, name, tag, gen, terminalStatus(reason, err)) } - patchErr := c.patchStatus(ctx, ns, name, tag, bump, func(st *v1alpha1.PluginStatus) { + _ = c.patchStatus(ctx, ns, name, tag, 0, func(st *v1alpha1.PluginStatus) { setReady(st, v1alpha1.ConditionFalse, reason, err.Error()) }) - if terminal { - return "failed", reason, patchErr - } return "", "", err // retryable } - manifest, err := bundle.ParseManifest(b) + resolvedPatch, err := scanStatus(resolved, b) if err != nil { - return "failed", "SourceInvalid", c.patchStatus(ctx, ns, name, tag, gen, func(st *v1alpha1.PluginStatus) { - setReady(st, v1alpha1.ConditionFalse, "SourceInvalid", err.Error()) - }) + return "failed", "SourceInvalid", c.patchStatus(ctx, ns, name, tag, gen, terminalStatus("SourceInvalid", err)) } - inventory := bundle.BuildInventory(b) + return "resolved", "", c.patchStatus(ctx, ns, name, tag, gen, resolvedPatch) +} - return "resolved", "", c.patchStatus(ctx, ns, name, tag, gen, func(st *v1alpha1.PluginStatus) { - st.ResolvedSource = resolved - st.Manifest = manifest - st.Inventory = inventory +// scanStatus scans a resolved bundle and returns the Ready=True status to +// record. Errors wrap bundle.ErrInvalidBundle. +func scanStatus(resolved *v1alpha1.PluginResolvedSource, b *bundle.CanonicalBundle) (func(*v1alpha1.PluginStatus), error) { + pluginFormat, manifestPath, err := format.Detect(b) + if err != nil { + return nil, err + } + manifest, err := bundle.ParseManifest(b, manifestPath) + if err != nil { + return nil, err + } + inventory := bundle.BuildInventory(b) + return func(st *v1alpha1.PluginStatus) { + st.ResolvedSource, st.Manifest, st.Inventory = resolved, manifest, inventory + st.Format, st.ScanVersion = pluginFormat, v1alpha1.PluginScanVersion setReady(st, v1alpha1.ConditionTrue, "Resolved", "") - }) + }, nil +} + +// terminalStatus records a terminal failure at the current scan version. It +// keeps ResolvedSource, because Deployment fingerprints read it. +func terminalStatus(reason string, err error) func(*v1alpha1.PluginStatus) { + return func(st *v1alpha1.PluginStatus) { + st.Manifest, st.Inventory = nil, nil + st.Format, st.ScanVersion = "", v1alpha1.PluginScanVersion + setReady(st, v1alpha1.ConditionFalse, reason, err.Error()) + } } // classifyResolveErr maps a resolver error to a status reason and whether it is diff --git a/internal/registry/controller/plugin_controller_test.go b/internal/registry/controller/plugin_controller_test.go index 4d87ce5fe..51cf6048a 100644 --- a/internal/registry/controller/plugin_controller_test.go +++ b/internal/registry/controller/plugin_controller_test.go @@ -3,7 +3,9 @@ package controller import ( "errors" "fmt" + "reflect" "testing" + "time" "github.com/agentregistry-dev/agentregistry/internal/registry/plugins/bundle" "github.com/agentregistry-dev/agentregistry/internal/registry/plugins/source" @@ -31,26 +33,100 @@ func TestClassifyResolveErr(t *testing.T) { } } +// TestPluginReconciled checks the gate on ObservedGeneration and ScanVersion. +// Ready true/false is irrelevant: a terminal failure must NOT re-resolve every tick. func TestPluginReconciled(t *testing.T) { - plugin := func(observed, gen int64, ready v1alpha1.ConditionStatus) *v1alpha1.Plugin { - p := &v1alpha1.Plugin{} - p.Metadata.Generation = gen - p.Status.ObservedGeneration = observed - p.Status.SetCondition(v1alpha1.Condition{Type: pluginReadyCondition, Status: ready, Reason: "x"}) - return p + const current = v1alpha1.PluginScanVersion + tests := []struct { + name string + observed, generation, scanVersion int64 + ready v1alpha1.ConditionStatus + want bool + }{ + {"success at current generation", 3, 3, current, v1alpha1.ConditionTrue, true}, + {"terminal failure at current generation", 3, 3, current, v1alpha1.ConditionFalse, true}, + {"retryable or pending", 2, 3, current, v1alpha1.ConditionFalse, false}, + {"fresh plugin with generation 0", 0, 0, 0, "", false}, + {"older scan version rescans", 3, 3, current - 1, v1alpha1.ConditionTrue, false}, + {"newer scan version after a rollback rescans", 3, 3, current + 1, v1alpha1.ConditionTrue, false}, } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + p := &v1alpha1.Plugin{} + p.Metadata.Generation = tt.generation + p.Status.ObservedGeneration = tt.observed + p.Status.ScanVersion = tt.scanVersion + p.Status.SetCondition(v1alpha1.Condition{Type: pluginReadyCondition, Status: tt.ready, Reason: "x"}) + if got := pluginReconciled(p); got != tt.want { + t.Fatalf("pluginReconciled = %v, want %v", got, tt.want) + } + }) + } +} - // Gates on ObservedGeneration only; Ready true/false is irrelevant. - if !pluginReconciled(plugin(3, 3, v1alpha1.ConditionTrue)) { - t.Fatal("observed==gen (success) should be reconciled") +func TestScanStatus(t *testing.T) { + resolved := &v1alpha1.PluginResolvedSource{Type: v1alpha1.PluginSourceTypeGit, Commit: "abc123"} + agentPlugins := &bundle.CanonicalBundle{Files: map[string][]byte{ + "plugin.json": []byte(`{"$schema":"https://agent-plugins.org/schemas/1.0.0/plugin.schema.json","name":"acme.test","version":"1.0.0"}`), + "mcp.json": []byte(`{"$schema":"https://agent-plugins.org/schemas/1.0.0/mcp.schema.json","mcpServers":{"search":{"type":"streamable-http","url":"https://example.com/mcp"}}}`), + ".mcp.json": []byte(`{"mcpServers":{"claude-only":{"url":"https://example.com/mcp"}}}`), + "skills/review/SKILL.md": []byte("---\nname: review\n---\n"), + }} + mutate, err := scanStatus(resolved, agentPlugins) + if err != nil { + t.Fatalf("scanStatus: %v", err) } - if !pluginReconciled(plugin(3, 3, v1alpha1.ConditionFalse)) { - t.Fatal("observed==gen (terminal failure) should be reconciled — must NOT re-resolve every tick") + got := v1alpha1.PluginStatus{Format: v1alpha1.PluginFormatClaudePlugin} + mutate(&got) + want := v1alpha1.PluginStatus{ + ResolvedSource: resolved, + Manifest: &v1alpha1.PluginManifest{Schema: "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json", Name: "acme.test", Version: "1.0.0"}, + Inventory: &v1alpha1.PluginInventory{Skills: []v1alpha1.PluginSkill{{Name: "review"}}, MCPServers: []string{"claude-only"}}, + Format: v1alpha1.PluginFormatAgentPlugins, + ScanVersion: v1alpha1.PluginScanVersion, } - if pluginReconciled(plugin(2, 3, v1alpha1.ConditionFalse)) { - t.Fatal("observed= maxFiles { - return fmt.Errorf("%w: too many files (limit %d)", ErrInvalidBundle, maxFiles) - } - info, err := d.Info() - if err != nil { - return err - } - if totalBytes+info.Size() > maxBytes { - return fmt.Errorf("%w: bundle exceeds %d bytes", ErrInvalidBundle, maxBytes) - } - data, err := os.ReadFile(p) - if err != nil { - return err - } - totalBytes += int64(len(data)) - files[rel] = data - return nil - }) - if walkErr != nil { + w := &treeWalker{root: dir, maxFiles: maxFiles, maxBytes: maxBytes, + bundle: &CanonicalBundle{Files: map[string][]byte{}, Dirs: map[string]bool{}}} + if err := filepath.WalkDir(dir, w.visit); err != nil { // Preserve a wrapped ErrInvalidBundle (size/traversal) as terminal; // wrap any other walk/IO error so the caller sees a bundle error. - if errors.Is(walkErr, ErrInvalidBundle) { - return nil, walkErr + if errors.Is(err, ErrInvalidBundle) { + return nil, err } - return nil, fmt.Errorf("%w: read source tree: %v", ErrInvalidBundle, walkErr) + return nil, fmt.Errorf("%w: read source tree: %w", ErrInvalidBundle, err) + } + return w.bundle, nil +} + +// treeWalker loads one source tree into a bundle within the size limits. +type treeWalker struct { + root string + maxFiles int + maxBytes int64 + totalBytes int64 + bundle *CanonicalBundle +} + +func (w *treeWalker) visit(p string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + rel, err := filepath.Rel(w.root, p) + if err != nil { + return err + } + rel = filepath.ToSlash(rel) + if d.IsDir() { + return w.visitDir(rel, d) } - return &CanonicalBundle{Files: files}, nil + // Skip symlinks (and any other irregular files) to avoid traversal out + // of the source tree via a malicious link. + if d.Type()&os.ModeSymlink != 0 || !d.Type().IsRegular() { + return nil + } + return w.visitFile(rel, d) +} + +// visitDir records a directory. It skips .git and the root. +func (w *treeWalker) visitDir(rel string, d fs.DirEntry) error { + if d.Name() == ".git" { + return filepath.SkipDir + } + if rel == "." { + return nil + } + if err := validateBundlePath(rel); err != nil { + return err + } + w.bundle.Dirs[rel] = true + return nil +} + +func (w *treeWalker) visitFile(rel string, d fs.DirEntry) error { + if err := validateBundlePath(rel); err != nil { + return err + } + if err := w.checkLimits(d); err != nil { + return err + } + data, err := os.ReadFile(filepath.Join(w.root, filepath.FromSlash(rel))) + if err != nil { + return err + } + w.totalBytes += int64(len(data)) + w.bundle.Files[rel] = data + return nil +} + +// checkLimits bounds file count and cumulative size before reading, so a +// hostile or runaway repo cannot exhaust memory. It checks the size from the +// dir entry, so an oversized file is never read. +func (w *treeWalker) checkLimits(d fs.DirEntry) error { + if len(w.bundle.Files) >= w.maxFiles { + return fmt.Errorf("%w: too many files (limit %d)", ErrInvalidBundle, w.maxFiles) + } + info, err := d.Info() + if err != nil { + return err + } + if w.totalBytes+info.Size() > w.maxBytes { + return fmt.Errorf("%w: bundle exceeds %d bytes", ErrInvalidBundle, w.maxBytes) + } + return nil } // validateBundlePath rejects empty, absolute, non-clean, backslash, and diff --git a/internal/registry/plugins/bundle/bundle_test.go b/internal/registry/plugins/bundle/bundle_test.go index 51c19508f..388ca6e25 100644 --- a/internal/registry/plugins/bundle/bundle_test.go +++ b/internal/registry/plugins/bundle/bundle_test.go @@ -16,6 +16,10 @@ func TestFromDir(t *testing.T) { writeFile(t, root, "bin/tool", "#!/bin/sh\n") // A .git directory must be skipped wholesale. writeFile(t, root, ".git/config", "[core]\n") + // An empty directory holds no file, so only Dirs can show it. + if err := os.Mkdir(filepath.Join(root, "empty"), 0o755); err != nil { + t.Fatal(err) + } b, err := FromDir(root) if err != nil { @@ -30,6 +34,10 @@ func TestFromDir(t *testing.T) { if !reflect.DeepEqual(b.Files, want) { t.Fatalf("FromDir files mismatch:\n got %v\n want %v", b.Files, want) } + wantDirs := map[string]bool{".claude-plugin": true, "skills": true, "skills/deploy": true, "bin": true, "empty": true} + if !reflect.DeepEqual(b.Dirs, wantDirs) { + t.Fatalf("FromDir dirs mismatch:\n got %v\n want %v", b.Dirs, wantDirs) + } } func TestFromDirSkipsSymlinks(t *testing.T) { @@ -51,6 +59,16 @@ func TestFromDirSkipsSymlinks(t *testing.T) { } } +func TestFromDirRejectsBackslashDirectory(t *testing.T) { + root := t.TempDir() + if err := os.Mkdir(filepath.Join(root, `a\b`), 0o755); err != nil { + t.Skipf("backslash directory name unsupported: %v", err) + } + if _, err := FromDir(root); !errors.Is(err, ErrInvalidBundle) { + t.Fatalf("expected ErrInvalidBundle, got %v", err) + } +} + func TestValidateBundlePathTraversal(t *testing.T) { for _, p := range []string{"", "../evil", "/abs", "a/../../b", "a\\b", "a/./b"} { if err := validateBundlePath(p); !errors.Is(err, ErrInvalidBundle) { diff --git a/internal/registry/plugins/bundle/manifest.go b/internal/registry/plugins/bundle/manifest.go index bf760628c..496c37bdd 100644 --- a/internal/registry/plugins/bundle/manifest.go +++ b/internal/registry/plugins/bundle/manifest.go @@ -16,22 +16,40 @@ import ( // ManifestPath is the canonical location of the plugin manifest within a bundle. const ManifestPath = ".claude-plugin/plugin.json" -// ParseManifest parses the bundle's real .claude-plugin/plugin.json into the -// typed, faithful PluginManifest (the canonical lingua-franca manifest). -// Returns (nil, nil) when the bundle ships no manifest, or (nil, err) when the -// manifest is present but malformed (the caller decides whether to fail). -func ParseManifest(b *CanonicalBundle) (*v1alpha1.PluginManifest, error) { - data, ok := b.Files[ManifestPath] +// ParseManifest parses the manifest at path into the typed PluginManifest. It +// drops each key the type cannot parse, because the format rules skip it. It +// returns (nil, nil) when path has no file. +func ParseManifest(b *CanonicalBundle, path string) (*v1alpha1.PluginManifest, error) { + data, ok := b.Files[path] if !ok { return nil, nil } + var fields map[string]json.RawMessage + if err := json.Unmarshal(data, &fields); err != nil { + return nil, fmt.Errorf("%w: parse %s: %w", ErrInvalidBundle, path, err) + } + dropUnparsableKeys(fields) + parsable, err := json.Marshal(fields) + if err != nil { + return nil, fmt.Errorf("%w: parse %s: %w", ErrInvalidBundle, path, err) + } var m v1alpha1.PluginManifest - if err := json.Unmarshal(data, &m); err != nil { - return nil, fmt.Errorf("%w: parse %s: %v", ErrInvalidBundle, ManifestPath, err) + if err := json.Unmarshal(parsable, &m); err != nil { + return nil, fmt.Errorf("%w: parse %s: %w", ErrInvalidBundle, path, err) } return &m, nil } +// dropUnparsableKeys deletes each key whose value the typed manifest rejects. +func dropUnparsableKeys(fields map[string]json.RawMessage) { + for key, value := range fields { + single, err := json.Marshal(map[string]json.RawMessage{key: value}) + if err != nil || json.Unmarshal(single, &v1alpha1.PluginManifest{}) != nil { + delete(fields, key) + } + } +} + // BuildInventory indexes a canonical bundle into a PluginInventory: the skills, // sub-agents, commands, MCP servers, hooks, and bin/ executables it actually // ships — the legible governance risk surface, derived by scanning bundle files diff --git a/internal/registry/plugins/bundle/manifest_test.go b/internal/registry/plugins/bundle/manifest_test.go index 167e5dfa3..4c3782925 100644 --- a/internal/registry/plugins/bundle/manifest_test.go +++ b/internal/registry/plugins/bundle/manifest_test.go @@ -62,23 +62,45 @@ func TestBuildInventoryBestEffortOnMalformed(t *testing.T) { func TestParseManifest(t *testing.T) { // Absent manifest -> nil, no error. - if m, err := ParseManifest(&CanonicalBundle{Files: map[string][]byte{"SKILL.md": []byte("x")}}); err != nil || m != nil { + if m, err := ParseManifest(&CanonicalBundle{Files: map[string][]byte{"SKILL.md": []byte("x")}}, ManifestPath); err != nil || m != nil { t.Fatalf("absent manifest: got (%v, %v), want (nil, nil)", m, err) } // Real plugin.json -> typed manifest. b := &CanonicalBundle{Files: map[string][]byte{ ManifestPath: []byte(`{"name":"company-deploy","version":"1.2.0","author":{"name":"Maya"},"keywords":["deploy"]}`), }} - m, err := ParseManifest(b) + m, err := ParseManifest(b, ManifestPath) if err != nil { t.Fatalf("parse: %v", err) } if m == nil || m.Name != "company-deploy" || m.Version != "1.2.0" || m.Author == nil || m.Author.Name != "Maya" { t.Fatalf("typed manifest not parsed: %+v", m) } + // Root Agent Plugins plugin.json -> same typed manifest, extensions in Extras. + agent := &CanonicalBundle{Files: map[string][]byte{ + "plugin.json": []byte(`{"$schema":"https://agent-plugins.org/schemas/1.0.0/plugin.schema.json","name":"acme.test","description":"Tools","extensions":{"x":1}}`), + }} + m, err = ParseManifest(agent, "plugin.json") + if err != nil { + t.Fatalf("parse agent-plugins manifest: %v", err) + } + if m == nil || m.Name != "acme.test" || m.Description != "Tools" || string(m.Extras["extensions"]) != `{"x":1}` { + t.Fatalf("agent-plugins manifest not parsed: %+v", m) + } + // A key the typed manifest cannot parse is dropped; the other keys stay. + ignored := &CanonicalBundle{Files: map[string][]byte{ + ManifestPath: []byte(`{"name":"a","hooks":5,"commands":"./cmds"}`), + }} + m, err = ParseManifest(ignored, ManifestPath) + if err != nil { + t.Fatalf("parse manifest with unparsable key: %v", err) + } + if m == nil || m.Name != "a" || m.Hooks != nil || m.Commands == nil { + t.Fatalf("unparsable key not dropped alone: %+v", m) + } // Malformed manifest -> error (fail closed). bad := &CanonicalBundle{Files: map[string][]byte{ManifestPath: []byte("{not json")}} - if _, err := ParseManifest(bad); err == nil { + if _, err := ParseManifest(bad, ManifestPath); err == nil { t.Fatal("expected error for malformed manifest") } } diff --git a/internal/registry/plugins/format/format.go b/internal/registry/plugins/format/format.go new file mode 100644 index 000000000..715065e31 --- /dev/null +++ b/internal/registry/plugins/format/format.go @@ -0,0 +1,140 @@ +// Package format detects a plugin bundle's layout from its manifest files. +// Raise v1alpha1.PluginScanVersion with any change to these rules. +package format + +import ( + "bytes" + "encoding/json" + "fmt" + "regexp" + "strings" + + "github.com/agentregistry-dev/agentregistry/internal/registry/plugins/bundle" + "github.com/agentregistry-dev/agentregistry/pkg/api/v1alpha1" +) + +const ( + agentPluginsManifest = "plugin.json" + agentPluginsSchema = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json" + maxNameLength = 64 +) + +var namePattern = regexp.MustCompile(`^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$`) + +// manifestKeys are the only manifest keys the rules check. Other keys are ignored. +var manifestKeys = map[string]bool{ + "$schema": true, "name": true, "version": true, "description": true, "author": true, + "homepage": true, "repository": true, "license": true, "keywords": true, "extensions": true, +} + +// manifest holds the checked keys with the JSON types they require. +type manifest struct { + Schema string `json:"$schema"` + Name string `json:"name"` + Version string `json:"version,omitempty"` + Description string `json:"description,omitempty"` + Author *manifestAuthor `json:"author,omitempty"` + Homepage string `json:"homepage,omitempty"` + Repository string `json:"repository,omitempty"` + License string `json:"license,omitempty"` + Keywords []string `json:"keywords,omitempty"` + Extensions map[string]json.RawMessage `json:"extensions,omitempty"` +} + +// manifestAuthor is the object form of author, the only form allowed. +type manifestAuthor struct { + Name string `json:"name,omitempty"` + Email string `json:"email,omitempty"` + URL string `json:"url,omitempty"` +} + +// Detect returns the format of b and the path of the manifest the rules +// selected. Every rejection wraps bundle.ErrInvalidBundle. +func Detect(b *bundle.CanonicalBundle) (v1alpha1.PluginFormat, string, error) { + path, format, err := selectManifest(b) + if err != nil { + return "", "", err + } + if err := checkManifest(b.Files[path], format); err != nil { + return "", "", fmt.Errorf("%w: %s: %w", bundle.ErrInvalidBundle, path, err) + } + return format, path, nil +} + +// selectManifest picks the root plugin.json, else the Claude manifest. +// A manifest path that is a directory is rejected. +func selectManifest(b *bundle.CanonicalBundle) (string, v1alpha1.PluginFormat, error) { + if _, ok := b.Files[agentPluginsManifest]; ok { + return agentPluginsManifest, v1alpha1.PluginFormatAgentPlugins, nil + } + if b.HasDir(agentPluginsManifest) { + return "", "", manifestDirectoryError(agentPluginsManifest) + } + if _, ok := b.Files[bundle.ManifestPath]; ok { + return bundle.ManifestPath, v1alpha1.PluginFormatClaudePlugin, nil + } + if b.HasDir(bundle.ManifestPath) { + return "", "", manifestDirectoryError(bundle.ManifestPath) + } + return "", "", fmt.Errorf("%w: no %s or %s manifest", bundle.ErrInvalidBundle, agentPluginsManifest, bundle.ManifestPath) +} + +func manifestDirectoryError(path string) error { + return fmt.Errorf("%w: %s is a directory", bundle.ErrInvalidBundle, path) +} + +// checkManifest applies the schema and name rules to the selected manifest. +func checkManifest(raw []byte, format v1alpha1.PluginFormat) error { + m, err := decodeManifest(raw) + if err != nil { + return err + } + if format == v1alpha1.PluginFormatAgentPlugins && m.Schema != agentPluginsSchema { + return fmt.Errorf("unsupported plugin schema %q", m.Schema) + } + if !validName(m.Name) { + return fmt.Errorf("invalid plugin name %q", m.Name) + } + return nil +} + +// decodeManifest decodes the checked keys strictly, so a checked key with the +// wrong JSON type fails. +func decodeManifest(raw []byte) (manifest, error) { + kept, err := checkedKeys(raw) + if err != nil { + return manifest{}, err + } + var m manifest + decoder := json.NewDecoder(bytes.NewReader(kept)) + decoder.DisallowUnknownFields() + if err := decoder.Decode(&m); err != nil { + return manifest{}, err + } + return m, nil +} + +// checkedKeys returns raw with only the checked keys. An extensions value that +// is not an object is ignored. +func checkedKeys(raw []byte) ([]byte, error) { + var fields map[string]json.RawMessage + if err := json.Unmarshal(raw, &fields); err != nil { + return nil, err + } + for name := range fields { + if !manifestKeys[name] { + delete(fields, name) + } + } + if ext := fields["extensions"]; len(ext) > 0 && ext[0] != '{' { + delete(fields, "extensions") + } + return json.Marshal(fields) +} + +// validName reports whether name is lowercase letters, digits, dots, and +// dashes, at most 64 characters, with no "--" or "..". +func validName(name string) bool { + return len(name) <= maxNameLength && namePattern.MatchString(name) && + !strings.Contains(name, "--") && !strings.Contains(name, "..") +} diff --git a/internal/registry/plugins/format/format_test.go b/internal/registry/plugins/format/format_test.go new file mode 100644 index 000000000..628775334 --- /dev/null +++ b/internal/registry/plugins/format/format_test.go @@ -0,0 +1,169 @@ +package format + +import ( + "errors" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/agentregistry-dev/agentregistry/internal/registry/plugins/bundle" + "github.com/agentregistry-dev/agentregistry/pkg/api/v1alpha1" +) + +const agentPluginsJSON = `{"$schema":"https://agent-plugins.org/schemas/1.0.0/plugin.schema.json","name":"acme.test"}` + +var detectCases = []struct { + name string + files map[string]string + dirs map[string]bool + wantFormat v1alpha1.PluginFormat + wantPath string + wantErr string +}{ + { + name: "agent-plugins manifest", + files: map[string]string{"plugin.json": agentPluginsJSON, "skills/review/SKILL.md": "x"}, + wantFormat: v1alpha1.PluginFormatAgentPlugins, + wantPath: "plugin.json", + }, + { + name: "claude manifest", + files: map[string]string{".claude-plugin/plugin.json": `{"name":"code-review","author":{"name":"Anthropic"}}`}, + wantFormat: v1alpha1.PluginFormatClaudePlugin, + wantPath: ".claude-plugin/plugin.json", + }, + { + name: "both manifests: root wins", + files: map[string]string{"plugin.json": agentPluginsJSON, ".claude-plugin/plugin.json": `{"name":"acme.test"}`}, + wantFormat: v1alpha1.PluginFormatAgentPlugins, + wantPath: "plugin.json", + }, + { + name: "both manifests: the Claude manifest is never read", + files: map[string]string{"plugin.json": agentPluginsJSON, ".claude-plugin/plugin.json": `{bad`}, + wantFormat: v1alpha1.PluginFormatAgentPlugins, + wantPath: "plugin.json", + }, + { + name: "claude manifest with any $schema", + files: map[string]string{".claude-plugin/plugin.json": `{"$schema":"https://json.schemastore.org/claude-code-plugin-manifest.json","name":"a"}`}, + wantFormat: v1alpha1.PluginFormatClaudePlugin, + wantPath: ".claude-plugin/plugin.json", + }, + { + name: "name of exactly 64 characters", + files: map[string]string{".claude-plugin/plugin.json": `{"name":"` + strings.Repeat("a", 64) + `"}`}, + wantFormat: v1alpha1.PluginFormatClaudePlugin, + wantPath: ".claude-plugin/plugin.json", + }, + { + name: "unknown keys and non-object extensions are ignored", + files: map[string]string{".claude-plugin/plugin.json": `{"name":"a","hooks":5,"interface":{},"extensions":"x"}`}, + wantFormat: v1alpha1.PluginFormatClaudePlugin, + wantPath: ".claude-plugin/plugin.json", + }, + {name: "no manifest", files: map[string]string{"skills/review/SKILL.md": "x"}, wantErr: "no plugin.json or .claude-plugin/plugin.json manifest"}, + {name: "root manifest without schema", files: map[string]string{"plugin.json": `{"name":"acme"}`}, wantErr: `plugin.json: unsupported plugin schema ""`}, + {name: "root manifest with wrong schema", files: map[string]string{"plugin.json": `{"$schema":"https://example.com/s.json","name":"acme"}`}, wantErr: "unsupported plugin schema"}, + {name: "claude manifest without schema is fine but needs a name", files: map[string]string{".claude-plugin/plugin.json": `{}`}, wantErr: `.claude-plugin/plugin.json: invalid plugin name ""`}, + {name: "uppercase name", files: map[string]string{".claude-plugin/plugin.json": `{"name":"Acme"}`}, wantErr: "invalid plugin name"}, + {name: "double dash name", files: map[string]string{".claude-plugin/plugin.json": `{"name":"a--b"}`}, wantErr: "invalid plugin name"}, + {name: "double dot name", files: map[string]string{"plugin.json": `{"$schema":"https://agent-plugins.org/schemas/1.0.0/plugin.schema.json","name":"a..b"}`}, wantErr: "invalid plugin name"}, + {name: "trailing dash name", files: map[string]string{".claude-plugin/plugin.json": `{"name":"a-"}`}, wantErr: "invalid plugin name"}, + {name: "leading dash name", files: map[string]string{".claude-plugin/plugin.json": `{"name":"-a"}`}, wantErr: "invalid plugin name"}, + {name: "leading dot name", files: map[string]string{".claude-plugin/plugin.json": `{"name":".a"}`}, wantErr: "invalid plugin name"}, + {name: "name over 64 characters", files: map[string]string{".claude-plugin/plugin.json": `{"name":"` + strings.Repeat("a", 65) + `"}`}, wantErr: "invalid plugin name"}, + {name: "string author", files: map[string]string{".claude-plugin/plugin.json": `{"name":"a","author":"x"}`}, wantErr: "cannot unmarshal string"}, + {name: "unknown author key", files: map[string]string{".claude-plugin/plugin.json": `{"name":"a","author":{"name":"x","team":"y"}}`}, wantErr: "unknown field"}, + {name: "keywords not strings", files: map[string]string{".claude-plugin/plugin.json": `{"name":"a","keywords":[1]}`}, wantErr: "cannot unmarshal number"}, + {name: "plugin.json directory", files: map[string]string{"plugin.json/x.json": "{}", ".claude-plugin/plugin.json": `{"name":"a"}`}, wantErr: "plugin.json is a directory"}, + {name: "empty plugin.json directory", files: map[string]string{".claude-plugin/plugin.json": `{"name":"a"}`}, dirs: map[string]bool{"plugin.json": true}, wantErr: "plugin.json is a directory"}, + {name: "claude manifest directory", files: map[string]string{".claude-plugin/plugin.json/x.json": "{}"}, wantErr: ".claude-plugin/plugin.json is a directory"}, + {name: "malformed JSON", files: map[string]string{".claude-plugin/plugin.json": `{bad`}, wantErr: "invalid character"}, +} + +func TestDetect(t *testing.T) { + for _, tt := range detectCases { + t.Run(tt.name, func(t *testing.T) { + b := bundleOf(tt.files) + b.Dirs = tt.dirs + format, path, err := Detect(b) + if tt.wantErr != "" { + if !errors.Is(err, bundle.ErrInvalidBundle) || !strings.Contains(err.Error(), tt.wantErr) { + t.Fatalf("err = %v, want ErrInvalidBundle containing %q", err, tt.wantErr) + } + return + } + if err != nil { + t.Fatalf("Detect: %v", err) + } + if format != tt.wantFormat || path != tt.wantPath { + t.Fatalf("Detect = (%q, %q), want (%q, %q)", format, path, tt.wantFormat, tt.wantPath) + } + }) + } +} + +// TestDetectRejectsPluginJSONDirectoryOfLinks runs the loader too: it skips a +// symlink, so a plugin.json directory holding only links looks empty. +func TestDetectRejectsPluginJSONDirectoryOfLinks(t *testing.T) { + root := t.TempDir() + claudeManifest := filepath.Join(root, filepath.FromSlash(bundle.ManifestPath)) + if err := os.MkdirAll(filepath.Dir(claudeManifest), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(claudeManifest, []byte(`{"name":"a"}`), 0o644); err != nil { + t.Fatal(err) + } + if err := os.Mkdir(filepath.Join(root, "plugin.json"), 0o755); err != nil { + t.Fatal(err) + } + if err := os.Symlink(claudeManifest, filepath.Join(root, "plugin.json", "link.json")); err != nil { + t.Skipf("symlink unsupported: %v", err) + } + b, err := bundle.FromDir(root) + if err != nil { + t.Fatalf("FromDir: %v", err) + } + if _, _, err := Detect(b); !errors.Is(err, bundle.ErrInvalidBundle) || !strings.Contains(err.Error(), "plugin.json is a directory") { + t.Fatalf("err = %v, want ErrInvalidBundle for a plugin.json directory", err) + } +} + +// TestDetectCannotSeeSymlinkedManifest pins a known gap: the loader skips a +// symlinked root plugin.json, so Detect picks the Claude manifest instead. +func TestDetectCannotSeeSymlinkedManifest(t *testing.T) { + root := t.TempDir() + writeTestFile(t, filepath.Join(root, filepath.FromSlash(bundle.ManifestPath)), `{"name":"a"}`) + writeTestFile(t, filepath.Join(root, "real.json"), agentPluginsJSON) + if err := os.Symlink("real.json", filepath.Join(root, "plugin.json")); err != nil { + t.Skipf("symlink unsupported: %v", err) + } + b, err := bundle.FromDir(root) + if err != nil { + t.Fatalf("FromDir: %v", err) + } + format, path, err := Detect(b) + if err != nil || format != v1alpha1.PluginFormatClaudePlugin || path != bundle.ManifestPath { + t.Fatalf("Detect = (%q, %q, %v), want the Claude manifest", format, path, err) + } +} + +func writeTestFile(t *testing.T, path, content string) { + t.Helper() + if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(path, []byte(content), 0o644); err != nil { + t.Fatal(err) + } +} + +func bundleOf(files map[string]string) *bundle.CanonicalBundle { + b := &bundle.CanonicalBundle{Files: map[string][]byte{}} + for p, content := range files { + b.Files[p] = []byte(content) + } + return b +} diff --git a/internal/registry/plugins/source/source.go b/internal/registry/plugins/source/source.go index 18ea48b37..c3dd9a374 100644 --- a/internal/registry/plugins/source/source.go +++ b/internal/registry/plugins/source/source.go @@ -90,9 +90,9 @@ func resolveGit(ctx context.Context, namespace string, g *v1alpha1.PluginSourceG func classifyGitErr(err error, context string) error { switch { case errors.Is(err, gitutil.ErrUnsupportedHost): - return fmt.Errorf("%w: %v", ErrUnsupportedSource, err) + return fmt.Errorf("%w: %w", ErrUnsupportedSource, err) case errors.Is(err, gitutil.ErrRefNotFound): - return fmt.Errorf("%w: %v", ErrSourceNotFound, err) + return fmt.Errorf("%w: %w", ErrSourceNotFound, err) default: return fmt.Errorf("%s: %w", context, err) // retryable } diff --git a/openapi.yaml b/openapi.yaml index 2cccd6f4b..6792bd66e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1317,12 +1317,17 @@ components: type: - array - "null" + format: + type: string inventory: $ref: '#/components/schemas/PluginInventory' manifest: $ref: '#/components/schemas/PluginManifest' resolvedSource: $ref: '#/components/schemas/PluginResolvedSource' + scanVersion: + format: int64 + type: integer type: object PluginUserConfigField: additionalProperties: false diff --git a/pkg/api/v1alpha1/accessors.go b/pkg/api/v1alpha1/accessors.go index 48127e79f..ded7f1499 100644 --- a/pkg/api/v1alpha1/accessors.go +++ b/pkg/api/v1alpha1/accessors.go @@ -186,9 +186,9 @@ func (p *Plugin) UnmarshalSpec(data json.RawMessage) error { } // MarshalStatus serializes the typed PluginStatus: the embedded Status via the -// storage codec, with the server-determined ResolvedSource/Manifest/Inventory -// spliced onto the same object. Nil custom fields are omitted (no stray nulls) -// so the store's patch-skip byte comparison stays stable. +// storage codec, with the server-determined ResolvedSource/Manifest/Inventory/ +// Format/ScanVersion spliced onto the same object. Empty custom fields are +// omitted (no stray nulls) so the store's patch-skip byte comparison stays stable. func (p *Plugin) MarshalStatus() (json.RawMessage, error) { base, err := MarshalStatusForStorage(p.Status.Status) if err != nil { @@ -213,6 +213,16 @@ func (p *Plugin) MarshalStatus() (json.RawMessage, error) { return nil, err } } + if p.Status.Format != "" { + if m["format"], err = json.Marshal(p.Status.Format); err != nil { + return nil, err + } + } + if p.Status.ScanVersion != 0 { + if m["scanVersion"], err = json.Marshal(p.Status.ScanVersion); err != nil { + return nil, err + } + } return json.Marshal(m) } @@ -228,11 +238,14 @@ func (p *Plugin) UnmarshalStatus(data json.RawMessage) error { ResolvedSource *PluginResolvedSource `json:"resolvedSource"` Manifest *PluginManifest `json:"manifest"` Inventory *PluginInventory `json:"inventory"` + Format PluginFormat `json:"format"` + ScanVersion int64 `json:"scanVersion"` } if err := json.Unmarshal(data, &custom); err != nil { return err } p.Status.ResolvedSource, p.Status.Manifest, p.Status.Inventory = custom.ResolvedSource, custom.Manifest, custom.Inventory + p.Status.Format, p.Status.ScanVersion = custom.Format, custom.ScanVersion return nil } diff --git a/pkg/api/v1alpha1/plugin.go b/pkg/api/v1alpha1/plugin.go index 52c68c3be..1f7337f78 100644 --- a/pkg/api/v1alpha1/plugin.go +++ b/pkg/api/v1alpha1/plugin.go @@ -61,8 +61,27 @@ type PluginStatus struct { Manifest *PluginManifest `json:"manifest,omitempty" yaml:"manifest,omitempty"` // Inventory is the server-derived risk surface / search index. Inventory *PluginInventory `json:"inventory,omitempty" yaml:"inventory,omitempty"` + // Format is the detected bundle layout. It is empty when the scan + // rejected the bundle. + Format PluginFormat `json:"format,omitempty" yaml:"format,omitempty"` + // ScanVersion is the PluginScanVersion of the rules that produced Format. + ScanVersion int64 `json:"scanVersion,omitempty" yaml:"scanVersion,omitempty"` } +// PluginFormat names a plugin bundle layout, detected from its manifest files. +type PluginFormat string + +const ( + // PluginFormatClaudePlugin is a bundle with only .claude-plugin/plugin.json. + PluginFormatClaudePlugin PluginFormat = "claude-plugin" + // PluginFormatAgentPlugins is a bundle with a root plugin.json (agent-plugins.org). + PluginFormatAgentPlugins PluginFormat = "agent-plugins" +) + +// PluginScanVersion is the version of the plugin format rules. Raise it with +// any rules change so every stored Plugin is scanned again. +const PluginScanVersion int64 = 1 + // PluginResolvedSource records the concrete, immutable revision the controller // pinned the user's source pointer to. Exactly one of Commit/Digest is set, // matching Type. It is the reproducibility anchor: deploys materialize from this diff --git a/pkg/api/v1alpha1/plugin_status_test.go b/pkg/api/v1alpha1/plugin_status_test.go index 17a8fea6f..aa5bf0fdb 100644 --- a/pkg/api/v1alpha1/plugin_status_test.go +++ b/pkg/api/v1alpha1/plugin_status_test.go @@ -12,6 +12,8 @@ func TestPluginStatusRoundTrip(t *testing.T) { in.Status.ResolvedSource = &PluginResolvedSource{Type: PluginSourceTypeGit, Commit: "abc123"} in.Status.Manifest = &PluginManifest{Name: "deploy", Version: "1.2.0"} in.Status.Inventory = &PluginInventory{Skills: []PluginSkill{{Name: "deploy", Description: "Deploys"}}} + in.Status.Format = PluginFormatAgentPlugins + in.Status.ScanVersion = PluginScanVersion raw, err := in.MarshalStatus() if err != nil { @@ -38,6 +40,9 @@ func TestPluginStatusRoundTrip(t *testing.T) { if out.Status.Inventory == nil || len(out.Status.Inventory.Skills) != 1 || out.Status.Inventory.Skills[0].Name != "deploy" { t.Errorf("inventory did not round-trip: %+v", out.Status.Inventory) } + if out.Status.Format != PluginFormatAgentPlugins || out.Status.ScanVersion != PluginScanVersion { + t.Errorf("format/scanVersion did not round-trip: %q, %d", out.Status.Format, out.Status.ScanVersion) + } } // TestPluginStatusOmitsNilCustomFields guards the patch-skip byte-stability @@ -54,7 +59,7 @@ func TestPluginStatusOmitsNilCustomFields(t *testing.T) { if err := json.Unmarshal(raw, &m); err != nil { t.Fatalf("unmarshal: %v", err) } - for _, k := range []string{"resolvedSource", "manifest", "inventory"} { + for _, k := range []string{"resolvedSource", "manifest", "inventory", "format", "scanVersion"} { if _, ok := m[k]; ok { t.Errorf("nil %q must be omitted, got key in %s", k, string(raw)) } diff --git a/test/e2e/private_git_sources_test.go b/test/e2e/private_git_sources_test.go index 844d79e4b..255873f02 100644 --- a/test/e2e/private_git_sources_test.go +++ b/test/e2e/private_git_sources_test.go @@ -37,18 +37,22 @@ func TestPrivateGitCatalogSources(t *testing.T) { pluginAuthName := UniqueNameWithPrefix("e2e-plugin-auth") pluginInvalidAuthName := UniqueNameWithPrefix("e2e-plugin-invalid-auth") pluginAnonName := UniqueNameWithPrefix("e2e-plugin-anon") + pluginAgentPluginsName := UniqueNameWithPrefix("e2e-plugin-agent-plugins") + pluginManifestDirName := UniqueNameWithPrefix("e2e-plugin-manifest-dir") skillAuthName := UniqueNameWithPrefix("e2e-skill-auth") skillAnonName := UniqueNameWithPrefix("e2e-skill-anon") path := renderPrivateGitSources(t, tmpDir, map[string]string{ - "Namespace": RegistryNamespace, - "SecretName": secretName, - "InvalidSecretName": invalidSecretName, - "PluginAuthName": pluginAuthName, - "PluginInvalidAuthName": pluginInvalidAuthName, - "PluginAnonName": pluginAnonName, - "SkillAuthName": skillAuthName, - "SkillAnonName": skillAnonName, + "Namespace": RegistryNamespace, + "SecretName": secretName, + "InvalidSecretName": invalidSecretName, + "PluginAuthName": pluginAuthName, + "PluginInvalidAuthName": pluginInvalidAuthName, + "PluginAnonName": pluginAnonName, + "PluginAgentPluginsName": pluginAgentPluginsName, + "PluginManifestDirName": pluginManifestDirName, + "SkillAuthName": skillAuthName, + "SkillAnonName": skillAnonName, }) t.Cleanup(func() { t.Logf("Deleting private Git catalog resources from %s", path) @@ -63,6 +67,17 @@ func TestPrivateGitCatalogSources(t *testing.T) { require.Len(t, plugin.Status.ResolvedSource.Commit, 40) require.NotNil(t, plugin.Status.Manifest) assert.Equal(t, "private-plugin", plugin.Status.Manifest.Name) + assert.Equal(t, v1alpha1.PluginFormatClaudePlugin, plugin.Status.Format) + assert.Equal(t, v1alpha1.PluginScanVersion, plugin.Status.ScanVersion) + + t.Logf("Verifying Agent Plugins bundle %q records the root manifest", pluginAgentPluginsName) + agentPlugins, _ := waitForPluginReady(t, regURL, pluginAgentPluginsName, v1alpha1.ConditionTrue) + assertAgentPluginsBundleStatus(t, agentPlugins) + + t.Logf("Verifying Plugin %q with a plugin.json directory is rejected", pluginManifestDirName) + manifestDir, _ := waitForPluginReady(t, regURL, pluginManifestDirName, v1alpha1.ConditionFalse) + assert.Equal(t, "SourceInvalid", manifestDir.Status.GetCondition("Ready").Reason) + assert.Contains(t, manifestDir.Status.GetCondition("Ready").Message, "plugin.json is a directory") t.Logf("Verifying authenticated Skill %q resolves the private source", skillAuthName) skill, skillRaw := waitForSkillReady(t, regURL, skillAuthName, v1alpha1.ConditionTrue) @@ -91,6 +106,17 @@ func TestPrivateGitCatalogSources(t *testing.T) { assert.Contains(t, pluginInvalidAuthRaw, "xxxxx") } +// assertAgentPluginsBundleStatus checks the fixture's agent-plugin bundle: the +// root manifest wins and the ignored "hooks" key is dropped. +func assertAgentPluginsBundleStatus(t *testing.T, plugin *v1alpha1.Plugin) { + t.Helper() + assert.Equal(t, v1alpha1.PluginFormatAgentPlugins, plugin.Status.Format) + assert.Equal(t, v1alpha1.PluginScanVersion, plugin.Status.ScanVersion) + require.NotNil(t, plugin.Status.Manifest) + assert.Equal(t, "agent-plugin", plugin.Status.Manifest.Name) + assert.Nil(t, plugin.Status.Manifest.Hooks) +} + func renderPrivateGitSources(t *testing.T, outputDir string, data map[string]string) string { t.Helper() return renderPrivateGitTemplate( diff --git a/test/e2e/testdata/private_git_fixture.yaml b/test/e2e/testdata/private_git_fixture.yaml index 9e66cf031..16657b4e4 100644 --- a/test/e2e/testdata/private_git_fixture.yaml +++ b/test/e2e/testdata/private_git_fixture.yaml @@ -33,6 +33,18 @@ data: mkdir -p plugin/.claude-plugin skill printf '{"name":"private-plugin","version":"1.0.0"}\n' > plugin/.claude-plugin/plugin.json printf '%s\n' '---' 'name: private-skill' 'description: E2E private skill' '---' > skill/SKILL.md + # Agent Plugins bundle: the root manifest wins over the Claude one, and an + # unchecked manifest key must not reject it. + mkdir -p agent-plugin/.claude-plugin agent-plugin/skills/review + printf '%s\n' '{"$schema":"https://agent-plugins.org/schemas/1.0.0/plugin.schema.json","name":"agent-plugin","hooks":5}' > agent-plugin/plugin.json + printf '{"name":"claude-name"}\n' > agent-plugin/.claude-plugin/plugin.json + printf '%s\n' '{"$schema":"https://agent-plugins.org/schemas/1.0.0/mcp.schema.json","mcpServers":{"search":{"type":"streamable-http","url":"https://example.com/mcp"}}}' > agent-plugin/mcp.json + printf '%s\n' '{"mcpServers":{"claude-only":{"url":"https://example.com/mcp"}}}' > agent-plugin/.mcp.json + printf '%s\n' '---' 'name: review' '---' > agent-plugin/skills/review/SKILL.md + # A plugin.json directory holding only a link must be rejected. + mkdir -p dir-plugin/.claude-plugin dir-plugin/plugin.json + printf '{"name":"dir-plugin"}\n' > dir-plugin/.claude-plugin/plugin.json + ln -s ../.claude-plugin/plugin.json dir-plugin/plugin.json/link.json git add -A git commit -qm "e2e private catalog sources" git branch -M main diff --git a/test/e2e/testdata/private_git_sources.yaml.tmpl b/test/e2e/testdata/private_git_sources.yaml.tmpl index 8b14154f3..8b40d82e2 100644 --- a/test/e2e/testdata/private_git_sources.yaml.tmpl +++ b/test/e2e/testdata/private_git_sources.yaml.tmpl @@ -65,6 +65,38 @@ spec: subfolder: plugin --- apiVersion: ar.dev/v1alpha1 +kind: Plugin +metadata: + name: {{ .PluginAgentPluginsName }} +spec: + title: E2E Private Agent Plugins Bundle + source: + type: git + git: + repository: + url: http://git-fixture.{{ .Namespace }}.svc.cluster.local/acme/private.git + branch: main + subfolder: agent-plugin + credentialsRef: + name: {{ .SecretName }} +--- +apiVersion: ar.dev/v1alpha1 +kind: Plugin +metadata: + name: {{ .PluginManifestDirName }} +spec: + title: E2E Private Plugin With A plugin.json Directory + source: + type: git + git: + repository: + url: http://git-fixture.{{ .Namespace }}.svc.cluster.local/acme/private.git + branch: main + subfolder: dir-plugin + credentialsRef: + name: {{ .SecretName }} +--- +apiVersion: ar.dev/v1alpha1 kind: Skill metadata: name: {{ .SkillAuthName }} diff --git a/ui/lib/api/types.gen.ts b/ui/lib/api/types.gen.ts index 8e37c9b13..f29079326 100644 --- a/ui/lib/api/types.gen.ts +++ b/ui/lib/api/types.gen.ts @@ -615,9 +615,11 @@ export type PluginSpec = { export type PluginStatus = { conditions?: Array | null; + format?: string; inventory?: PluginInventory; manifest?: PluginManifest; resolvedSource?: PluginResolvedSource; + scanVersion?: number; }; export type PluginUserConfigField = {