Skip to content

Commit

Permalink
rename check types
Browse files Browse the repository at this point in the history
  • Loading branch information
jreisinger committed Jun 17, 2024
1 parent 66dbb51 commit be762f6
Show file tree
Hide file tree
Showing 26 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion check/abuseipdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (a abuseIPDB) Json() ([]byte, error) {
// AbuseIPDB uses api.abuseipdb.com to get generic information about ipaddr and
// to see if the ipaddr has been reported as malicious.
func AbuseIPDB(ipaddr net.IP) (Check, error) {
result := Check{Description: "abuseipdb.com", Type: TypeInfoAndIsMalicious}
result := Check{Description: "abuseipdb.com", Type: InfoAndIsMalicious}

apiKey, err := getConfigValue("ABUSEIPDB_API_KEY")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion check/abuseipdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestAbuseIPDB(t *testing.T) {
result, err := AbuseIPDB(net.ParseIP("118.25.6.39"))
require.NoError(t, err)
assert.Equal(t, "abuseipdb.com", result.Description)
assert.Equal(t, TypeInfoAndIsMalicious, result.Type)
assert.Equal(t, InfoAndIsMalicious, result.Type)
assert.Equal(t, true, result.IpAddrIsMalicious)
assert.Equal(t, "domain: tencent.com, usage type: Data Center/Web Hosting/Transit", result.IpAddrInfo.Summary())
})
Expand Down
2 changes: 1 addition & 1 deletion check/blocklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func BlockList(ipaddr net.IP) (Check, error) {
result := Check{
Description: "blocklist.de",
Type: TypeIsMalicious,
Type: IsMalicious,
}

file, err := getBlockListFile()
Expand Down
2 changes: 1 addition & 1 deletion check/blocklist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestBlockList(t *testing.T) {
result, err := BlockList(net.ParseIP("66.249.70.34"))
require.NoError(t, err)
assert.Equal(t, "blocklist.de", result.Description)
assert.Equal(t, TypeIsMalicious, result.Type)
assert.Equal(t, IsMalicious, result.Type)
assert.Equal(t, true, result.IpAddrIsMalicious)
})
}
Expand Down
2 changes: 1 addition & 1 deletion check/censys.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func basicAuth(username, password string) string {
func Censys(ipaddr net.IP) (Check, error) {
result := Check{
Description: "censys.io",
Type: TypeInfoAndIsMalicious,
Type: InfoAndIsMalicious,
}

apiKey, err := getConfigValue("CENSYS_KEY")
Expand Down
2 changes: 1 addition & 1 deletion check/censys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestCensys(t *testing.T) {
result, err := Censys(net.ParseIP("118.25.6.39"))
require.NoError(t, err)
assert.Equal(t, "censys.io", result.Description)
assert.Equal(t, TypeInfoAndIsMalicious, result.Type)
assert.Equal(t, InfoAndIsMalicious, result.Type)
assert.Equal(t, true, result.IpAddrIsMalicious)
assert.Equal(t, "MikroTik, RB760iGS, udp/161 (snmp), tcp/2000 (mikrotik_bw), tcp/51922 (ssh)", result.IpAddrInfo.Summary())
})
Expand Down
8 changes: 4 additions & 4 deletions check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"regexp"
)

// Existing Check types.
// Type of a check.
const (
TypeInfo Type = iota // some information about the IP address
TypeIsMalicious // whether the IP address is considered malicious
TypeInfoAndIsMalicious // both of the above
Info Type = iota // some information about the IP address
IsMalicious // whether the IP address is considered malicious
InfoAndIsMalicious // both of the above
)

