v0.22.2 cli presentation improvements, hardened config
Test / test (push) Canceled after 0s
Test / e2e (push) Canceled after 0s

This commit is contained in:
lixen committed 2026-10-04 00:04:03 -04:00
1 parent 4eba6fc834
commit 15745682bc
8 files changed
+49 -44

No files matched your search

+18
View File
@@ -301,3 +301,21 @@ func TestNoConfigFileMeansQuietLogging(t *testing.T) {
t.Fatalf("environment over the file-less default: %+v %v", cfg, err)
}
}
// A string in the file is one list entry: split at its comma, an exclude
// pattern such as password=\S{8,64} would become two that match nothing
func TestFileStringIsOneListEntry(t *testing.T) {
isolateConfig(t)
testutil.WriteFile(t, "logwisp.toml", "[[pipelines]]\nname = \"p\"\n"+
"[[pipelines.plugin_sources]]\nid = \"in\"\ntype = \"null\"\n[[pipelines.plugin_sinks]]\nid = \"out\"\ntype = \"null\"\n"+
"[[pipelines.flow.filters]]\ntype = \"exclude\"\npatterns = \"password=\\\\S{8,64}\"\n")
m, err := Load(nil)
if err != nil {
t.Fatal(err)
}
defer m.Close()
cfg, err := m.Snapshot()
if err != nil || !reflect.DeepEqual(cfg.Pipelines[0].Flow.Filters[0].Patterns, []string{`password=\S{8,64}`}) {
t.Fatalf("patterns: %v %v", cfg.Pipelines[0].Flow.Filters, err)
}
}
+1 -7
View File
@@ -111,9 +111,7 @@ func Scan(configMap map[string]any, target any) error {
}
// checkKeys walks nested tables against the toml tags of t, refusing unknown
// keys and making a lone string for a list field a one-entry list: the weakly
// typed decoder would split it at commas, which a pattern or a DN may hold.
// Map-typed fields hold free-form keys and are not descended into.
// keys. Map-typed fields hold free-form keys and are not descended into.
func checkKeys(m map[string]any, t reflect.Type, prefix string) error {
for t.Kind() == reflect.Pointer || t.Kind() == reflect.Slice {
t = t.Elem()
@@ -134,10 +132,6 @@ func checkKeys(m map[string]any, t reflect.Type, prefix string) error {
}
var tables []map[string]any
switch v := m[key].(type) {
case string:
if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.String {
m[key] = []string{v}
}
case map[string]any:
if err := checkKeys(v, ft, prefix+key+"."); err != nil {
return err