test(05-03): add failing tests for VerifyAll worker pool

- TestVerifyAll_MultipleFindings: 5 findings via 3-worker pool
- TestVerifyAll_MissingProvider: unknown provider yields StatusUnknown
- TestVerifyAll_ContextCancellation: cancellation closes channel early
- Add providers.NewRegistryFromProviders test helper
This commit is contained in:
salvacybersec
2026-04-05 15:48:46 +03:00
parent 026d305026
commit 45ee2f8f53
2 changed files with 99 additions and 0 deletions

View File

@@ -39,6 +39,21 @@ func NewRegistry() (*Registry, error) {
}, nil
}
// NewRegistryFromProviders builds a Registry from an explicit slice of providers
// without touching the embedded YAML files. Intended for tests that need a
// minimal registry with synthetic providers.
func NewRegistryFromProviders(ps []Provider) *Registry {
index := make(map[string]int, len(ps))
var keywords []string
for i, p := range ps {
index[p.Name] = i
keywords = append(keywords, p.Keywords...)
}
builder := ahocorasick.NewAhoCorasickBuilder(ahocorasick.Opts{DFA: true})
ac := builder.Build(keywords)
return &Registry{providers: ps, index: index, ac: ac}
}
// List returns all loaded providers.
func (r *Registry) List() []Provider {
return r.providers