- The settings button now also appears for plugins that only contribute a settings.plugin panel; the panel opens in the settings dialog beside the declarative form instead of the bottom of the Plugins page. - Plugin stderr and non-routine audit entries are mirrored to the app log as plugin:<id>, rate limited per plugin; the per-plugin log window is removed. - The installed-plugin security scan button is removed; the scan verdict shows in the permissions tooltip. The pre-install archive scan is unchanged. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package plugin
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestAuditMirrorsPluginOutputToAppLog(t *testing.T) {
|
|
layout := NewPluginsLayout(t.TempDir())
|
|
broker := NewBroker(layout, nil, func(s string) string { return strings.ReplaceAll(s, "secret", "***") })
|
|
var got []string
|
|
broker.SetLogger(func(source, line string) { got = append(got, source+" "+line) })
|
|
|
|
broker.Audit("vendor.demo", "STDERR", "secret one\r\n12:00:00 [host] two")
|
|
broker.Audit("vendor.demo", "HOST_API", "host/vm.list")
|
|
|
|
want := "plugin:vendor.demo [STDERR] *** one 12:00:00 [host] two"
|
|
if len(got) != 1 || got[0] != want {
|
|
t.Fatalf("app log = %q, want only %q", got, want)
|
|
}
|
|
file, err := os.ReadFile(layout.LogPath("vendor.demo"))
|
|
if err != nil || !strings.Contains(string(file), "host/vm.list") {
|
|
t.Fatalf("audit file must keep routine entries: %q, %v", file, err)
|
|
}
|
|
|
|
for range 2 * hostCallsPerSecond {
|
|
broker.Audit("vendor.demo", "STDERR", "spam")
|
|
}
|
|
if len(got) >= 2*hostCallsPerSecond {
|
|
t.Fatalf("%d lines reached the app log; spam must be limited", len(got))
|
|
}
|
|
}
|