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
|
|
@ -22,6 +22,13 @@ type malwareBazaarSource struct {
|
|||
func (*malwareBazaarSource) ID() string { return "malwarebazaar" }
|
||||
func (*malwareBazaarSource) Name() string { return "abuse.ch MalwareBazaar" }
|
||||
|
||||
func (s *malwareBazaarSource) Precheck(ctx context.Context, opts sdk.CheckerOptions) error {
|
||||
if stringOpt(opts, "malwarebazaar_auth_key") == "" {
|
||||
return fmt.Errorf("MalwareBazaar Auth-Key is not configured")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*malwareBazaarSource) Options() SourceOptions {
|
||||
return SourceOptions{
|
||||
Admin: []sdk.CheckerOptionField{
|
||||
|
|
@ -33,21 +40,12 @@ func (*malwareBazaarSource) Options() SourceOptions {
|
|||
Secret: true,
|
||||
},
|
||||
},
|
||||
User: []sdk.CheckerOptionField{
|
||||
{
|
||||
Id: "enable_malwarebazaar",
|
||||
Type: "bool",
|
||||
Label: "Use abuse.ch MalwareBazaar",
|
||||
Description: "Search MalwareBazaar for malware samples tagged with the domain (typically C2 infrastructure or delivery hosts).",
|
||||
Default: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *malwareBazaarSource) Query(ctx context.Context, domain, registered string, opts sdk.CheckerOptions) []SourceResult {
|
||||
authKey := stringOpt(opts, "malwarebazaar_auth_key")
|
||||
if !sdk.GetBoolOption(opts, "enable_malwarebazaar", true) || registered == "" || authKey == "" {
|
||||
if registered == "" || authKey == "" {
|
||||
return disabledResult(s.ID(), s.Name())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue