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
|
|
@ -17,7 +17,7 @@ func TestThreatFoxSource_NoResult(t *testing.T) {
|
|||
defer srv.Close()
|
||||
|
||||
s := &threatFoxSource{endpoint: srv.URL}
|
||||
results := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"enable_threatfox": true, "threatfox_auth_key": "k"})
|
||||
results := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"threatfox_auth_key": "k"})
|
||||
if len(results) != 1 {
|
||||
t.Fatalf("expected 1 result, got %d", len(results))
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ func TestThreatFoxSource_Listed(t *testing.T) {
|
|||
defer srv.Close()
|
||||
|
||||
s := &threatFoxSource{endpoint: srv.URL}
|
||||
r := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"enable_threatfox": true, "threatfox_auth_key": "k"})[0]
|
||||
r := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"threatfox_auth_key": "k"})[0]
|
||||
if len(r.Evidence) != 1 {
|
||||
t.Fatalf("expected 1 evidence item, got %+v", r)
|
||||
}
|
||||
|
|
@ -73,23 +73,15 @@ func TestThreatFoxSource_HTTPError(t *testing.T) {
|
|||
defer srv.Close()
|
||||
|
||||
s := &threatFoxSource{endpoint: srv.URL}
|
||||
r := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"enable_threatfox": true, "threatfox_auth_key": "k"})[0]
|
||||
r := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"threatfox_auth_key": "k"})[0]
|
||||
if r.Error == "" {
|
||||
t.Errorf("expected error, got %+v", r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestThreatFoxSource_Disabled(t *testing.T) {
|
||||
s := &threatFoxSource{endpoint: "http://nope"}
|
||||
r := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"enable_threatfox": false})[0]
|
||||
if r.Enabled {
|
||||
t.Errorf("expected disabled, got %+v", r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestThreatFoxSource_NoAuthKey(t *testing.T) {
|
||||
s := &threatFoxSource{endpoint: "http://nope"}
|
||||
r := s.Query(context.Background(), "example.com", "example.com", sdk.CheckerOptions{"enable_threatfox": true})[0]
|
||||
r := s.Query(context.Background(), "example.com", "example.com", nil)[0]
|
||||
if r.Enabled {
|
||||
t.Errorf("expected disabled when no auth key, got %+v", r)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue