Skip to content

Commit

Permalink
add MissingCredentials field to Result
Browse files Browse the repository at this point in the history
  • Loading branch information
jreisinger committed Jun 7, 2024
1 parent ceeaaf8 commit 25193ea
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions check/abuseipdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func AbuseIPDB(ipaddr net.IP) (checkip.Result, error) {
return result, newCheckError(err)
}
if apiKey == "" { // we don't consider missing to be an error
result.MissingCredentials = "ABUSEIPDB_API_KEY"
return result, nil
}

Expand Down
1 change: 1 addition & 0 deletions check/maxmind.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func MaxMind(ip net.IP) (checkip.Result, error) {
return result, newCheckError(err)
}
if licenseKey == "" {
result.MissingCredentials = "MAXMIND_LICENSE_KEY"
return result, nil
}

Expand Down
1 change: 1 addition & 0 deletions check/shodan.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func Shodan(ipaddr net.IP) (checkip.Result, error) {
return result, newCheckError(err)
}
if apiKey == "" {
result.MissingCredentials = "SHODAN_API_KEY"
return result, nil
}

Expand Down
1 change: 1 addition & 0 deletions check/urlscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func UrlScan(ipaddr net.IP) (checkip.Result, error) {
return result, newCheckError(err)
}
if apiKey == "" {
result.MissingCredentials = "URLSCAN_API_KEY"
return result, nil
}

Expand Down
1 change: 1 addition & 0 deletions check/virustotal.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func VirusTotal(ipaddr net.IP) (checkip.Result, error) {
return result, newCheckError(err)
}
if apiKey == "" {
result.MissingCredentials = "VIRUSTOTAL_API_KEY"
return result, nil
}

Expand Down
9 changes: 5 additions & 4 deletions checkip.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ type Check func(ipaddr net.IP) (Result, error)

// Result is the information provided by a Check.
type Result struct {
Name string `json:"name"` // check name, max 15 chars
Type Type `json:"type"` // check type
Malicious bool `json:"malicious"` // provided by TypeSec and TypeInfoSec check type
Info Info `json:"info"`
Name string `json:"name"` // check name, max 15 chars
Type Type `json:"type"` // check type
MissingCredentials string `json:"missing_credentials,omitempty"`
Malicious bool `json:"malicious"` // provided by TypeSec and TypeInfoSec check type
Info Info `json:"info"`
}

// Info is generic information provided by a TypeInfo or TypeInfoSec Check.
Expand Down

0 comments on commit 25193ea

Please sign in to comment.