Replace per-source enable booleans with SourcePrecheck and bump SDK to v1.9.0
Sources that always work (botvrij, disconnect, oisd, openphish, phishtank, quad9) drop their user-facing enable_* option; the rule's enabled/disabled state is now solely controlled by the SDK rule toggle. Sources that require credentials (criminalip, malwarebazaar, otx, pulsedive, safebrowsing, threatfox, urlhaus, virustotal) instead implement the new SourcePrecheck interface so the host UI can surface "not configured" before attempting a query.
This commit is contained in:
parent
ce59a976d5
commit
c3cda1f104
25 changed files with 189 additions and 175 deletions
|
|
@ -19,7 +19,7 @@ func TestURLhausSource_NoResults(t *testing.T) {
|
|||
defer srv.Close()
|
||||
|
||||
s := &urlhausSource{endpoint: srv.URL}
|
||||
results := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"enable_urlhaus": true, "urlhaus_auth_key": "k"})
|
||||
results := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"urlhaus_auth_key": "k"})
|
||||
if len(results) != 1 {
|
||||
t.Fatalf("expected 1 result, got %d", len(results))
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ func TestURLhausSource_Listed(t *testing.T) {
|
|||
defer srv.Close()
|
||||
|
||||
s := &urlhausSource{endpoint: srv.URL}
|
||||
r := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"enable_urlhaus": true, "urlhaus_auth_key": "k"})[0]
|
||||
r := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"urlhaus_auth_key": "k"})[0]
|
||||
if len(r.Evidence) != 1 {
|
||||
t.Fatalf("expected 1 evidence item, got %+v", r)
|
||||
}
|
||||
|
|
@ -80,16 +80,16 @@ func TestURLhausSource_HTTPError(t *testing.T) {
|
|||
defer srv.Close()
|
||||
|
||||
s := &urlhausSource{endpoint: srv.URL}
|
||||
r := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"enable_urlhaus": true, "urlhaus_auth_key": "k"})[0]
|
||||
r := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"urlhaus_auth_key": "k"})[0]
|
||||
if r.Error == "" || !strings.Contains(r.Error, "401") {
|
||||
t.Errorf("expected 401 error, got %+v", r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestURLhausSource_Disabled(t *testing.T) {
|
||||
func TestURLhausSource_NoAuthKey(t *testing.T) {
|
||||
s := &urlhausSource{endpoint: "http://nope"}
|
||||
r := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"enable_urlhaus": false})[0]
|
||||
r := s.Query(context.Background(), "example.com", "example.com", nil)[0]
|
||||
if r.Enabled {
|
||||
t.Errorf("expected disabled, got %+v", r)
|
||||
t.Errorf("expected disabled when no auth key, got %+v", r)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue