Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/plugins/apps/apps-11.1.2.tar.xz
Binary file not shown.
6 changes: 6 additions & 0 deletions docs/plugins/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
"url": "apps/apps-11.1.1.tar.xz",
"sha256": "81fd3c72a76358d56c8d7cdc3bbc566c3119a334c96a9855ae75187521032e6b",
"releaseDate": "2026-01-28"
},
{
"version": "11.1.2",
"url": "apps/apps-11.1.2.tar.xz",
"sha256": "1a647a33feb45e0fe96b1772df27e4f75168b3c6e01d7c3c590a90a2bfde125d",
"releaseDate": "2026-02-04"
}
]
}
Expand Down
22 changes: 22 additions & 0 deletions internal/plugin/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package plugin
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"os"
"os/exec"
Expand All @@ -30,6 +31,10 @@ import (
// ValidatePluginScript validates that a plugin script outputs a manifest matching the expected manifest.
// All fields must match exactly, including Scripts and MinCLIVersion for managed plugins.
func ValidatePluginScript(pluginDir string, expectedManifest PluginManifest) error {
if err := ValidateLicense(pluginDir); err != nil {
return err
}

scriptPath, err := FindPluginScript(pluginDir, expectedManifest.Name)
if err != nil {
return err
Expand All @@ -45,6 +50,23 @@ func ValidatePluginScript(pluginDir string, expectedManifest PluginManifest) err
return validateManifests(expectedManifest, *scriptManifest)
}

// ValidateLicense validates that a plugin has a LICENSE.txt file.
func ValidateLicense(pluginDir string) error {
licensePath := filepath.Join(pluginDir, "LICENSE.txt")

if _, err := os.Stat(licensePath); err != nil {
if os.IsNotExist(err) {
return errors.New("plugin must contain LICENSE.txt file")
}

return fmt.Errorf("failed to check for LICENSE.txt: %w", err)
}

log.Debug("Plugin license validation passed", "path", licensePath)

return nil
}

// validateManifests compares two manifests and returns an error if they differ.
func validateManifests(expected, actual PluginManifest) error {
opts := cmp.Options{
Expand Down
64 changes: 64 additions & 0 deletions internal/plugin/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,67 @@ func createScript(t *testing.T, path, content string) {
err := os.WriteFile(path, []byte(content), 0o755)
require.NoError(t, err)
}

func TestValidateLicense_Success(t *testing.T) {
tempDir := t.TempDir()

licensePath := filepath.Join(tempDir, "LICENSE.txt")
err := os.WriteFile(licensePath, []byte("Apache License 2.0"), 0o644)
require.NoError(t, err)

err = ValidateLicense(tempDir)

assert.NoError(t, err)
}

func TestValidateLicense_Missing(t *testing.T) {
tempDir := t.TempDir()

err := ValidateLicense(tempDir)

require.Error(t, err)
assert.Contains(t, err.Error(), "plugin must contain LICENSE.txt file")
}

func TestValidatePluginScript_MissingLicense(t *testing.T) {
tempDir := t.TempDir()

manifest := PluginManifest{
BasicPluginManifest: BasicPluginManifest{
Name: "test",
Version: "1.0.0",
Description: "Test plugin",
Authentication: true,
},
}

createTestScript(t, tempDir, manifest)

err := ValidatePluginScript(tempDir, manifest)

require.Error(t, err)
assert.Contains(t, err.Error(), "plugin must contain LICENSE.txt file")
}

func TestValidatePluginScript_WithLicense(t *testing.T) {
tempDir := t.TempDir()

manifest := PluginManifest{
BasicPluginManifest: BasicPluginManifest{
Name: "test",
Version: "1.0.0",
Description: "Test plugin",
Authentication: true,
},
}

createTestScript(t, tempDir, manifest)

licensePath := filepath.Join(tempDir, "LICENSE.txt")
err := os.WriteFile(licensePath, []byte("Apache License 2.0"), 0o644)
require.NoError(t, err)

err = ValidatePluginScript(tempDir, manifest)

assert.NoError(t, err)
}
Loading