diff --git a/crawler/crawler.go b/crawler/crawler.go index 4036e60..c10670b 100644 --- a/crawler/crawler.go +++ b/crawler/crawler.go @@ -1,68 +1,76 @@ package crawler import ( - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + activedirectoryH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/activedirectory" + cassandraH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/cassandra" + dnsH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/dns" + ftpH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/ftp" + httpH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/http" + imapH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/imap" + ldapH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/ldap" + mongodbH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/mongodb" + mysqlH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/mysql" + netbiosH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/netbios" + oracleH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/oracle" + popH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/pop" + postgresqlH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/postgresql" + redisH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/redis" + rmiH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/rmi" + smbH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/smb" + smtpH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/smtp" + snmpV2H "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/snmp/v2" + snmpV3H "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/snmp/v3" + sqlserverH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/sqlserver" + sshH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/ssh" + telnetH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/telnet" + wmiH "git.loafle.net/overflow/overflow_probe_container_network/crawler/health/wmi" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/ssh" ) -type Crawler interface { - Init(config *configM.Config) error - Add(config *configM.Config) error - Remove(id string) error - Get(id string) (map[string]string, error) +var crawlers map[string]oopcc.Crawler - Name() string +func init() { + crawlers = make(map[string]oopcc.Crawler, 0) + + addCrawler(activedirectoryH.NewCrawler()) + addCrawler(cassandraH.NewCrawler()) + addCrawler(dnsH.NewCrawler()) + addCrawler(ftpH.NewCrawler()) + addCrawler(httpH.NewCrawler()) + addCrawler(imapH.NewCrawler()) + addCrawler(ldapH.NewCrawler()) + addCrawler(mongodbH.NewCrawler()) + addCrawler(mysqlH.NewCrawler()) + addCrawler(netbiosH.NewCrawler()) + addCrawler(oracleH.NewCrawler()) + addCrawler(popH.NewCrawler()) + addCrawler(postgresqlH.NewCrawler()) + addCrawler(redisH.NewCrawler()) + addCrawler(rmiH.NewCrawler()) + addCrawler(smbH.NewCrawler()) + addCrawler(smtpH.NewCrawler()) + addCrawler(snmpV2H.NewCrawler()) + addCrawler(snmpV3H.NewCrawler()) + addCrawler(sqlserverH.NewCrawler()) + addCrawler(sshH.NewCrawler()) + addCrawler(telnetH.NewCrawler()) + addCrawler(wmiH.NewCrawler()) + addCrawler(ssh.NewCrawler()) } -type InternalCrawler interface { - InternalGet(config *configM.Config) (map[string]string, error) +func addCrawler(c oopcc.Crawler) { + crawlers[c.Name()] = c } -type Crawlers struct { - configs map[string]*configM.Config - - Internal InternalCrawler -} - -func (c *Crawlers) GetConfig(id string) *configM.Config { - if nil == c.configs { +func GetCrawler(name string) oopcc.Crawler { + c, ok := crawlers[name] + if !ok { return nil } - return c.configs[id] + return c } -func (c *Crawlers) RemoveConfig(id string) { - if nil == c.configs { - return - } - delete(c.configs, id) -} - -func (c *Crawlers) PutConfig(id string, config *configM.Config) { - if nil == c.configs { - c.configs = make(map[string]*configM.Config, 0) - } - c.configs[id] = config -} - -func (c *Crawlers) Init(config *configM.Config) error { - c.PutConfig(config.ID.String(), config) - return nil -} - -func (c *Crawlers) Add(config *configM.Config) error { - c.PutConfig(config.ID.String(), config) - return nil -} - -func (c *Crawlers) Remove(id string) error { - c.RemoveConfig(id) - return nil -} - -func (c *Crawlers) Get(id string) (map[string]string, error) { - rss, err := c.Internal.InternalGet(c.GetConfig(id)) - if nil != err { - return nil, err - } - return rss, nil +func GetCrawlers() map[string]oopcc.Crawler { + return crawlers } diff --git a/crawler/impl/health/SocketHeahthCrawler.go b/crawler/health/SocketHeahthCrawler.go similarity index 86% rename from crawler/impl/health/SocketHeahthCrawler.go rename to crawler/health/SocketHeahthCrawler.go index ade7859..fa09358 100644 --- a/crawler/impl/health/SocketHeahthCrawler.go +++ b/crawler/health/SocketHeahthCrawler.go @@ -9,12 +9,12 @@ import ( cnsm "git.loafle.net/commons_go/network_service_matcher" cuej "git.loafle.net/commons_go/util/encoding/json" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" ) type SocketHeahthCrawler struct { - crawler.Crawlers + oopcc.Crawler m cnsm.Matcher } @@ -22,7 +22,7 @@ func (s *SocketHeahthCrawler) SetMatcher(m cnsm.Matcher) { s.m = m } -func (s *SocketHeahthCrawler) getConnection(config *configM.Config) (net.Conn, error) { +func (s *SocketHeahthCrawler) getConnection(config *sensorConfigM.SensorConfig) (net.Conn, error) { connection := config.Target.Connection ip := connection.IP @@ -54,7 +54,7 @@ func (s *SocketHeahthCrawler) getConnection(config *configM.Config) (net.Conn, e return conn, nil } -func (s *SocketHeahthCrawler) CheckHeahth(config *configM.Config) (result map[string]string, err error) { +func (s *SocketHeahthCrawler) CheckHeahth(config *sensorConfigM.SensorConfig) (result map[string]string, err error) { result = make(map[string]string, 0) result["StartTime"] = time.Now().String() diff --git a/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler.go b/crawler/health/activedirectory/ActiveDirectoryHealthCrawler.go similarity index 62% rename from crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler.go rename to crawler/health/activedirectory/ActiveDirectoryHealthCrawler.go index b79df66..b2ae6e8 100644 --- a/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler.go +++ b/crawler/health/activedirectory/ActiveDirectoryHealthCrawler.go @@ -2,9 +2,9 @@ package activedirectory import ( cnsma "git.loafle.net/commons_go/network_service_matcher/activedirectory" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type ActiveDirectoryHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *ActiveDirectoryHealthCrawler) Name() string { return "ACTIVEDIRECTORY_HEALTH_CRAWLER" } -func (c *ActiveDirectoryHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *ActiveDirectoryHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *ActiveDirectoryHealthCrawler) InternalGet(config *configM.Config) (map[ return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { ad := &ActiveDirectoryHealthCrawler{} - ad.Internal = ad ad.SetMatcher(cnsma.NewMatcher()) return ad } diff --git a/crawler/health/activedirectory/ActiveDirectoryHealthCrawler_test.go b/crawler/health/activedirectory/ActiveDirectoryHealthCrawler_test.go new file mode 100644 index 0000000..3baea28 --- /dev/null +++ b/crawler/health/activedirectory/ActiveDirectoryHealthCrawler_test.go @@ -0,0 +1,27 @@ +package activedirectory + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.1", + Port: json.Number(389), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/cassandra/CassandraHealthCrawler.go b/crawler/health/cassandra/CassandraHealthCrawler.go similarity index 61% rename from crawler/impl/health/cassandra/CassandraHealthCrawler.go rename to crawler/health/cassandra/CassandraHealthCrawler.go index dae2845..844d9aa 100644 --- a/crawler/impl/health/cassandra/CassandraHealthCrawler.go +++ b/crawler/health/cassandra/CassandraHealthCrawler.go @@ -2,9 +2,9 @@ package cassandra import ( cnsmc "git.loafle.net/commons_go/network_service_matcher/cassandra" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type CassandraHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *CassandraHealthCrawler) Name() string { return "CASSANDRA_HEALTH_CRAWLER" } -func (c *CassandraHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *CassandraHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *CassandraHealthCrawler) InternalGet(config *configM.Config) (map[string return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &CassandraHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmc.NewMatcher()) return c } diff --git a/crawler/health/cassandra/CassandraHealthCrawler_test.go b/crawler/health/cassandra/CassandraHealthCrawler_test.go new file mode 100644 index 0000000..f2e3d96 --- /dev/null +++ b/crawler/health/cassandra/CassandraHealthCrawler_test.go @@ -0,0 +1,27 @@ +package cassandra + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.104", + Port: json.Number(9042), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/dns/DNSHealthCrawler.go b/crawler/health/dns/DNSHealthCrawler.go similarity index 59% rename from crawler/impl/health/dns/DNSHealthCrawler.go rename to crawler/health/dns/DNSHealthCrawler.go index 3bcf5c8..6c8cac1 100644 --- a/crawler/impl/health/dns/DNSHealthCrawler.go +++ b/crawler/health/dns/DNSHealthCrawler.go @@ -2,9 +2,9 @@ package dns import ( cnsmd "git.loafle.net/commons_go/network_service_matcher/dns" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type DNSHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *DNSHealthCrawler) Name() string { return "DNS_HEALTH_CRAWLER" } -func (c *DNSHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *DNSHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *DNSHealthCrawler) InternalGet(config *configM.Config) (map[string]strin return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &DNSHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmd.NewMatcher()) return c } diff --git a/crawler/health/dns/DNSHealthCrawler_test.go b/crawler/health/dns/DNSHealthCrawler_test.go new file mode 100644 index 0000000..11e72ee --- /dev/null +++ b/crawler/health/dns/DNSHealthCrawler_test.go @@ -0,0 +1,27 @@ +package dns + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.215", + Port: json.Number(53), + PortType: "udp", + SSL: false, + } + + c := NewCrawler() + + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/ftp/FTPHealthCrawler.go b/crawler/health/ftp/FTPHealthCrawler.go similarity index 59% rename from crawler/impl/health/ftp/FTPHealthCrawler.go rename to crawler/health/ftp/FTPHealthCrawler.go index 215f76b..e197955 100644 --- a/crawler/impl/health/ftp/FTPHealthCrawler.go +++ b/crawler/health/ftp/FTPHealthCrawler.go @@ -2,9 +2,9 @@ package ftp import ( cnsmf "git.loafle.net/commons_go/network_service_matcher/ftp" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type FTPHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *FTPHealthCrawler) Name() string { return "FTP_HEALTH_CRAWLER" } -func (c *FTPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *FTPHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *FTPHealthCrawler) InternalGet(config *configM.Config) (map[string]strin return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &FTPHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmf.NewMatcher()) return c } diff --git a/crawler/health/ftp/FTPHealthCrawler_test.go b/crawler/health/ftp/FTPHealthCrawler_test.go new file mode 100644 index 0000000..080279c --- /dev/null +++ b/crawler/health/ftp/FTPHealthCrawler_test.go @@ -0,0 +1,27 @@ +package ftp + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.215", + Port: json.Number(21), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/http/HTTPHealthCrawler.go b/crawler/health/http/HTTPHealthCrawler.go similarity index 60% rename from crawler/impl/health/http/HTTPHealthCrawler.go rename to crawler/health/http/HTTPHealthCrawler.go index 2814339..8fd9c75 100644 --- a/crawler/impl/health/http/HTTPHealthCrawler.go +++ b/crawler/health/http/HTTPHealthCrawler.go @@ -2,9 +2,9 @@ package http import ( cnsmh "git.loafle.net/commons_go/network_service_matcher/http" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type HTTPHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *HTTPHealthCrawler) Name() string { return "HTTP_HEALTH_CRAWLER" } -func (c *HTTPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *HTTPHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *HTTPHealthCrawler) InternalGet(config *configM.Config) (map[string]stri return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &HTTPHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmh.NewMatcher()) return c } diff --git a/crawler/health/http/HTTPHealthCrawler_test.go b/crawler/health/http/HTTPHealthCrawler_test.go new file mode 100644 index 0000000..32d3845 --- /dev/null +++ b/crawler/health/http/HTTPHealthCrawler_test.go @@ -0,0 +1,27 @@ +package http + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.105", + Port: json.Number(80), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/imap/IMAPHealthCrawler.go b/crawler/health/imap/IMAPHealthCrawler.go similarity index 60% rename from crawler/impl/health/imap/IMAPHealthCrawler.go rename to crawler/health/imap/IMAPHealthCrawler.go index 9e6bcd7..3ee7a2f 100644 --- a/crawler/impl/health/imap/IMAPHealthCrawler.go +++ b/crawler/health/imap/IMAPHealthCrawler.go @@ -2,9 +2,9 @@ package imap import ( cnsmi "git.loafle.net/commons_go/network_service_matcher/imap" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type IMAPHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *IMAPHealthCrawler) Name() string { return "IMAP_HEALTH_CRAWLER" } -func (c *IMAPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *IMAPHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *IMAPHealthCrawler) InternalGet(config *configM.Config) (map[string]stri return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &IMAPHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmi.NewMatcher()) return c } diff --git a/crawler/health/imap/IMAPHealthCrawler_test.go b/crawler/health/imap/IMAPHealthCrawler_test.go new file mode 100644 index 0000000..4588775 --- /dev/null +++ b/crawler/health/imap/IMAPHealthCrawler_test.go @@ -0,0 +1,27 @@ +package imap + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.215", + Port: json.Number(993), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/ldap/LDAPHealthCrawler.go b/crawler/health/ldap/LDAPHealthCrawler.go similarity index 60% rename from crawler/impl/health/ldap/LDAPHealthCrawler.go rename to crawler/health/ldap/LDAPHealthCrawler.go index ad4267d..a20c0c4 100644 --- a/crawler/impl/health/ldap/LDAPHealthCrawler.go +++ b/crawler/health/ldap/LDAPHealthCrawler.go @@ -2,9 +2,9 @@ package ldap import ( cnsml "git.loafle.net/commons_go/network_service_matcher/ldap" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type LDAPHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *LDAPHealthCrawler) Name() string { return "LDAP_HEALTH_CRAWLER" } -func (c *LDAPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *LDAPHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *LDAPHealthCrawler) InternalGet(config *configM.Config) (map[string]stri return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &LDAPHealthCrawler{} - c.Internal = c c.SetMatcher(cnsml.NewMatcher()) return c } diff --git a/crawler/health/ldap/LDAPHealthCrawler_test.go b/crawler/health/ldap/LDAPHealthCrawler_test.go new file mode 100644 index 0000000..ab2bd58 --- /dev/null +++ b/crawler/health/ldap/LDAPHealthCrawler_test.go @@ -0,0 +1,27 @@ +package ldap + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.215", + Port: json.Number(389), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/mongodb/MongoDBHealthCrawler.go b/crawler/health/mongodb/MongoDBHealthCrawler.go similarity index 60% rename from crawler/impl/health/mongodb/MongoDBHealthCrawler.go rename to crawler/health/mongodb/MongoDBHealthCrawler.go index 82d8d99..0d8e6a3 100644 --- a/crawler/impl/health/mongodb/MongoDBHealthCrawler.go +++ b/crawler/health/mongodb/MongoDBHealthCrawler.go @@ -2,9 +2,9 @@ package mongodb import ( cnsmm "git.loafle.net/commons_go/network_service_matcher/mongodb" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type MongoDBHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *MongoDBHealthCrawler) Name() string { return "MONGODB_HEALTH_CRAWLER" } -func (c *MongoDBHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *MongoDBHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *MongoDBHealthCrawler) InternalGet(config *configM.Config) (map[string]s return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &MongoDBHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmm.NewMatcher()) return c } diff --git a/crawler/health/mongodb/MongoDBHealthCrawler_test.go b/crawler/health/mongodb/MongoDBHealthCrawler_test.go new file mode 100644 index 0000000..26d533c --- /dev/null +++ b/crawler/health/mongodb/MongoDBHealthCrawler_test.go @@ -0,0 +1,27 @@ +package mongodb + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.104", + Port: json.Number(27017), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/mysql/MySQLHealthCrawler.go b/crawler/health/mysql/MySQLHealthCrawler.go similarity index 60% rename from crawler/impl/health/mysql/MySQLHealthCrawler.go rename to crawler/health/mysql/MySQLHealthCrawler.go index d21bf4b..a16155e 100644 --- a/crawler/impl/health/mysql/MySQLHealthCrawler.go +++ b/crawler/health/mysql/MySQLHealthCrawler.go @@ -2,9 +2,9 @@ package mysql import ( cnsmm "git.loafle.net/commons_go/network_service_matcher/mysql" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type MySQLHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *MySQLHealthCrawler) Name() string { return "MYSQL_HEALTH_CRAWLER" } -func (c *MySQLHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *MySQLHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *MySQLHealthCrawler) InternalGet(config *configM.Config) (map[string]str return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &MySQLHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmm.NewMatcher()) return c } diff --git a/crawler/health/mysql/MySQLHealthCrawler_test.go b/crawler/health/mysql/MySQLHealthCrawler_test.go new file mode 100644 index 0000000..61495f6 --- /dev/null +++ b/crawler/health/mysql/MySQLHealthCrawler_test.go @@ -0,0 +1,26 @@ +package mysql + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.103", + Port: json.Number(3306), + PortType: "tcp", + SSL: false, + } + c := NewCrawler() + + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/netbios/NetBIOSHealthCrawler.go b/crawler/health/netbios/NetBIOSHealthCrawler.go similarity index 60% rename from crawler/impl/health/netbios/NetBIOSHealthCrawler.go rename to crawler/health/netbios/NetBIOSHealthCrawler.go index 4678917..5f27d7c 100644 --- a/crawler/impl/health/netbios/NetBIOSHealthCrawler.go +++ b/crawler/health/netbios/NetBIOSHealthCrawler.go @@ -2,9 +2,9 @@ package netbios import ( cnsmn "git.loafle.net/commons_go/network_service_matcher/netbios" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type NetBIOSHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *NetBIOSHealthCrawler) Name() string { return "NETBIOS_HEALTH_CRAWLER" } -func (c *NetBIOSHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *NetBIOSHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *NetBIOSHealthCrawler) InternalGet(config *configM.Config) (map[string]s return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &NetBIOSHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmn.NewMatcher()) return c } diff --git a/crawler/health/netbios/NetBIOSHealthCrawler_test.go b/crawler/health/netbios/NetBIOSHealthCrawler_test.go new file mode 100644 index 0000000..958a931 --- /dev/null +++ b/crawler/health/netbios/NetBIOSHealthCrawler_test.go @@ -0,0 +1,26 @@ +package netbios + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.106", + Port: json.Number(139), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/oracle/OracleHealthCrawler.go b/crawler/health/oracle/OracleHealthCrawler.go similarity index 60% rename from crawler/impl/health/oracle/OracleHealthCrawler.go rename to crawler/health/oracle/OracleHealthCrawler.go index 545f27f..45f1b6e 100644 --- a/crawler/impl/health/oracle/OracleHealthCrawler.go +++ b/crawler/health/oracle/OracleHealthCrawler.go @@ -2,9 +2,9 @@ package oracle import ( cnsmo "git.loafle.net/commons_go/network_service_matcher/oracle" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type OracleHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *OracleHealthCrawler) Name() string { return "ORACLE_HEALTH_CRAWLER" } -func (c *OracleHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *OracleHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *OracleHealthCrawler) InternalGet(config *configM.Config) (map[string]st return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &OracleHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmo.NewMatcher()) return c } diff --git a/crawler/health/oracle/OracleHealthCrawler_test.go b/crawler/health/oracle/OracleHealthCrawler_test.go new file mode 100644 index 0000000..e0ed602 --- /dev/null +++ b/crawler/health/oracle/OracleHealthCrawler_test.go @@ -0,0 +1,26 @@ +package oracle + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.30", + Port: json.Number(1521), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/pop/POPHealthCrawler.go b/crawler/health/pop/POPHealthCrawler.go similarity index 59% rename from crawler/impl/health/pop/POPHealthCrawler.go rename to crawler/health/pop/POPHealthCrawler.go index 875b105..0129d1c 100644 --- a/crawler/impl/health/pop/POPHealthCrawler.go +++ b/crawler/health/pop/POPHealthCrawler.go @@ -2,9 +2,9 @@ package pop import ( cnsmp "git.loafle.net/commons_go/network_service_matcher/pop" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type POPHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *POPHealthCrawler) Name() string { return "POP_HEALTH_CRAWLER" } -func (c *POPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *POPHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *POPHealthCrawler) InternalGet(config *configM.Config) (map[string]strin return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &POPHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmp.NewMatcher()) return c } diff --git a/crawler/health/pop/POPHealthCrawler_test.go b/crawler/health/pop/POPHealthCrawler_test.go new file mode 100644 index 0000000..57678a8 --- /dev/null +++ b/crawler/health/pop/POPHealthCrawler_test.go @@ -0,0 +1,26 @@ +package pop + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.215", + Port: json.Number(110), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/postgresql/PostgreSQLHealthCrawler.go b/crawler/health/postgresql/PostgreSQLHealthCrawler.go similarity index 61% rename from crawler/impl/health/postgresql/PostgreSQLHealthCrawler.go rename to crawler/health/postgresql/PostgreSQLHealthCrawler.go index 8b82eb5..ce870d7 100644 --- a/crawler/impl/health/postgresql/PostgreSQLHealthCrawler.go +++ b/crawler/health/postgresql/PostgreSQLHealthCrawler.go @@ -2,9 +2,9 @@ package postgresql import ( cnsmp "git.loafle.net/commons_go/network_service_matcher/postgresql" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type PostgreSQLHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *PostgreSQLHealthCrawler) Name() string { return "POSTGRESQL_HEALTH_CRAWLER" } -func (c *PostgreSQLHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *PostgreSQLHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *PostgreSQLHealthCrawler) InternalGet(config *configM.Config) (map[strin return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &PostgreSQLHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmp.NewMatcher()) return c } diff --git a/crawler/health/postgresql/PostgreSQLHealthCrawler_test.go b/crawler/health/postgresql/PostgreSQLHealthCrawler_test.go new file mode 100644 index 0000000..a843b4d --- /dev/null +++ b/crawler/health/postgresql/PostgreSQLHealthCrawler_test.go @@ -0,0 +1,26 @@ +package postgresql + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.107", + Port: json.Number(5432), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/redis/RedisHealthCrawler.go b/crawler/health/redis/RedisHealthCrawler.go similarity index 60% rename from crawler/impl/health/redis/RedisHealthCrawler.go rename to crawler/health/redis/RedisHealthCrawler.go index 1271886..eda0e59 100644 --- a/crawler/impl/health/redis/RedisHealthCrawler.go +++ b/crawler/health/redis/RedisHealthCrawler.go @@ -2,9 +2,9 @@ package redis import ( cnsmr "git.loafle.net/commons_go/network_service_matcher/redis" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type RedisHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *RedisHealthCrawler) Name() string { return "REDIS_HEALTH_CRAWLER" } -func (c *RedisHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *RedisHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *RedisHealthCrawler) InternalGet(config *configM.Config) (map[string]str return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &RedisHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmr.NewMatcher()) return c } diff --git a/crawler/health/redis/RedisHealthCrawler_test.go b/crawler/health/redis/RedisHealthCrawler_test.go new file mode 100644 index 0000000..756126c --- /dev/null +++ b/crawler/health/redis/RedisHealthCrawler_test.go @@ -0,0 +1,27 @@ +package redis + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.104", + Port: json.Number(6379), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/rmi/RMIHealthCrawler.go b/crawler/health/rmi/RMIHealthCrawler.go similarity index 59% rename from crawler/impl/health/rmi/RMIHealthCrawler.go rename to crawler/health/rmi/RMIHealthCrawler.go index 32791a6..f4d7b1d 100644 --- a/crawler/impl/health/rmi/RMIHealthCrawler.go +++ b/crawler/health/rmi/RMIHealthCrawler.go @@ -2,9 +2,9 @@ package rmi import ( cnsmr "git.loafle.net/commons_go/network_service_matcher/rmi" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type RMIHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *RMIHealthCrawler) Name() string { return "RMI_HEALTH_CRAWLER" } -func (c *RMIHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *RMIHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *RMIHealthCrawler) InternalGet(config *configM.Config) (map[string]strin return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &RMIHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmr.NewMatcher()) return c } diff --git a/crawler/health/rmi/RMIHealthCrawler_test.go b/crawler/health/rmi/RMIHealthCrawler_test.go new file mode 100644 index 0000000..905f063 --- /dev/null +++ b/crawler/health/rmi/RMIHealthCrawler_test.go @@ -0,0 +1,26 @@ +package rmi + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.103", + Port: json.Number(9840), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/smb/SMBHealthCrawler.go b/crawler/health/smb/SMBHealthCrawler.go similarity index 59% rename from crawler/impl/health/smb/SMBHealthCrawler.go rename to crawler/health/smb/SMBHealthCrawler.go index 17d7b8f..a0803fe 100644 --- a/crawler/impl/health/smb/SMBHealthCrawler.go +++ b/crawler/health/smb/SMBHealthCrawler.go @@ -2,9 +2,9 @@ package smb import ( cnsms "git.loafle.net/commons_go/network_service_matcher/smb" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type SMBHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *SMBHealthCrawler) Name() string { return "SMB_HEALTH_CRAWLER" } -func (c *SMBHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *SMBHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *SMBHealthCrawler) InternalGet(config *configM.Config) (map[string]strin return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &SMBHealthCrawler{} - c.Internal = c c.SetMatcher(cnsms.NewMatcher()) return c } diff --git a/crawler/health/smb/SMBHealthCrawler_test.go b/crawler/health/smb/SMBHealthCrawler_test.go new file mode 100644 index 0000000..9471489 --- /dev/null +++ b/crawler/health/smb/SMBHealthCrawler_test.go @@ -0,0 +1,26 @@ +package smb + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.106", + Port: json.Number(445), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/smtp/SMTPHealthCrawler.go b/crawler/health/smtp/SMTPHealthCrawler.go similarity index 60% rename from crawler/impl/health/smtp/SMTPHealthCrawler.go rename to crawler/health/smtp/SMTPHealthCrawler.go index d9f6608..0b46273 100644 --- a/crawler/impl/health/smtp/SMTPHealthCrawler.go +++ b/crawler/health/smtp/SMTPHealthCrawler.go @@ -2,9 +2,9 @@ package smtp import ( cnsms "git.loafle.net/commons_go/network_service_matcher/smtp" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type SMTPHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *SMTPHealthCrawler) Name() string { return "SMTP_HEALTH_CRAWLER" } -func (c *SMTPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *SMTPHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *SMTPHealthCrawler) InternalGet(config *configM.Config) (map[string]stri return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &SMTPHealthCrawler{} - c.Internal = c c.SetMatcher(cnsms.NewMatcher()) return c } diff --git a/crawler/health/smtp/SMTPHealthCrawler_test.go b/crawler/health/smtp/SMTPHealthCrawler_test.go new file mode 100644 index 0000000..663e548 --- /dev/null +++ b/crawler/health/smtp/SMTPHealthCrawler_test.go @@ -0,0 +1,26 @@ +package smtp + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.215", + Port: json.Number(25), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/snmp/v2/SNMPHealthCrawler.go b/crawler/health/snmp/v2/SNMPHealthCrawler.go similarity index 60% rename from crawler/impl/health/snmp/v2/SNMPHealthCrawler.go rename to crawler/health/snmp/v2/SNMPHealthCrawler.go index 63bd5a7..ac0325c 100644 --- a/crawler/impl/health/snmp/v2/SNMPHealthCrawler.go +++ b/crawler/health/snmp/v2/SNMPHealthCrawler.go @@ -2,9 +2,9 @@ package v2 import ( cnsms "git.loafle.net/commons_go/network_service_matcher/snmp/v2" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type SNMPHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *SNMPHealthCrawler) Name() string { return "SNMPV2C_HEALTH_CRAWLER" } -func (c *SNMPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *SNMPHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *SNMPHealthCrawler) InternalGet(config *configM.Config) (map[string]stri return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &SNMPHealthCrawler{} - c.Internal = c c.SetMatcher(cnsms.NewMatcher()) return c } diff --git a/crawler/health/snmp/v2/SNMPHealthCrawler_test.go b/crawler/health/snmp/v2/SNMPHealthCrawler_test.go new file mode 100644 index 0000000..1bdfe4d --- /dev/null +++ b/crawler/health/snmp/v2/SNMPHealthCrawler_test.go @@ -0,0 +1,26 @@ +package v2 + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.215", + Port: json.Number(161), + PortType: "udp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/snmp/v3/SNMPHealthCrawler.go b/crawler/health/snmp/v3/SNMPHealthCrawler.go similarity index 60% rename from crawler/impl/health/snmp/v3/SNMPHealthCrawler.go rename to crawler/health/snmp/v3/SNMPHealthCrawler.go index ae380a8..a464f33 100644 --- a/crawler/impl/health/snmp/v3/SNMPHealthCrawler.go +++ b/crawler/health/snmp/v3/SNMPHealthCrawler.go @@ -2,9 +2,9 @@ package v3 import ( cnsms "git.loafle.net/commons_go/network_service_matcher/snmp/v3" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type SNMPHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *SNMPHealthCrawler) Name() string { return "SNMPV3_HEALTH_CRAWLER" } -func (c *SNMPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *SNMPHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *SNMPHealthCrawler) InternalGet(config *configM.Config) (map[string]stri return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &SNMPHealthCrawler{} - c.Internal = c c.SetMatcher(cnsms.NewMatcher()) return c } diff --git a/crawler/health/snmp/v3/SNMPHealthCrawler_test.go b/crawler/health/snmp/v3/SNMPHealthCrawler_test.go new file mode 100644 index 0000000..5c6396b --- /dev/null +++ b/crawler/health/snmp/v3/SNMPHealthCrawler_test.go @@ -0,0 +1,26 @@ +package v3 + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.254", + Port: json.Number(161), + PortType: "udp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/sqlserver/SQLServerHealthCrawler.go b/crawler/health/sqlserver/SQLServerHealthCrawler.go similarity index 61% rename from crawler/impl/health/sqlserver/SQLServerHealthCrawler.go rename to crawler/health/sqlserver/SQLServerHealthCrawler.go index 4630bf2..8a33c6e 100644 --- a/crawler/impl/health/sqlserver/SQLServerHealthCrawler.go +++ b/crawler/health/sqlserver/SQLServerHealthCrawler.go @@ -2,9 +2,9 @@ package sqlserver import ( cnsms "git.loafle.net/commons_go/network_service_matcher/sqlserver" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type SQLServerHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *SQLServerHealthCrawler) Name() string { return "SQLSERVER_HEALTH_CRAWLER" } -func (c *SQLServerHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *SQLServerHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *SQLServerHealthCrawler) InternalGet(config *configM.Config) (map[string return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &SQLServerHealthCrawler{} - c.Internal = c c.SetMatcher(cnsms.NewMatcher()) return c } diff --git a/crawler/health/sqlserver/SQLServerHealthCrawler_test.go b/crawler/health/sqlserver/SQLServerHealthCrawler_test.go new file mode 100644 index 0000000..2486992 --- /dev/null +++ b/crawler/health/sqlserver/SQLServerHealthCrawler_test.go @@ -0,0 +1,26 @@ +package sqlserver + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.106", + Port: json.Number(1433), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/ssh/SSHHealthCrawler.go b/crawler/health/ssh/SSHHealthCrawler.go similarity index 59% rename from crawler/impl/health/ssh/SSHHealthCrawler.go rename to crawler/health/ssh/SSHHealthCrawler.go index 539638f..63d2a1b 100644 --- a/crawler/impl/health/ssh/SSHHealthCrawler.go +++ b/crawler/health/ssh/SSHHealthCrawler.go @@ -2,9 +2,9 @@ package ssh import ( cnsms "git.loafle.net/commons_go/network_service_matcher/ssh" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type SSHHealthCrawler struct { @@ -15,7 +15,7 @@ func (c *SSHHealthCrawler) Name() string { return "SSH_HEALTH_CRAWLER" } -func (c *SSHHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *SSHHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -23,9 +23,8 @@ func (c *SSHHealthCrawler) InternalGet(config *configM.Config) (map[string]strin return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &SSHHealthCrawler{} - c.Internal = c c.SetMatcher(cnsms.NewMatcher()) return c } diff --git a/crawler/health/ssh/SSHHealthCrawler_test.go b/crawler/health/ssh/SSHHealthCrawler_test.go new file mode 100644 index 0000000..2e6fae1 --- /dev/null +++ b/crawler/health/ssh/SSHHealthCrawler_test.go @@ -0,0 +1,26 @@ +package ssh + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.215", + Port: json.Number(22), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/telnet/TelnetHealthCrawler.go b/crawler/health/telnet/TelnetHealthCrawler.go similarity index 60% rename from crawler/impl/health/telnet/TelnetHealthCrawler.go rename to crawler/health/telnet/TelnetHealthCrawler.go index f86f840..8aaaa06 100644 --- a/crawler/impl/health/telnet/TelnetHealthCrawler.go +++ b/crawler/health/telnet/TelnetHealthCrawler.go @@ -1,11 +1,10 @@ package telnet - import ( cnsmt "git.loafle.net/commons_go/network_service_matcher/telnet" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type TelnetHealthCrawler struct { @@ -16,7 +15,7 @@ func (c *TelnetHealthCrawler) Name() string { return "TELNET_HEALTH_CRAWLER" } -func (c *TelnetHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *TelnetHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -24,9 +23,8 @@ func (c *TelnetHealthCrawler) InternalGet(config *configM.Config) (map[string]st return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &TelnetHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmt.NewMatcher()) return c } diff --git a/crawler/health/telnet/TelnetHealthCrawler_test.go b/crawler/health/telnet/TelnetHealthCrawler_test.go new file mode 100644 index 0000000..b61b7d9 --- /dev/null +++ b/crawler/health/telnet/TelnetHealthCrawler_test.go @@ -0,0 +1,26 @@ +package telnet + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.215", + Port: json.Number(23), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/wmi/WMIHealthCrawler.go b/crawler/health/wmi/WMIHealthCrawler.go similarity index 59% rename from crawler/impl/health/wmi/WMIHealthCrawler.go rename to crawler/health/wmi/WMIHealthCrawler.go index a4b71c3..aaa7e7a 100644 --- a/crawler/impl/health/wmi/WMIHealthCrawler.go +++ b/crawler/health/wmi/WMIHealthCrawler.go @@ -1,11 +1,10 @@ package wmi - import ( cnsmw "git.loafle.net/commons_go/network_service_matcher/wmi" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/health" ) type WMIHealthCrawler struct { @@ -16,7 +15,7 @@ func (c *WMIHealthCrawler) Name() string { return "WMI_HEALTH_CRAWLER" } -func (c *WMIHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *WMIHealthCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { rss, err := c.CheckHeahth(config) if err != nil { return nil, err @@ -24,9 +23,8 @@ func (c *WMIHealthCrawler) InternalGet(config *configM.Config) (map[string]strin return rss, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &WMIHealthCrawler{} - c.Internal = c c.SetMatcher(cnsmw.NewMatcher()) return c } diff --git a/crawler/health/wmi/WMIHealthCrawler_test.go b/crawler/health/wmi/WMIHealthCrawler_test.go new file mode 100644 index 0000000..194ee70 --- /dev/null +++ b/crawler/health/wmi/WMIHealthCrawler_test.go @@ -0,0 +1,26 @@ +package wmi + +import ( + "encoding/json" + "testing" + + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + "github.com/stretchr/testify/assert" +) + +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} + config.Target = &sensorConfigM.Target{} + config.Target.Connection = &sensorConfigM.Connection{ + IP: "192.168.1.1", + Port: json.Number(135), + PortType: "tcp", + SSL: false, + } + + c := NewCrawler() + rss, err := c.Get(config) + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler_test.go b/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler_test.go deleted file mode 100644 index 37aa2be..0000000 --- a/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package activedirectory - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*ActiveDirectoryHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.1", - Port: json.Number(389), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/cassandra/CassandraHealthCrawler_test.go b/crawler/impl/health/cassandra/CassandraHealthCrawler_test.go deleted file mode 100644 index 88ec770..0000000 --- a/crawler/impl/health/cassandra/CassandraHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package cassandra - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*CassandraHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.104", - Port: json.Number(9042), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/dns/DNSHealthCrawler_test.go b/crawler/impl/health/dns/DNSHealthCrawler_test.go deleted file mode 100644 index 7ab2993..0000000 --- a/crawler/impl/health/dns/DNSHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package dns - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*DNSHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.215", - Port: json.Number(53), - PortType: "udp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/ftp/FTPHealthCrawler_test.go b/crawler/impl/health/ftp/FTPHealthCrawler_test.go deleted file mode 100644 index d7a7888..0000000 --- a/crawler/impl/health/ftp/FTPHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package ftp - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*FTPHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.215", - Port: json.Number(21), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/http/HTTPHealthCrawler_test.go b/crawler/impl/health/http/HTTPHealthCrawler_test.go deleted file mode 100644 index 198b5ef..0000000 --- a/crawler/impl/health/http/HTTPHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package http - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*HTTPHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.105", - Port: json.Number(80), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/imap/IMAPHealthCrawler_test.go b/crawler/impl/health/imap/IMAPHealthCrawler_test.go deleted file mode 100644 index 57408d7..0000000 --- a/crawler/impl/health/imap/IMAPHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package imap - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*IMAPHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.215", - Port: json.Number(993), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/ldap/LDAPHealthCrawler_test.go b/crawler/impl/health/ldap/LDAPHealthCrawler_test.go deleted file mode 100644 index 6d66abf..0000000 --- a/crawler/impl/health/ldap/LDAPHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package ldap - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*LDAPHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.215", - Port: json.Number(389), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/mongodb/MongoDBHealthCrawler_test.go b/crawler/impl/health/mongodb/MongoDBHealthCrawler_test.go deleted file mode 100644 index f4009c5..0000000 --- a/crawler/impl/health/mongodb/MongoDBHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package mongodb - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*MongoDBHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.104", - Port: json.Number(27017), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/mysql/MySQLHealthCrawler_test.go b/crawler/impl/health/mysql/MySQLHealthCrawler_test.go deleted file mode 100644 index d33c843..0000000 --- a/crawler/impl/health/mysql/MySQLHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package mysql - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*MySQLHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.103", - Port: json.Number(3306), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/netbios/NetBIOSHealthCrawler_test.go b/crawler/impl/health/netbios/NetBIOSHealthCrawler_test.go deleted file mode 100644 index 437dc1c..0000000 --- a/crawler/impl/health/netbios/NetBIOSHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package netbios - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*NetBIOSHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.106", - Port: json.Number(139), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/oracle/OracleHealthCrawler_test.go b/crawler/impl/health/oracle/OracleHealthCrawler_test.go deleted file mode 100644 index 5ec6b26..0000000 --- a/crawler/impl/health/oracle/OracleHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package oracle - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*OracleHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.30", - Port: json.Number(1521), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/pop/POPHealthCrawler_test.go b/crawler/impl/health/pop/POPHealthCrawler_test.go deleted file mode 100644 index 5ba8b6b..0000000 --- a/crawler/impl/health/pop/POPHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package pop - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*POPHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.215", - Port: json.Number(110), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/postgresql/PostgreSQLHealthCrawler_test.go b/crawler/impl/health/postgresql/PostgreSQLHealthCrawler_test.go deleted file mode 100644 index 18f5980..0000000 --- a/crawler/impl/health/postgresql/PostgreSQLHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package postgresql - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*PostgreSQLHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.107", - Port: json.Number(5432), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/redis/RedisHealthCrawler_test.go b/crawler/impl/health/redis/RedisHealthCrawler_test.go deleted file mode 100644 index d5f41cc..0000000 --- a/crawler/impl/health/redis/RedisHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package redis - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*RedisHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.104", - Port: json.Number(6379), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/rmi/RMIHealthCrawler_test.go b/crawler/impl/health/rmi/RMIHealthCrawler_test.go deleted file mode 100644 index a3f6ed7..0000000 --- a/crawler/impl/health/rmi/RMIHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package rmi - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*RMIHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.103", - Port: json.Number(9840), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/smb/SMBHealthCrawler_test.go b/crawler/impl/health/smb/SMBHealthCrawler_test.go deleted file mode 100644 index 8490f73..0000000 --- a/crawler/impl/health/smb/SMBHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package smb - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*SMBHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.106", - Port: json.Number(445), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/smtp/SMTPHealthCrawler_test.go b/crawler/impl/health/smtp/SMTPHealthCrawler_test.go deleted file mode 100644 index 384cbee..0000000 --- a/crawler/impl/health/smtp/SMTPHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package smtp - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*SMTPHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.215", - Port: json.Number(25), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/snmp/v2/SNMPHealthCrawler_test.go b/crawler/impl/health/snmp/v2/SNMPHealthCrawler_test.go deleted file mode 100644 index 0db3787..0000000 --- a/crawler/impl/health/snmp/v2/SNMPHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package v2 - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*SNMPHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.215", - Port: json.Number(161), - PortType: "udp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/snmp/v3/SNMPHealthCrawler_test.go b/crawler/impl/health/snmp/v3/SNMPHealthCrawler_test.go deleted file mode 100644 index 945b07f..0000000 --- a/crawler/impl/health/snmp/v3/SNMPHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package v3 - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*SNMPHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.254", - Port: json.Number(161), - PortType: "udp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/sqlserver/SQLServerHealthCrawler_test.go b/crawler/impl/health/sqlserver/SQLServerHealthCrawler_test.go deleted file mode 100644 index cd4cb13..0000000 --- a/crawler/impl/health/sqlserver/SQLServerHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package sqlserver - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*SQLServerHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.106", - Port: json.Number(1433), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/ssh/SSHHealthCrawler_test.go b/crawler/impl/health/ssh/SSHHealthCrawler_test.go deleted file mode 100644 index 1d3be38..0000000 --- a/crawler/impl/health/ssh/SSHHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package ssh - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*SSHHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.215", - Port: json.Number(22), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/telnet/TelnetHealthCrawler_test.go b/crawler/impl/health/telnet/TelnetHealthCrawler_test.go deleted file mode 100644 index 58f0bba..0000000 --- a/crawler/impl/health/telnet/TelnetHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package telnet - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*TelnetHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.215", - Port: json.Number(23), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/health/wmi/WMIHealthCrawler_test.go b/crawler/impl/health/wmi/WMIHealthCrawler_test.go deleted file mode 100644 index 223c34f..0000000 --- a/crawler/impl/health/wmi/WMIHealthCrawler_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package wmi - -import ( - "encoding/json" - "testing" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "github.com/stretchr/testify/assert" -) - -func setConfig() crawler.Crawler { - - c := NewCrawler().(*WMIHealthCrawler) - config := &configM.Config{} - config.Target = &configM.Target{} - config.Target.Connection = &configM.Connection{ - IP: "192.168.1.1", - Port: json.Number(135), - PortType: "tcp", - SSL: false, - } - - c.PutConfig("c", config) - - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") - - assert.Nil(t, err) - assert.NotNil(t, rss) -} diff --git a/crawler/impl/impl.go b/crawler/impl/impl.go deleted file mode 100644 index 4058525..0000000 --- a/crawler/impl/impl.go +++ /dev/null @@ -1,72 +0,0 @@ -package impl - -import ( - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - activedirectoryH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/activedirectory" - cassandraH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/cassandra" - dnsH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/dns" - ftpH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/ftp" - httpH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/http" - imapH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/imap" - ldapH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/ldap" - mongodbH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/mongodb" - mysqlH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/mysql" - netbiosH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/netbios" - oracleH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/oracle" - popH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/pop" - postgresqlH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/postgresql" - redisH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/redis" - rmiH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/rmi" - smbH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/smb" - smtpH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/smtp" - snmpV2H "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/snmp/v2" - snmpV3H "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/snmp/v3" - sqlserverH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/sqlserver" - sshH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/ssh" - telnetH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/telnet" - wmiH "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health/wmi" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/ssh" -) - -var crawlers map[string]crawler.Crawler - -func init() { - crawlers = make(map[string]crawler.Crawler, 0) - - addCrawler(activedirectoryH.NewCrawler()) - addCrawler(cassandraH.NewCrawler()) - addCrawler(dnsH.NewCrawler()) - addCrawler(ftpH.NewCrawler()) - addCrawler(httpH.NewCrawler()) - addCrawler(imapH.NewCrawler()) - addCrawler(ldapH.NewCrawler()) - addCrawler(mongodbH.NewCrawler()) - addCrawler(mysqlH.NewCrawler()) - addCrawler(netbiosH.NewCrawler()) - addCrawler(oracleH.NewCrawler()) - addCrawler(popH.NewCrawler()) - addCrawler(postgresqlH.NewCrawler()) - addCrawler(redisH.NewCrawler()) - addCrawler(rmiH.NewCrawler()) - addCrawler(smbH.NewCrawler()) - addCrawler(smtpH.NewCrawler()) - addCrawler(snmpV2H.NewCrawler()) - addCrawler(snmpV3H.NewCrawler()) - addCrawler(sqlserverH.NewCrawler()) - addCrawler(sshH.NewCrawler()) - addCrawler(telnetH.NewCrawler()) - addCrawler(wmiH.NewCrawler()) - addCrawler(ssh.NewCrawler()) -} - -func addCrawler(c crawler.Crawler) { - crawlers[c.Name()] = c -} - -func GetCrawler(name string) crawler.Crawler { - c, ok := crawlers[name] - if !ok { - return nil - } - return c -} diff --git a/crawler/impl/ssh/SSHCrawler.go b/crawler/ssh/SSHCrawler.go similarity index 72% rename from crawler/impl/ssh/SSHCrawler.go rename to crawler/ssh/SSHCrawler.go index 0ba74b2..0570455 100644 --- a/crawler/impl/ssh/SSHCrawler.go +++ b/crawler/ssh/SSHCrawler.go @@ -5,23 +5,23 @@ import ( "bytes" "fmt" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - configUtil "git.loafle.net/overflow/overflow_commons_go/modules/config/util" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/ssh/client" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/ssh/parser" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" + sensorConfigUtil "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/util" + oopcc "git.loafle.net/overflow/overflow_probe_container/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/ssh/client" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/ssh/parser" "github.com/satori/go.uuid" ) type SSHCrawler struct { - crawler.Crawlers + oopcc.Crawler } func (c *SSHCrawler) Name() string { return "SSH_CRAWLER" } -func (c *SSHCrawler) InternalGet(config *configM.Config) (map[string]string, error) { +func (c *SSHCrawler) Get(config *sensorConfigM.SensorConfig) (map[string]string, error) { sshClient, err := client.New(config.Target) if nil != err { return nil, err @@ -29,7 +29,12 @@ func (c *SSHCrawler) InternalGet(config *configM.Config) (map[string]string, err itemCount := len(config.Items) results := make(map[string]string, 0) - boundary := uuid.NewV4().String() + uuid, err := uuid.NewV4() + if nil != err { + return nil, err + } + + boundary := uuid.String() commands := "" for i := 0; i < itemCount; i++ { @@ -65,7 +70,7 @@ func (c *SSHCrawler) InternalGet(config *configM.Config) (map[string]string, err } if nil != rm { - mm := configUtil.KeysToMap(item.Keys) + mm := sensorConfigUtil.KeysToMap(item.Keys) for key, value := range mm { results[value] = rm[key] } @@ -79,9 +84,8 @@ func (c *SSHCrawler) InternalGet(config *configM.Config) (map[string]string, err return results, nil } -func NewCrawler() crawler.Crawler { +func NewCrawler() oopcc.Crawler { c := &SSHCrawler{} - c.Internal = c return c } diff --git a/crawler/impl/ssh/SSHCrawler_test.go b/crawler/ssh/SSHCrawler_test.go similarity index 56% rename from crawler/impl/ssh/SSHCrawler_test.go rename to crawler/ssh/SSHCrawler_test.go index 7932b3b..b1624c0 100644 --- a/crawler/impl/ssh/SSHCrawler_test.go +++ b/crawler/ssh/SSHCrawler_test.go @@ -6,13 +6,12 @@ import ( "log" "testing" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" "github.com/stretchr/testify/assert" ) -func setConfig() crawler.Crawler { - config := &configM.Config{} +func TestMatch(t *testing.T) { + config := &sensorConfigM.SensorConfig{} data, err := ioutil.ReadFile("./SSHCrawler_test.json") if err != nil { log.Fatal(err) @@ -23,16 +22,8 @@ func setConfig() crawler.Crawler { } c := NewCrawler().(*SSHCrawler) - c.PutConfig("c", config) - return c -} - -func TestMatch(t *testing.T) { - // test config - c := setConfig() - - rss, err := c.Get("c") + rss, err := c.Get(config) assert.Nil(t, err) assert.NotNil(t, rss) diff --git a/crawler/impl/ssh/SSHCrawler_test.json b/crawler/ssh/SSHCrawler_test.json similarity index 100% rename from crawler/impl/ssh/SSHCrawler_test.json rename to crawler/ssh/SSHCrawler_test.json diff --git a/crawler/impl/ssh/client/client.go b/crawler/ssh/client/client.go similarity index 94% rename from crawler/impl/ssh/client/client.go rename to crawler/ssh/client/client.go index bf82e95..ed1118c 100644 --- a/crawler/impl/ssh/client/client.go +++ b/crawler/ssh/client/client.go @@ -8,7 +8,7 @@ import ( "git.loafle.net/commons_go/logging" cuej "git.loafle.net/commons_go/util/encoding/json" - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + sensorConfigM "git.loafle.net/overflow/overflow_commons_go/modules/sensor_config/model" "golang.org/x/crypto/ssh" ) @@ -88,7 +88,7 @@ func parsePrivateKey(keyPath, pw string) (ssh.Signer, error) { return ssh.ParsePrivateKeyWithPassphrase(buff, []byte(pw)) } -func New(target *configM.Target) (*SSHClient, error) { +func New(target *sensorConfigM.Target) (*SSHClient, error) { connection := target.Connection auth := target.Auth diff --git a/crawler/impl/ssh/parser/cpu_parser.go b/crawler/ssh/parser/cpu_parser.go similarity index 100% rename from crawler/impl/ssh/parser/cpu_parser.go rename to crawler/ssh/parser/cpu_parser.go diff --git a/crawler/impl/ssh/parser/memory_parser.go b/crawler/ssh/parser/memory_parser.go similarity index 100% rename from crawler/impl/ssh/parser/memory_parser.go rename to crawler/ssh/parser/memory_parser.go diff --git a/crawler/impl/ssh/parser/parser.go b/crawler/ssh/parser/parser.go similarity index 100% rename from crawler/impl/ssh/parser/parser.go rename to crawler/ssh/parser/parser.go diff --git a/server/server.go b/server/server.go index e5fb359..5418f69 100644 --- a/server/server.go +++ b/server/server.go @@ -8,8 +8,10 @@ import ( crr "git.loafle.net/commons_go/rpc/registry" "git.loafle.net/commons_go/server" ooca "git.loafle.net/overflow/overflow_commons_go/annotation" + oopc "git.loafle.net/overflow/overflow_probe_container" oopcs "git.loafle.net/overflow/overflow_probe_container/server" oopcService "git.loafle.net/overflow/overflow_probe_container/service" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" oopcns "git.loafle.net/overflow/overflow_probe_container_network/service" ) @@ -21,6 +23,8 @@ func New(pidPath string) server.Server { ) oopcns.InitService() + cdr.RegisterResource(oopc.PROBE_CONTAINER_CRAWLERS, crawler.GetCrawlers()) + rpcRegistry := crr.NewRPCRegistry() if services, err = cdr.GetInstancesByAnnotationName(ooca.ServiceTag); nil != err { @@ -40,7 +44,7 @@ func New(pidPath string) server.Server { rpcSH := oopcs.NewRPCServletHandler(rpcRegistry) socketHandler := newSocketHandler(rpcSH, probeService) - sh := newServerHandler(pidPath, socketHandler) + sh := newServerHandler(pidPath, socketHandler, services, oopcns.ServicesToStartAndStop) s := oopcs.New(sh) return s diff --git a/server/server_handlers.go b/server/server_handlers.go index c4a0acb..3bd2714 100644 --- a/server/server_handlers.go +++ b/server/server_handlers.go @@ -1,13 +1,15 @@ package server import ( + "reflect" + "git.loafle.net/commons_go/server" oopcs "git.loafle.net/overflow/overflow_probe_container/server" ) -func newServerHandler(pidPath string, socketHandler SocketHandler) ServerHandler { +func newServerHandler(pidPath string, socketHandler SocketHandler, services []interface{}, servicesToStartAndStop []reflect.Type) ServerHandler { sh := &ServerHandlers{} - sh.ServerHandler = oopcs.NewServerHandler(pidPath, "Network Containter", socketHandler) + sh.ServerHandler = oopcs.NewServerHandler(pidPath, "Network Containter", socketHandler, services, servicesToStartAndStop) return sh } @@ -34,6 +36,11 @@ func (sh *ServerHandlers) OnStop(serverCTX server.ServerContext) { sh.ServerHandler.OnStop(serverCTX) } +func (sh *ServerHandlers) Destroy(serverCTX server.ServerContext) { + + sh.ServerHandler.Destroy(serverCTX) +} + func (sh *ServerHandlers) Validate() { sh.ServerHandler.Validate() diff --git a/service/ConfigService.go b/service/ConfigService.go deleted file mode 100644 index d4d91dc..0000000 --- a/service/ConfigService.go +++ /dev/null @@ -1,57 +0,0 @@ -package service - -import ( - "reflect" - - cda "git.loafle.net/commons_go/di/annotation" - cdr "git.loafle.net/commons_go/di/registry" - - configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl" -) - -func init() { - cdr.RegisterType(reflect.TypeOf((*ConfigService)(nil))) -} - -type ConfigService struct { - cda.TypeAnnotation `annotation:"@overFlow:Service()"` -} - -func (s *ConfigService) Add(crawlerName string, config *configM.Config) error { - c := impl.GetCrawler(crawlerName) - return c.Add(config) -} - -func (s *ConfigService) Remove(crawlerName string, id string) error { - c := impl.GetCrawler(crawlerName) - return c.Remove(id) -} - -func (s *ConfigService) Init(configs []map[string]*configM.Config) error { - var err error - sensorIDs := make([]map[string]*configM.Config, 0) - ok := true -Loop: - for _, item := range configs { - for k, v := range item { - c := impl.GetCrawler(k) - if err = c.Init(v); nil != err { - ok = false - break Loop - } - sensorIDs = append(sensorIDs, item) - } - } - - if !ok { - for _, item := range sensorIDs { - for k, v := range item { - s.Remove(k, v.ID.String()) - } - } - return err - } - - return nil -} diff --git a/service/DataService.go b/service/DataService.go deleted file mode 100644 index fd5eaeb..0000000 --- a/service/DataService.go +++ /dev/null @@ -1,22 +0,0 @@ -package service - -import ( - "reflect" - - cda "git.loafle.net/commons_go/di/annotation" - cdr "git.loafle.net/commons_go/di/registry" - "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl" -) - -func init() { - cdr.RegisterType(reflect.TypeOf((*DataService)(nil))) -} - -type DataService struct { - cda.TypeAnnotation `annotation:"@overFlow:Service()"` -} - -func (s *DataService) Get(crawlerName string, sensorID string) (interface{}, error) { - c := impl.GetCrawler(crawlerName) - return c.Get(sensorID) -} diff --git a/service/StateService.go b/service/StateService.go deleted file mode 100644 index 12fd503..0000000 --- a/service/StateService.go +++ /dev/null @@ -1,20 +0,0 @@ -package service - -import ( - "reflect" - - cda "git.loafle.net/commons_go/di/annotation" - cdr "git.loafle.net/commons_go/di/registry" -) - -func init() { - cdr.RegisterType(reflect.TypeOf((*StateService)(nil))) -} - -type StateService struct { - cda.TypeAnnotation `annotation:"@overFlow:Service()"` -} - -func (s *StateService) State() (bool, error) { - return true, nil -} diff --git a/service/service.go b/service/service.go index 83c4f6f..58bd579 100644 --- a/service/service.go +++ b/service/service.go @@ -1,9 +1,20 @@ package service import ( + "reflect" + oopcs "git.loafle.net/overflow/overflow_probe_container/service" ) +var ( + ServicesToStartAndStop = []reflect.Type{ + reflect.TypeOf((*oopcs.SensorConfigService)(nil)), + reflect.TypeOf((*oopcs.CrawlerService)(nil)), + reflect.TypeOf((*oopcs.ProbeService)(nil)), + reflect.TypeOf((*oopcs.StateService)(nil)), + } +) + func InitService() { oopcs.InitService() }