// Funcs contains all available functions for checking IP addresses.
Expand Down
2 changes: 1 addition & 1 deletion check/cinsscore.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type cins struct {
func CinsScore(ipaddr net.IP) (Check, error) {
result := Check{
Description: "cinsscore.com",
Type: TypeIsMalicious,
Type: IsMalicious,
}

// file := "/var/tmp/cins.txt"
Expand Down
2 changes: 1 addition & 1 deletion check/dbip.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (d dbip) Json() ([]byte, error) {
func DBip(ip net.IP) (Check, error) {
result := Check{
Description: "db-ip.com",
Type: TypeInfo,
Type: Info,
}

// file := "/var/tmp/dbip-city-lite.mmdb"
Expand Down
2 changes: 1 addition & 1 deletion check/dnsmx.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (mx mx) Json() ([]byte, error) {
func DnsMX(ipaddr net.IP) (Check, error) {
result := Check{
Description: "dns mx",
Type: TypeInfo,
Type: Info,
}

names, _ := net.LookupAddr(ipaddr.String()) // NOTE: ignoring error
Expand Down
2 changes: 1 addition & 1 deletion check/dnsname.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (n dnsNames) Json() ([]byte, error) {
func DnsName(ipaddr net.IP) (Check, error) {
result := Check{
Description: "dns name",
Type: TypeInfo,
Type: Info,
}

names, err := net.LookupAddr(ipaddr.String())
Expand Down
2 changes: 1 addition & 1 deletion check/firehol.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func Firehol(ipaddr net.IP) (Check, error) {
result := Check{
Description: "firehol.org",
Type: TypeIsMalicious,
Type: IsMalicious,
}

file, err := getCachePath("firehol_level1.netset")
Expand Down
2 changes: 1 addition & 1 deletion check/ipsum.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func IPSum(ipaddr net.IP) (Check, error) {
result := Check{
Description: "github.com/stamparm/ipsum",
Type: TypeIsMalicious,
Type: IsMalicious,
}

// file := "/var/tmp/ipsum.txt"
Expand Down
2 changes: 1 addition & 1 deletion check/iptoasn.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (a autonomousSystem) Json() ([]byte, error) {
func IPtoASN(ipaddr net.IP) (Check, error) {
result := Check{
Description: "iptoasn.com",
Type: TypeInfo,
Type: Info,
}

// file := "/var/tmp/ip2asn-combined.tsv"
Expand Down
2 changes: 1 addition & 1 deletion check/maxmind.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (m maxmind) Json() ([]byte, error) {
func MaxMind(ip net.IP) (Check, error) {
result := Check{
Description: "maxmind.com",
Type: TypeInfo,
Type: Info,
}

licenseKey, err := getConfigValue("MAXMIND_LICENSE_KEY")
Expand Down
2 changes: 1 addition & 1 deletion check/otx.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type otx struct {
func OTX(ipaddr net.IP) (Check, error) {
result := Check{
Description: "otx.alienvault.com",
Type: TypeIsMalicious,
Type: IsMalicious,
}

u, err := url.Parse(otxUrl)
Expand Down
2 changes: 1 addition & 1 deletion check/otx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestOTX(t *testing.T) {
result, err := OTX(net.ParseIP("118.25.6.39"))
require.NoError(t, err)
assert.Equal(t, "otx.alienvault.com", result.Description)
assert.Equal(t, TypeIsMalicious, result.Type)
assert.Equal(t, IsMalicious, result.Type)
assert.Equal(t, true, result.IpAddrIsMalicious)
})

Expand Down
2 changes: 1 addition & 1 deletion check/phishstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (ps phishstats) Json() ([]byte, error) {
func PhishStats(ipaddr net.IP) (Check, error) {
result := Check{
Description: "phishstats.info",
Type: TypeInfoAndIsMalicious,
Type: InfoAndIsMalicious,
}

file, err := getCachePath("phish_score.csv")
Expand Down
2 changes: 1 addition & 1 deletion check/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func Ping(ipaddr net.IP) (Check, error) {
result := Check{
Description: "ping",
Type: TypeInfo,
Type: Info,
}

pinger, err := ping.NewPinger(ipaddr.String())
Expand Down
2 changes: 1 addition & 1 deletion check/sans.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (s sans) Json() ([]byte, error) {
func SansISC(ipaddr net.IP) (Check, error) {
result := Check{
Description: "isc.sans.edu",
Type: TypeInfoAndIsMalicious,
Type: InfoAndIsMalicious,
}

u, err := url.Parse(sansUrl)
Expand Down
2 changes: 1 addition & 1 deletion check/shodan.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var shodanUrl = "https://api.shodan.io"
func Shodan(ipaddr net.IP) (Check, error) {
result := Check{
Description: "shodan.io",
Type: TypeInfoAndIsMalicious,
Type: InfoAndIsMalicious,
}

apiKey, err := getConfigValue("SHODAN_API_KEY")
Expand Down
2 changes: 1 addition & 1 deletion check/shodan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestShodan(t *testing.T) {
result, err := Shodan(net.ParseIP("118.25.6.39"))
require.NoError(t, err)
assert.Equal(t, "shodan.io", result.Description)
assert.Equal(t, TypeInfoAndIsMalicious, result.Type)
assert.Equal(t, InfoAndIsMalicious, result.Type)
assert.Equal(t, true, result.IpAddrIsMalicious)
})

Expand Down
2 changes: 1 addition & 1 deletion check/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (t tlsinfo) Json() ([]byte, error) {
func Tls(ipaddr net.IP) (Check, error) {
result := Check{
Description: "tls",
Type: TypeInfoAndIsMalicious,
Type: InfoAndIsMalicious,
}

address := net.JoinHostPort(ipaddr.String(), "443")
Expand Down
2 changes: 1 addition & 1 deletion check/urlscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const days = 30 // limit search to last 30 days
func UrlScan(ipaddr net.IP) (Check, error) {
result := Check{
Description: "urlscan.io",
Type: TypeInfoAndIsMalicious,
Type: InfoAndIsMalicious,
}

apiKey, err := getConfigValue("URLSCAN_API_KEY")
Expand Down
2 changes: 1 addition & 1 deletion check/virustotal.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (v virusTotal) Json() ([]byte, error) {
func VirusTotal(ipaddr net.IP) (Check, error) {
result := Check{
Description: "virustotal.com",
Type: TypeInfoAndIsMalicious,
Type: InfoAndIsMalicious,
}

apiKey, err := getConfigValue("VIRUSTOTAL_API_KEY")
Expand Down
4 changes: 2 additions & 2 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (rs Checks) PrintSummary() {
continue
}

if r.Type == check.TypeInfo || r.Type == check.TypeInfoAndIsMalicious {
if r.Type == check.Info || r.Type == check.InfoAndIsMalicious {
fmt.Printf("%-15s %s\n", r.Description, r.IpAddrInfo.Summary())
}
}
Expand Down Expand Up @@ -118,7 +118,7 @@ func (rs Checks) maliciousStats() (total, malicious int, prob float64) {
// if r.Info == nil {
// continue
// }
if r.Type == check.TypeIsMalicious || r.Type == check.TypeInfoAndIsMalicious {
if r.Type == check.IsMalicious || r.Type == check.InfoAndIsMalicious {
total++
if r.IpAddrIsMalicious {
malicious++
Expand Down

0 comments on commit be762f6

Please sign in to comment.