This commit is contained in:
insanity 2018-07-02 20:53:06 +09:00
parent 508fac7b8a
commit 9ad03d5303
25 changed files with 64 additions and 71 deletions

4
Gopkg.lock generated
View File

@ -47,7 +47,7 @@
"socket/web", "socket/web",
"socket/web/client" "socket/web/client"
] ]
revision = "20a63b3de6efdc0942bfb4be21ddc64e2b76f59d" revision = "cbe8e30db48a21b33650c5ed7e7d8bbf4784c9d4"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -111,7 +111,7 @@
"model/sensorconfig", "model/sensorconfig",
"service/probe" "service/probe"
] ]
revision = "7e2ff26648aefbafaee2ca28c1a958332ae4c6f9" revision = "54725b74e13a501d7a13a76a82c294769729748d"
[[projects]] [[projects]]
branch = "master" branch = "master"

View File

@ -5,47 +5,44 @@ import (
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"net" "net"
"time"
cnsm "git.loafle.net/commons/service_matcher-go" cnsm "git.loafle.net/commons/service_matcher-go"
cuej "git.loafle.net/commons/util-go/encoding/json" cuej "git.loafle.net/commons/util-go/encoding/json"
ocmm "git.loafle.net/overflow/commons-go/model/meta"
ocmsc "git.loafle.net/overflow/commons-go/model/sensorconfig" ocmsc "git.loafle.net/overflow/commons-go/model/sensorconfig"
"git.loafle.net/overflow/crawler-go" "git.loafle.net/overflow/crawler-go"
) )
type SocketHeahthCrawler struct { type SocketHealthCrawler struct {
crawler.Crawler crawler.Crawler
m cnsm.Matcher m cnsm.Matcher
} }
func (s *SocketHeahthCrawler) SetMatcher(m cnsm.Matcher) { func (s *SocketHealthCrawler) SetMatcher(m cnsm.Matcher) {
s.m = m s.m = m
} }
func (s *SocketHeahthCrawler) getConnection(config *ocmsc.SensorConfig) (net.Conn, error) { func (s *SocketHealthCrawler) getConnection(config *ocmsc.SensorConfig) (net.Conn, error) {
connection := config.Target.Connection connection := config.Connection
metaIPTypeKey := connection.MetaIPTypeKey
metaIPType := connection.MetaIPType
ip := connection.IP ip := connection.IP
port := connection.Port port := connection.Port
metaPortType := connection.MetaPortType metaPortTypeKey := connection.MetaPortTypeKey
metaCryptoType := connection.MetaCryptoType metaCryptoTypeKey := connection.MetaCryptoTypeKey
addr := fmt.Sprintf("%s:%s", ip, port) addr := fmt.Sprintf("%s:%s", ip, port)
network := "" network := ""
switch ocmm.ToMetaIPTypeEnum(metaIPType) { switch metaIPTypeKey {
case ocmm.MetaIPTypeEnumV6: case "V6":
switch ocmm.ToMetaPortTypeEnum(metaPortType) { switch metaPortTypeKey {
case ocmm.MetaPortTypeEnumUDP: case "UDP":
network = "udp6" network = "udp6"
default: default:
network = "tcp6" network = "tcp6"
} }
default: default:
switch ocmm.ToMetaPortTypeEnum(metaPortType) { switch metaPortTypeKey {
case ocmm.MetaPortTypeEnumUDP: case "UDP":
network = "udp" network = "udp"
default: default:
network = "tcp" network = "tcp"
@ -57,7 +54,7 @@ func (s *SocketHeahthCrawler) getConnection(config *ocmsc.SensorConfig) (net.Con
return nil, err return nil, err
} }
if ocmm.ToMetaCryptoTypeEnum(metaCryptoType) == ocmm.MetaCryptoTypeEnumTLS { if metaCryptoTypeKey == "TLS" {
cfg := &tls.Config{ cfg := &tls.Config{
InsecureSkipVerify: true, InsecureSkipVerify: true,
ServerName: ip, ServerName: ip,
@ -74,11 +71,9 @@ func (s *SocketHeahthCrawler) getConnection(config *ocmsc.SensorConfig) (net.Con
return conn, nil return conn, nil
} }
func (s *SocketHeahthCrawler) CheckHeahth(config *ocmsc.SensorConfig) (result map[string]string, err error) { func (s *SocketHealthCrawler) CheckHealth(config *ocmsc.SensorConfig) (result map[string]string, err error) {
result = make(map[string]string, 0) result = make(map[string]string, 0)
result["StartTime"] = time.Now().String()
conn, cErr := s.getConnection(config) conn, cErr := s.getConnection(config)
if cErr != nil { if cErr != nil {
result["Error"] = cErr.Error() result["Error"] = cErr.Error()
@ -87,7 +82,7 @@ func (s *SocketHeahthCrawler) CheckHeahth(config *ocmsc.SensorConfig) (result ma
} }
defer conn.Close() defer conn.Close()
connection := config.Target.Connection connection := config.Connection
port, _ := cuej.NumberToInt(connection.Port) port, _ := cuej.NumberToInt(connection.Port)
info := cnsm.NewMatchInfo(connection.IP, port) info := cnsm.NewMatchInfo(connection.IP, port)
@ -143,8 +138,6 @@ func (s *SocketHeahthCrawler) CheckHeahth(config *ocmsc.SensorConfig) (result ma
} }
} }
result["EndTime"] = time.Now().String()
return return
} }

View File

@ -8,7 +8,7 @@ import (
) )
type ActiveDirectoryHealthCrawler struct { type ActiveDirectoryHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *ActiveDirectoryHealthCrawler) Key() string { func (c *ActiveDirectoryHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *ActiveDirectoryHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *ActiveDirectoryHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *ActiveDirectoryHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type CassandraHealthCrawler struct { type CassandraHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *CassandraHealthCrawler) Key() string { func (c *CassandraHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *CassandraHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *CassandraHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *CassandraHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type DNSHealthCrawler struct { type DNSHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *DNSHealthCrawler) Key() string { func (c *DNSHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *DNSHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *DNSHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *DNSHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type FTPHealthCrawler struct { type FTPHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *FTPHealthCrawler) Key() string { func (c *FTPHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *FTPHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *FTPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *FTPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type HTTPHealthCrawler struct { type HTTPHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *HTTPHealthCrawler) Key() string { func (c *HTTPHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *HTTPHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *HTTPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *HTTPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type IMAPHealthCrawler struct { type IMAPHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *IMAPHealthCrawler) Key() string { func (c *IMAPHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *IMAPHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *IMAPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *IMAPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type LDAPHealthCrawler struct { type LDAPHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *LDAPHealthCrawler) Key() string { func (c *LDAPHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *LDAPHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *LDAPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *LDAPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type MongoDBHealthCrawler struct { type MongoDBHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *MongoDBHealthCrawler) Key() string { func (c *MongoDBHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *MongoDBHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *MongoDBHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *MongoDBHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type MySQLHealthCrawler struct { type MySQLHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *MySQLHealthCrawler) Key() string { func (c *MySQLHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *MySQLHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *MySQLHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *MySQLHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type NetBIOSHealthCrawler struct { type NetBIOSHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *NetBIOSHealthCrawler) Key() string { func (c *NetBIOSHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *NetBIOSHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *NetBIOSHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *NetBIOSHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type OracleHealthCrawler struct { type OracleHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *OracleHealthCrawler) Key() string { func (c *OracleHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *OracleHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *OracleHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *OracleHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type POPHealthCrawler struct { type POPHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *POPHealthCrawler) Key() string { func (c *POPHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *POPHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *POPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *POPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type PostgreSQLHealthCrawler struct { type PostgreSQLHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *PostgreSQLHealthCrawler) Key() string { func (c *PostgreSQLHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *PostgreSQLHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *PostgreSQLHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *PostgreSQLHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type RedisHealthCrawler struct { type RedisHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *RedisHealthCrawler) Key() string { func (c *RedisHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *RedisHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *RedisHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *RedisHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type RMIHealthCrawler struct { type RMIHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *RMIHealthCrawler) Key() string { func (c *RMIHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *RMIHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *RMIHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *RMIHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type SMBHealthCrawler struct { type SMBHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *SMBHealthCrawler) Key() string { func (c *SMBHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *SMBHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *SMBHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *SMBHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type SMTPHealthCrawler struct { type SMTPHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *SMTPHealthCrawler) Key() string { func (c *SMTPHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *SMTPHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *SMTPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *SMTPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type SNMPHealthCrawler struct { type SNMPHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *SNMPHealthCrawler) Key() string { func (c *SNMPHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *SNMPHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *SNMPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *SNMPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type SNMPHealthCrawler struct { type SNMPHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *SNMPHealthCrawler) Key() string { func (c *SNMPHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *SNMPHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *SNMPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *SNMPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type SQLServerHealthCrawler struct { type SQLServerHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *SQLServerHealthCrawler) Key() string { func (c *SQLServerHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *SQLServerHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *SQLServerHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *SQLServerHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type SSHHealthCrawler struct { type SSHHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *SSHHealthCrawler) Key() string { func (c *SSHHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *SSHHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *SSHHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *SSHHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type TelnetHealthCrawler struct { type TelnetHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *TelnetHealthCrawler) Key() string { func (c *TelnetHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *TelnetHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *TelnetHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *TelnetHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,7 +8,7 @@ import (
) )
type WMIHealthCrawler struct { type WMIHealthCrawler struct {
health.SocketHeahthCrawler health.SocketHealthCrawler
} }
func (c *WMIHealthCrawler) Key() string { func (c *WMIHealthCrawler) Key() string {
@ -24,7 +24,7 @@ func (c *WMIHealthCrawler) Auth(auth map[string]interface{}) error {
} }
func (c *WMIHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) { func (c *WMIHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
rss, err := c.CheckHeahth(config) rss, err := c.CheckHealth(config)
if err != nil { if err != nil {
return nil, err return nil, err
} }