fixed infra series model

This commit is contained in:
snoop 2017-08-21 13:59:36 +09:00
parent 4d00504612
commit be24ebf19f
17 changed files with 422 additions and 341 deletions

View File

@ -21,8 +21,8 @@ public interface InfraDAO extends JpaRepository<Infra, Long> {
List<Infra> findAllByProbe(List<Probe> probeList);
@Query("SELECT DISTINCT i.target FROM Infra i WHERE i.probe IN (:probeList)")
List<Target> findAllTargetByProbeList(@Param("probeList") List<Probe> probeList);
// @Query("SELECT DISTINCT i.target FROM Infra i WHERE i.probe IN (:probeList)")
// List<Target> findAllTargetByProbeList(@Param("probeList") List<Probe> probeList);
// List<Infra> findAllByProbe(List<Probe> probeList);
}

View File

@ -11,16 +11,24 @@ import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "INFRA", schema = "public", catalog = "postgres")
public class Infra {
@Entity(name = "INFRA")
//@Table(name = "INFRA", schema = "public", catalog = "postgres")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "INFRA_TYPE")
public abstract class Infra {
private long id;
private MetaInfraType infraType;
private long childId;
// private long childId;
private Date createDate;
private Probe probe;
private Target target;
// private InfraChild infraChild;
// private InfraHost infraHost;
// private InfraMachine infraMachine;
// private InfraOS infraOS;
/*
private long id;
private MetaInfraType infraType;
@ -29,6 +37,55 @@ public class Infra {
private Probe probeId;
private Target targetId;
*/
// @ManyToOne
// @JoinColumn(name = "CHILD_ID", nullable = false, insertable = false, updatable = false)
// public InfraHost getInfraChild() {
// return infraChild;
// }
//
// public void setInfraChild(InfraChild infraChild) {
// this.infraChild = infraChild;
// }
// @OneToOne
// @JoinColumn(name = "CHILD_ID")
// public InfraChild getInfraChild() {
// return infraChild;
// }
//
// public void setInfraChild(InfraChild infraChild) {
// this.infraChild = infraChild;
// }
// @ManyToOne
// @JoinColumn(name = "HOST_ID")
// public InfraHost getInfraHost() {
// return infraHost;
// }
//
// public void setInfraHost(InfraHost infraHost) {
// this.infraHost = infraHost;
// }
// @ManyToOne
// @JoinColumn(name = "MACHINE_ID")
// public InfraMachine getInfraMachine() {
// return infraMachine;
// }
//
// public void setInfraMachine(InfraMachine infraMachine) {
// this.infraMachine = infraMachine;
// }
//
// @ManyToOne
// @JoinColumn(name = "OS_ID")
// public InfraOS getInfraOS() {
// return infraOS;
// }
//
// public void setInfraOS(InfraOS infraOS) {
// this.infraOS = infraOS;
// }
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@ -50,15 +107,15 @@ public class Infra {
this.infraType = infraType;
}
@Basic
@Column(name = "CHILD_ID", nullable = false)
public long getChildId() {
return childId;
}
public void setChildId(long childId) {
this.childId = childId;
}
// @Basic
// @Column(name = "CHILD_ID", nullable = false)
// public long getChildId() {
// return childId;
// }
//
// public void setChildId(long childId) {
// this.childId = childId;
// }
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
@ -71,7 +128,7 @@ public class Infra {
}
@ManyToOne
@JoinColumn(name = "PROBE_ID", nullable = false)
@JoinColumn(name = "PROBE_ID", nullable = true)
public Probe getProbe() {
return probe;
}
@ -81,7 +138,7 @@ public class Infra {
}
@ManyToOne
@JoinColumn(name = "TARGET_ID", nullable = false)
@JoinColumn(name = "TARGET_ID", nullable = true)
public Target getTarget() {
return target;
}
@ -90,37 +147,37 @@ public class Infra {
this.target = target;
}
public static Infra CreateInfraByType(long id, Class c) {
Infra infra = new Infra();
infra.setChildId(id);
MetaInfraType infraType = new MetaInfraType();
if(c == InfraMachine.class) {
infraType.setId(1);
}
else if(c == InfraHost.class) {
infraType.setId(2);
}
else if(c == InfraOS.class) {
infraType.setId(3);
}
else if(c == InfraOSApplication.class) {
infraType.setId(4);
}
else if(c == InfraOSDaemon.class) {
infraType.setId(5);
}
else if(c == InfraOSPort.class) {
infraType.setId(6);
}
else if(c == InfraService.class) {
infraType.setId(7);
}
infra.setInfraType(infraType);
return infra;
}
// public static Infra CreateInfraByType(long id, Class c) {
//
// Infra infra = new Infra();
//// infra.setChildId(id);
//
// MetaInfraType infraType = new MetaInfraType();
// if(c == InfraMachine.class) {
// infraType.setId(1);
// }
// else if(c == InfraHost.class) {
// infraType.setId(2);
// }
// else if(c == InfraOS.class) {
// infraType.setId(3);
// }
// else if(c == InfraOSApplication.class) {
// infraType.setId(4);
// }
// else if(c == InfraOSDaemon.class) {
// infraType.setId(5);
// }
// else if(c == InfraOSPort.class) {
// infraType.setId(6);
// }
// else if(c == InfraService.class) {
// infraType.setId(7);
// }
//
// infra.setInfraType(infraType);
//
// return infra;
// }
}

View File

@ -6,27 +6,28 @@ import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "INFRA_HOST", schema = "public", catalog = "postgres")
public class InfraHost {
private long id;
@Entity(name = "INFRA_HOST")
//@Table(name = "INFRA_HOST", schema = "public", catalog = "postgres")
@DiscriminatorValue("INFRA_HOST")
public class InfraHost extends Infra {
// private long id;
private InfraOS os;
private long ip;
private long mac;
private Date createDate;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
@ManyToOne
@JoinColumn(name = "OS_ID", nullable = false)
@JoinColumn(name = "OS_ID", nullable = true)
public InfraOS getOs() {
return os;
}
@ -36,7 +37,7 @@ public class InfraHost {
}
@Basic
@Column(name = "IP", nullable = false)
@Column(name = "IP", nullable = true)
public long getIp() {
return ip;
}
@ -46,7 +47,7 @@ public class InfraHost {
}
@Basic
@Column(name = "MAC", nullable = false)
@Column(name = "MAC", nullable = true)
public long getMac() {
return mac;
}
@ -56,7 +57,7 @@ public class InfraHost {
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}

View File

@ -8,10 +8,11 @@ import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "INFRA_MACHINE", schema = "public", catalog = "postgres")
public class InfraMachine {
private long id;
@Entity(name = "INFRA_MACHINE")
//@Table(name = "INFRA_MACHINE", schema = "public", catalog = "postgres")
@DiscriminatorValue("INFRA_MACHINE")
public class InfraMachine extends Infra {
// private long id;
private String meta;
private Date createDate;
@ -22,15 +23,15 @@ public class InfraMachine {
private Date createDate;
*/
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
@Basic
@Column(name = "META", nullable = true, length = 255)

View File

@ -9,27 +9,28 @@ import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "INFRA_OS", schema = "public", catalog = "postgres")
public class InfraOS {
private long id;
@Entity(name = "INFRA_OS")
//@Table(name = "INFRA_OS", schema = "public", catalog = "postgres")
@DiscriminatorValue("INFRA_OS")
public class InfraOS extends Infra {
// private long id;
private InfraMachine machine;
private String meta;
private Date createDate;
private MetaInfraVendor vendor;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
@ManyToOne
@JoinColumn(name = "MACHINE_ID", nullable = false)
@JoinColumn(name = "MACHINE_ID", nullable = true)
public InfraMachine getMachine() {
return machine;
}
@ -49,7 +50,7 @@ public class InfraOS {
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
@ -59,7 +60,7 @@ public class InfraOS {
}
@ManyToOne
@JoinColumn(name = "VENDOR_ID", nullable = false)
@JoinColumn(name = "VENDOR_ID", nullable = true)
public MetaInfraVendor getVendor() {
return vendor;
}

View File

@ -6,26 +6,27 @@ import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "INFRA_OS_APPLICATION", schema = "public", catalog = "postgres")
public class InfraOSApplication {
private long id;
@Entity(name = "INFRA_OS_APPLICATION")
//@Table(name = "INFRA_OS_APPLICATION", schema = "public", catalog = "postgres")
@DiscriminatorValue("INFRA_OS_APPLICATION")
public class InfraOSApplication extends Infra {
// private long id;
private InfraOS os;
private String name;
private Date createDate;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
@ManyToOne
@JoinColumn(name = "OS_ID", nullable = false)
@JoinColumn(name = "OS_ID", nullable = true)
public InfraOS getOs() {
return os;
}
@ -45,7 +46,7 @@ public class InfraOSApplication {
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}

View File

@ -6,26 +6,27 @@ import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "INFRA_OS_DAEMON", schema = "public", catalog = "postgres")
public class InfraOSDaemon {
private long id;
@Entity(name = "INFRA_OS_DAEMON")
//@Table(name = "INFRA_OS_DAEMON", schema = "public", catalog = "postgres")
@DiscriminatorValue("INFRA_OS_DAEMON")
public class InfraOSDaemon extends Infra {
// private long id;
private InfraOS os;
private String name;
private Date createDate;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
@ManyToOne
@JoinColumn(name = "OS_ID", nullable = false)
@JoinColumn(name = "OS_ID", nullable = true)
public InfraOS getOs() {
return os;
}
@ -45,7 +46,7 @@ public class InfraOSDaemon {
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}

View File

@ -9,29 +9,30 @@ import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "INFRA_OS_PORT", schema = "public", catalog = "postgres")
public class InfraOSPort {
private long id;
@Entity(name = "INFRA_OS_PORT")
//@Table(name = "INFRA_OS_PORT", schema = "public", catalog = "postgres")
@DiscriminatorValue("INFRA_OS_PORT")
public class InfraOSPort extends Infra {
// private long id;
private InfraOS os;
private Date createDate;
private Integer port;
private String portType;
private MetaInfraVendor vendor;
private boolean tlsType;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
//
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
@ManyToOne
@JoinColumn(name = "OS_ID", nullable = false)
@JoinColumn(name = "OS_ID", nullable = true)
public InfraOS getOs() {
return this.os;
}
@ -41,7 +42,7 @@ public class InfraOSPort {
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
@ -61,7 +62,7 @@ public class InfraOSPort {
}
@Basic
@Column(name = "PORT_TYPE", nullable = false)
@Column(name = "PORT_TYPE", nullable = true)
public String getPortType() {
return portType;
}
@ -81,7 +82,7 @@ public class InfraOSPort {
}
@Basic
@Column(name = "TLS_TYPE", nullable = false)
@Column(name = "TLS_TYPE", nullable = true)
public boolean isTlsType() {
return tlsType;
}

View File

@ -9,10 +9,11 @@ import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "INFRA_SERVICE", schema = "public", catalog = "postgres")
public class InfraService {
private long id;
@Entity(name = "INFRA_SERVICE")
//@Table(name = "INFRA_SERVICE", schema = "public", catalog = "postgres")
@DiscriminatorValue("INFRA_SERVICE")
public class InfraService extends Infra{
// private long id;
private InfraHost host;
private String portType;
private Integer port;
@ -20,18 +21,18 @@ public class InfraService {
private Date createDate;
private boolean tlsType;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
// @Id
// @GeneratedValue(strategy= GenerationType.IDENTITY)
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
@ManyToOne
@JoinColumn(name = "HOST_ID", nullable = false)
@JoinColumn(name = "HOST_ID", nullable = true)
public InfraHost getHost() {
return host;
}
@ -41,7 +42,7 @@ public class InfraService {
}
@Basic
@Column(name = "PORT_TYPE", nullable = false)
@Column(name = "PORT_TYPE", nullable = true)
public String getPortType() {
return portType;
}
@ -61,7 +62,7 @@ public class InfraService {
}
@ManyToOne
@JoinColumn(name = "VENDOR_ID", nullable = false)
@JoinColumn(name = "VENDOR_ID", nullable = true)
public MetaInfraVendor getVendor() {
return vendor;
}
@ -71,7 +72,7 @@ public class InfraService {
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() {
return createDate;
}
@ -81,7 +82,7 @@ public class InfraService {
}
@Basic
@Column(name = "TLS_TYPE", nullable = false)
@Column(name = "TLS_TYPE", nullable = true)
public boolean isTlsType() {
return tlsType;
}

View File

@ -48,6 +48,7 @@ public class InfraService {
}
public List<Target> readAllTargetByProbeList(List<Probe> probeList) {
return this.infraDAO.findAllTargetByProbeList(probeList);
// return this.infraDAO.findAllTargetByProbeList(probeList);
return null;
}
}

View File

@ -42,101 +42,101 @@ public class TargetDiscoveryService {
@Autowired
private InfraServiceDAO infraServiceDAO;
@Transactional
public void saveAllTarget(List<Host> hosts, Probe probe) {
for(Host host : hosts) {
InfraMachine infraMachine = new InfraMachine();
// infraMachine.setProbe(probe);
this.infraMachineDAO.save(infraMachine);
Infra infraByMachine = Infra.CreateInfraByType(infraMachine.getId(), InfraMachine.class);
this.infraDAO.save(infraByMachine);
InfraOS infraOS = new InfraOS();
infraOS.setMachine(infraMachine);
infraOS.setVendor(MetaInfraVendor.CreateInfraVendorByOS(host.getOs()));
this.infraOSDAO.save(infraOS);
Infra infraByOS = Infra.CreateInfraByType(infraOS.getId(), InfraOS.class);
this.infraDAO.save(infraByOS);
InfraHost infraHost = new InfraHost();
infraHost.setIp(host.getIp());
infraHost.setMac(host.getMac());
infraHost.setOs(infraOS);
this.infraHostDAO.save(infraHost);
Infra infraByHost = Infra.CreateInfraByType(infraHost.getId(), InfraHost.class);
this.infraDAO.save(infraByHost);
if(host.isTarget()) {
Target targetHost = new Target();
// targetHost.setInfra(infraByHost);
// targetHost.setProbe(probe);
this.targetDAO.save(targetHost);
}
if(host.getPorts() == null) {
continue;
}
for(Port port : host.getPorts()) {
InfraOSPort infraOSPort = new InfraOSPort();
infraOSPort.setOs(infraOS);
infraOSPort.setPort(port.getPortNumber());
infraOSPort.setPortType("UDP");
if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
infraOSPort.setPortType("TCP");
}
if (port.getPortType() == PortType.TLS) {
infraOSPort.setTlsType(true);
}
infraOSPort.setVendor(MetaInfraVendor.CreateInfraVendorByPort(port.getPortNumber()));
this.infraOSPortDAO.save(infraOSPort);
Infra infraByPort = Infra.CreateInfraByType(infraOSPort.getId(), InfraOSPort.class);
this.infraDAO.save(infraByPort);
if(port.getServices() == null) {
continue;
}
for(com.loafle.overflow.module.discovery.model.Service service : port.getServices()) {
InfraService infraService = new InfraService();
infraService.setHost(infraHost);
infraService.setPort(port.getPortNumber());
infraService.setPortType("UDP");
if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
infraService.setPortType("TCP");
}
if (port.getPortType() == PortType.TLS) {
infraService.setTlsType(true);
}
infraService.setVendor(MetaInfraVendor.CreateInfraVendorByService(service.getServiceName()));
this.infraServiceDAO.save(infraService);
Infra infraByService = Infra.CreateInfraByType(infraService.getId(), InfraService.class);
this.infraDAO.save(infraByService);
if(service.isTarget()) {
Target targetService = new Target();
// targetService.setInfra(infraByService);
// targetService.setProbe(probe);
this.targetDAO.save(targetService);
}
}
}
}
}
// @Transactional
// public void saveAllTarget(List<Host> hosts, Probe probe) {
//
// for(Host host : hosts) {
//
// InfraMachine infraMachine = new InfraMachine();
//// infraMachine.setProbe(probe);
// this.infraMachineDAO.save(infraMachine);
//
// Infra infraByMachine = Infra.CreateInfraByType(infraMachine.getId(), InfraMachine.class);
// this.infraDAO.save(infraByMachine);
//
//
// InfraOS infraOS = new InfraOS();
//// infraOS.setMachine(infraMachine);
//// infraOS.setVendor(MetaInfraVendor.CreateInfraVendorByOS(host.getOs()));
// this.infraOSDAO.save(infraOS);
//
// Infra infraByOS = Infra.CreateInfraByType(infraOS.getId(), InfraOS.class);
// this.infraDAO.save(infraByOS);
//
//
// InfraHost infraHost = new InfraHost();
// infraHost.setIp(host.getIp());
// infraHost.setMac(host.getMac());
//// infraHost.setOs(infraOS);
// this.infraHostDAO.save(infraHost);
//
// Infra infraByHost = Infra.CreateInfraByType(infraHost.getId(), InfraHost.class);
// this.infraDAO.save(infraByHost);
//
// if(host.isTarget()) {
// Target targetHost = new Target();
//// targetHost.setInfra(infraByHost);
//// targetHost.setProbe(probe);
// this.targetDAO.save(targetHost);
// }
//
// if(host.getPorts() == null) {
// continue;
// }
//
// for(Port port : host.getPorts()) {
//
// InfraOSPort infraOSPort = new InfraOSPort();
// infraOSPort.setOs(infraOS);
// infraOSPort.setPort(port.getPortNumber());
// infraOSPort.setPortType("UDP");
// if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
// infraOSPort.setPortType("TCP");
// }
// if (port.getPortType() == PortType.TLS) {
// infraOSPort.setTlsType(true);
// }
// infraOSPort.setVendor(MetaInfraVendor.CreateInfraVendorByPort(port.getPortNumber()));
// this.infraOSPortDAO.save(infraOSPort);
//
// Infra infraByPort = Infra.CreateInfraByType(infraOSPort.getId(), InfraOSPort.class);
// this.infraDAO.save(infraByPort);
//
// if(port.getServices() == null) {
// continue;
// }
//
// for(com.loafle.overflow.module.discovery.model.Service service : port.getServices()) {
//
// InfraService infraService = new InfraService();
// infraService.setHost(infraHost);
// infraService.setPort(port.getPortNumber());
// infraService.setPortType("UDP");
// if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
// infraService.setPortType("TCP");
// }
// if (port.getPortType() == PortType.TLS) {
// infraService.setTlsType(true);
// }
// infraService.setVendor(MetaInfraVendor.CreateInfraVendorByService(service.getServiceName()));
// this.infraServiceDAO.save(infraService);
//
// Infra infraByService = Infra.CreateInfraByType(infraService.getId(), InfraService.class);
// this.infraDAO.save(infraByService);
//
// if(service.isTarget()) {
// Target targetService = new Target();
//// targetService.setInfra(infraByService);
//// targetService.setProbe(probe);
// this.targetDAO.save(targetService);
// }
//
// }
//
// }
//
//
// }
//
// }
}

View File

@ -397,54 +397,3 @@ INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES (
INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES (
'52abd6fd57e511e7ac52080027658d13','2017-06-26 13:02:28.347',1);
INSERT INTO public.noauth_probe (api_key,create_date,host_name,ip_address,mac_address,temp_probe_key,domain_id,probe_id,status) VALUES (
'52abd6fd57e511e7ac52080027658d13','2017-06-26 12:43:46.877','snoop',3232235980,8796753988883,'1cf2555c57d511e79714080027658d13',1,NULL,3);
INSERT INTO public.noauth_probe (api_key,create_date,host_name,ip_address,mac_address,temp_probe_key,domain_id,probe_id,status) VALUES (
'52abd6fd57e511e7ac52080027658d14','2017-08-11 12:43:46.877','geek',3232235980,8796753988883,'1cf2555c57d511e79714080027658d14',1,NULL,3);
INSERT INTO public.noauth_probe (api_key,create_date,host_name,ip_address,mac_address,temp_probe_key,domain_id,probe_id,status) VALUES (
'52abd6fd57e511e7ac52080027658d15','2017-08-11 12:43:46.877','insanity',3232235980,8796753988883,'1cf2555c57d511e79714080027658d15',1,NULL,3);
INSERT INTO public.infra_machine (create_date,meta) VALUES (
'2017-07-27 19:54:26.677','');
INSERT INTO public.infra_os (create_date,meta,machine_id,vendor_id) VALUES (
'2017-07-27 19:55:47.326','',1,26);
INSERT INTO public.infra_host (create_date,ip,mac,os_id) VALUES (
'2017-07-27 19:57:10.607',3232235980,8796753988883,1);
INSERT INTO public.infra_service (create_date,port,port_type,tls_type,host_id,vendor_id) VALUES (
'2017-07-28 16:36:33.906',80,'TCP',false,1,45);
INSERT INTO public.infra_os_application (create_date,name,os_id) VALUES (
'2017-07-28 16:54:11.646','Apache',1);
INSERT INTO public.infra_os_daemon (create_date,name,os_id) VALUES (
'2017-07-28 17:00:35.186','Apache',1);
INSERT INTO public.probe (authorize_date,cidr,create_date,description,display_name,encryption_key,probe_key,sensor_count,target_count,authorize_member_id,domain_id,host_id,status) VALUES (
'2017-07-27 20:01:28.513','192.168.1.0/24','2017-07-27 20:01:28.513','snoop probe','test probe','8c51fa9c5bcc11e7980a080027658d13','899fdd145bcc11e7b611080027658d13',0,0,1,1,1,1);
INSERT INTO public.target (create_date,description,display_name) VALUES (
'2017-07-27 20:18:09.555','i am target','ghost target');
INSERT INTO public.infra (child_id,create_date,probe_id,target_id,type_id) VALUES (
1,'2017-07-28 11:08:50.803',1,1,1);
INSERT INTO public.infra (child_id,create_date,probe_id,target_id,type_id) VALUES (
1,'2017-07-28 11:08:50.832',1,1,3);
INSERT INTO public.infra (child_id,create_date,probe_id,target_id,type_id) VALUES (
1,'2017-07-28 11:08:50.841',1,1,2);
INSERT INTO public.infra (child_id,create_date,type_id,probe_id,target_id) VALUES (
1,'2017-07-28 16:52:30.391',7,1,1);
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES (
NULL,'2017-06-26 20:19:07.009','My sensor',1,1,1);
INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id) VALUES (
NULL,'2017-06-26 20:19:07.074','My sensor',1,1,1);
INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES (
'2017-06-26 20:21:16.626',1,1);
INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES (
'2017-06-26 20:21:50.988',2,2);

View File

@ -36,7 +36,7 @@ public class InfraHostServiceTest {
InfraOS infraOS = new InfraOS();
infraOS.setId(1);
infraHost.setOs(infraOS);
// infraHost.setOs(infraOS);
this.infraHostService.regist(infraHost);

View File

@ -2,6 +2,8 @@ package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.infra.model.InfraMachine;
import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.module.meta.model.MetaInfraVendor;
import com.loafle.overflow.spring.AppConfigTest;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert;
@ -23,13 +25,18 @@ public class InfraMachineServiceTest {
@Autowired
private InfraMachineService infraMachineService;
@Ignore
// @Ignore
@Test
public void regist() throws Exception {
InfraMachine infraMachine = new InfraMachine();
infraMachine.setMeta("");
infraMachine.setMeta("i am a infra machine");
MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(1);
infraMachine.setInfraType(metaInfraType);
this.infraMachineService.regist(infraMachine);
@ -40,6 +47,8 @@ public class InfraMachineServiceTest {
@Test
public void read() throws Exception {
regist();
InfraMachine infraMachine = this.infraMachineService.read(1);
ObjectMapper objectMapper = new ObjectMapper();

View File

@ -2,6 +2,7 @@ package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.infra.model.InfraMachine;
import com.loafle.overflow.module.infra.model.InfraOS;
import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.module.meta.model.MetaInfraVendor;
import com.loafle.overflow.spring.AppConfigTest;
import org.codehaus.jackson.map.ObjectMapper;
@ -23,8 +24,8 @@ public class InfraOSServiceTest {
private InfraOSService infraOSService;
@Test
@Ignore
public void regist() throws Exception {
// @Ignore
public void registOS() throws Exception {
InfraOS infraOS = new InfraOS();
@ -37,8 +38,14 @@ public class InfraOSServiceTest {
InfraMachine infraMachine = new InfraMachine();
infraMachine.setId(1);
MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(3);
infraOS.setInfraType(metaInfraType);
infraOS.setMachine(infraMachine);
this.infraOSService.regist(infraOS);
}

View File

@ -2,6 +2,7 @@ package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.domain.model.Domain;
import com.loafle.overflow.module.infra.model.Infra;
import com.loafle.overflow.module.infra.model.InfraMachine;
import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.module.probe.model.Probe;
import com.loafle.overflow.module.probe.service.ProbeService;
@ -31,52 +32,102 @@ public class InfraServiceTest {
@Autowired
private ProbeService probeService;
@Ignore
@Test
public void regist() throws Exception {
@Autowired
private InfraMachineService infraMachineService;
long id =registInfra(7,1);
Assert.assertNotEquals(id, 0);
// id =registInfra(3,1);
// public void regist() throws Exception {
//
// long id =registInfra(7,1);
// Assert.assertNotEquals(id, 0);
//
// id =registInfra(2,1);
// Assert.assertNotEquals(id, 0);
//// id =registInfra(3,1);
//// Assert.assertNotEquals(id, 0);
////
//// id =registInfra(2,1);
//// Assert.assertNotEquals(id, 0);
//
//
//
// }
@Test
public void tttt() {
}
// @Ignore
public long registInfra(int type, int childId) {
@Test
public void registInfraMachine() {
InfraMachine infraMachine = new InfraMachine();
infraMachine.setMeta("i am a inframachine");
// Assert.assertNotEquals(infraMachine.getId(), 0);
// Probe probe = new Probe();
// probe.setId(1);
//
// Target target = new Target();
// target.setId(1);
// Infra infra = new Infra();
// infra.setTarget(target);
MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(type);
metaInfraType.setId(1);
Infra infra = new Infra();
infra.setInfraType(metaInfraType);
infra.setChildId(childId);
// infraMachine.setInfraType(metaInfraType);
// infra.setProbe(probe);
// infra.setInfraChild(infraMachine);
Probe probe = new Probe();
probe.setId(1);
this.infraMachineService.regist(infraMachine);
Target target = new Target();
target.setId(1);
// this.infraService.regist(infra);
infra.setProbe(probe);
infra.setTarget(target);
// Assert.assertNotEquals(infra.getId(), 0);
this.infraService.regist(infra);
return infra.getId();
}
@Test
public void registInfraOS() {
registInfraMachine();
}
//// @Ignore
// public long registInfra(int type, int childId) {
// MetaInfraType metaInfraType = new MetaInfraType();
// metaInfraType.setId(type);
//
// Infra infra = new Infra();
// infra.setInfraType(metaInfraType);
//// infra.setChildId(childId);
//
//
//
// Probe probe = new Probe();
// probe.setId(1);
//
// Target target = new Target();
// target.setId(1);
//
// infra.setProbe(probe);
// infra.setTarget(target);
//
// this.infraService.regist(infra);
//
// return infra.getId();
// }
@Test
public void read() throws Exception {
Infra infra = this.infraService.read(3);
// registInfraMachine();
Infra infra = this.infraService.read(1);
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(infra);

View File

@ -51,7 +51,7 @@ public class TargetDiscoveryServiceTest {
Probe probe = new Probe();
probe.setId(1);
this.targetDiscoveryService.saveAllTarget(hosts, probe);
// this.targetDiscoveryService.saveAllTarget(hosts, probe);
}
private String readFileAsString(String filePath) throws IOException {