fixed discovery result save
This commit is contained in:
parent
0c5f529bf0
commit
a8ad0f1187
|
@ -1,6 +1,7 @@
|
|||
package com.loafle.overflow.module.discovery.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -19,6 +20,9 @@ public class Host {
|
|||
|
||||
private Map<String, Port> ports;
|
||||
|
||||
private List<Port> portList;
|
||||
|
||||
|
||||
public Host(){}
|
||||
|
||||
public long getId() {
|
||||
|
@ -84,4 +88,12 @@ public class Host {
|
|||
public void setPorts(Map<String, Port> ports) {
|
||||
this.ports = ports;
|
||||
}
|
||||
|
||||
public List<Port> getPortList() {
|
||||
return portList;
|
||||
}
|
||||
|
||||
public void setPortList(List<Port> portList) {
|
||||
this.portList = portList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ package com.loafle.overflow.module.discovery.model;
|
|||
import com.loafle.overflow.module.discovery.type.PortType;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -26,6 +27,8 @@ public class Port {
|
|||
|
||||
private Map<String, Service> services;
|
||||
|
||||
private List<Service> serviceList;
|
||||
|
||||
public Port() {}
|
||||
|
||||
public long getId() {
|
||||
|
@ -75,4 +78,12 @@ public class Port {
|
|||
public void setServices(Map<String, Service> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
public List<Service> getServiceList() {
|
||||
return serviceList;
|
||||
}
|
||||
|
||||
public void setServiceList(List<Service> serviceList) {
|
||||
this.serviceList = serviceList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,22 +85,23 @@ public class MetaInfraVendor {
|
|||
MetaInfraVendor vendor = new MetaInfraVendor();
|
||||
|
||||
if(serviceName.equals("mysql")) {
|
||||
vendor.setId(39);
|
||||
vendor.setId(11);
|
||||
}
|
||||
else if(serviceName.equals("portgresql")) {
|
||||
vendor.setId(39);
|
||||
vendor.setId(15);
|
||||
}
|
||||
else if(serviceName.equals("wmi")) {
|
||||
vendor.setId(39);
|
||||
vendor.setId(23);
|
||||
}
|
||||
else if(serviceName.equals("snmpv2")) {
|
||||
vendor.setId(39);
|
||||
else if(serviceName.equals("snmp")) {
|
||||
vendor.setId(20);
|
||||
}
|
||||
else {
|
||||
vendor.setId(43); // unknown
|
||||
vendor.setId(24); // unknown
|
||||
}
|
||||
|
||||
|
||||
|
||||
return vendor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,16 +74,17 @@ public class TargetDiscoveryService {
|
|||
portType = "TCP";
|
||||
}
|
||||
|
||||
for(String key : port.getServices().keySet()) {
|
||||
// for(String key : port.getServices().keySet()) {
|
||||
for(com.loafle.overflow.module.discovery.model.Service service : port.getServiceList()) {
|
||||
|
||||
com.loafle.overflow.module.discovery.model.Service service = port.getServices().get(key);
|
||||
// com.loafle.overflow.module.discovery.model.Service service = port.getServices().get(key);
|
||||
|
||||
InfraService dbInfraService = this.infraServiceService.readByService(infraHost.getId(), port.getPortNumber(), portType);
|
||||
|
||||
if(dbInfraService != null) {
|
||||
if(service.isTarget() && dbInfraService.getTarget() == null) {
|
||||
Target targetService = new Target();
|
||||
targetService.setDisplayName(service.getServiceName() + "-Service");
|
||||
targetService.setDisplayName(service.getServiceName());
|
||||
this.targetService.regist(targetService);
|
||||
dbInfraService.setTarget(targetService);
|
||||
this.infraServiceService.regist(dbInfraService);
|
||||
|
@ -105,7 +106,7 @@ public class TargetDiscoveryService {
|
|||
|
||||
if(service.isTarget()) {
|
||||
Target targetService = new Target();
|
||||
targetService.setDisplayName(service.getServiceName() + "-Service");
|
||||
targetService.setDisplayName(service.getServiceName());
|
||||
this.targetService.regist(targetService);
|
||||
infraService.setTarget(targetService);
|
||||
}
|
||||
|
@ -129,9 +130,9 @@ public class TargetDiscoveryService {
|
|||
|
||||
InfraOS infraOS = infraHost.getOs();
|
||||
|
||||
for( String key: host.getPorts().keySet()) {
|
||||
|
||||
Port port = host.getPorts().get(key);
|
||||
// for( String key: host.getPorts().keySet()) {
|
||||
for( Port port: host.getPortList()) {
|
||||
// Port port = host.getPorts().get(key);
|
||||
|
||||
if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
|
||||
portType = "TCP";
|
||||
|
@ -225,5 +226,4 @@ public class TargetDiscoveryService {
|
|||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
1
src/test/resources/180403-td.json
Normal file
1
src/test/resources/180403-td.json
Normal file
|
@ -0,0 +1 @@
|
|||
[{"id":0,"ip":"192.168.1.254","mac":"64:e5:99:63:e7:80","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":{},"portList":[{"id":0,"portType":"UDP","portNumber":53,"discoveredDate":-62135596800000,"host":null,"services":{},"serviceList":[{"id":0,"cryptoType":null,"serviceName":"DNS","discoveredDate":-62135596800000,"port":null,"target":false}]}]},{"id":0,"ip":"192.168.1.99","mac":"00:25:b3:fa:ca:9b","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":{},"portList":[{"id":0,"portType":"UDP","portNumber":161,"discoveredDate":-62135596800000,"host":null,"services":{},"serviceList":[{"id":0,"cryptoType":null,"serviceName":"SNMP_V2","discoveredDate":-62135596800000,"port":null,"target":false}]},{"id":0,"portType":"TCP","portNumber":7,"discoveredDate":-62135596800000,"host":null,"services":null}]},{"id":0,"ip":"192.168.1.206","mac":"30:9c:23:15:a3:09","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":null},{"id":0,"ip":"192.168.1.50","mac":"6c:f0:49:7a:60:68","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":{},"portList":[{"id":0,"portType":"TCP","portNumber":22,"discoveredDate":-62135596800000,"host":null,"services":{},"serviceList":[{"id":0,"cryptoType":"TCP","serviceName":"SSH","discoveredDate":-62135596800000,"port":null,"target":false}]}]},{"id":0,"ip":"192.168.1.15","mac":"00:19:b9:35:8e:a6","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":{},"portList":[{"id":0,"portType":"TCP","portNumber":22,"discoveredDate":-62135596800000,"host":null,"services":null},{"id":0,"portType":"TCP","portNumber":25,"discoveredDate":-62135596800000,"host":null,"services":null}]},{"id":0,"ip":"192.168.1.100","mac":"00:17:08:8d:cf:f7","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":{},"portList":[{"id":0,"portType":"UDP","portNumber":161,"discoveredDate":-62135596800000,"host":null,"services":{},"serviceList":[{"id":0,"cryptoType":null,"serviceName":"SNMP_V2","discoveredDate":-62135596800000,"port":null,"target":false}]},{"id":0,"portType":"TCP","portNumber":23,"discoveredDate":-62135596800000,"host":null,"services":null},{"id":0,"portType":"TCP","portNumber":21,"discoveredDate":-62135596800000,"host":null,"services":null}]},{"id":0,"ip":"192.168.1.16","mac":"00:19:b9:19:7e:c7","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":{},"portList":[{"id":0,"portType":"TCP","portNumber":22,"discoveredDate":-62135596800000,"host":null,"services":null}]},{"id":0,"ip":"192.168.1.106","mac":"44:8a:5b:f1:3a:7d","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":{},"portList":[{"id":0,"portType":"UDP","portNumber":161,"discoveredDate":-62135596800000,"host":null,"services":{},"serviceList":[{"id":0,"cryptoType":null,"serviceName":"SNMP_V2","discoveredDate":-62135596800000,"port":null,"target":false}]},{"id":0,"portType":"TCP","portNumber":21,"discoveredDate":-62135596800000,"host":null,"services":null}]},{"id":0,"ip":"192.168.1.101","mac":"44:8a:5b:f1:f1:f3","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":null},{"id":0,"ip":"192.168.1.102","mac":"44:8a:5b:f1:f2:d3","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":null},{"id":0,"ip":"192.168.1.205","mac":"40:98:ad:7b:d0:43","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":null},{"id":0,"ip":"192.168.1.103","mac":"44:8a:5b:44:8c:e8","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":{},"portList":[{"id":0,"portType":"TCP","portNumber":21,"discoveredDate":-62135596800000,"host":null,"services":null}]},{"id":0,"ip":"192.168.1.10","mac":"d0:50:99:97:5d:99","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":{},"portList":[{"id":0,"portType":"TCP","portNumber":22,"discoveredDate":-62135596800000,"host":null,"services":null}]},{"id":0,"ip":"192.168.1.203","mac":"a8:e5:39:5b:c9:62","os":null,"discoveredDate":-62135596800000,"target":false,"zone":null,"ports":null}]
|
Loading…
Reference in New Issue
Block a user