private Integer syscall;
@Column(name = "syscallargs")
- private Integer syscallargs;
+ private String syscallargs;
@Column(name = "syscallexitcode")
private Integer syscallexitcode;
this.syscall = syscall;
}
- public Integer getSyscallargs() {
+ public String getSyscallargs() {
return syscallargs;
}
- public ReportSyscall syscallargs(Integer syscallargs) {
+ public ReportSyscall syscallargs(String syscallargs) {
this.syscallargs = syscallargs;
return this;
}
- public void setSyscallargs(Integer syscallargs) {
+ public void setSyscallargs(String syscallargs) {
this.syscallargs = syscallargs;
}
import javax.persistence.*;
-
import java.io.Serializable;
import java.util.Objects;
@Lob
@Column(name = "text")
- private byte[] text;
-
- @Column(name = "text_content_type")
- private String textContentType;
+ private String text;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
this.pid = pid;
}
- public byte[] getText() {
+ public String getText() {
return text;
}
- public ReportUser text(byte[] text) {
+ public ReportUser text(String text) {
this.text = text;
return this;
}
- public void setText(byte[] text) {
+ public void setText(String text) {
this.text = text;
}
- public String getTextContentType() {
- return textContentType;
- }
-
- public ReportUser textContentType(String textContentType) {
- this.textContentType = textContentType;
- return this;
- }
-
- public void setTextContentType(String textContentType) {
- this.textContentType = textContentType;
- }
- // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
-
@Override
public boolean equals(Object o) {
if (this == o) {
", time=" + getTime() +
", pid=" + getPid() +
", text='" + getText() + "'" +
- ", textContentType='" + getTextContentType() + "'" +
"}";
}
}
package com.samsung.samserver.service;
import com.samsung.samserver.domain.primary.Report;
+import com.samsung.samserver.domain.report.ReportSyscall;
+import com.samsung.samserver.domain.report.ReportUser;
+
import java.util.List;
/**
* @param id the id of the entity
*/
void delete(Long id);
+
+ /**
+ * Save a report.
+ *
+ * @param report the entity to save
+ * @return the persisted entity
+ */
+ Object save(Object report);
+
}
*/
package com.samsung.samserver.service.impl;
+import com.samsung.samserver.domain.report.ReportSyscall;
+import com.samsung.samserver.domain.report.ReportUser;
+import com.samsung.samserver.repository.report.ReportSyscallRepository;
+import com.samsung.samserver.repository.report.ReportUserRepository;
import com.samsung.samserver.service.ReportService;
import com.samsung.samserver.domain.primary.Report;
import com.samsung.samserver.repository.primary.ReportRepository;
private final Logger log = LoggerFactory.getLogger(ReportServiceImpl.class);
private final ReportRepository reportRepository;
+ private final ReportSyscallRepository reportSyscallRepository;
+ private final ReportUserRepository reportUserRepository;
- public ReportServiceImpl(ReportRepository reportRepository) {
+ public ReportServiceImpl(ReportRepository reportRepository, ReportSyscallRepository reportSyscallRepository, ReportUserRepository reportUserRepository) {
this.reportRepository = reportRepository;
+ this.reportSyscallRepository = reportSyscallRepository;
+ this.reportUserRepository = reportUserRepository;
}
/**
log.debug("Request to delete Report : {}", id);
reportRepository.delete(id);
}
+
+ /**
+ * Save a report.
+ *
+ * @param report the entity to save
+ * @return the persisted entity
+ */
+ @Override
+ public Object save(Object report) {
+ log.debug("Request to save Report: {}", report);
+ if( report instanceof ReportSyscall) {
+ return reportSyscallRepository.save((ReportSyscall)report);
+ } else
+ if( report instanceof ReportUser) {
+ return reportUserRepository.save((ReportUser) report);
+ } else {
+ return null;
+ }
+ }
+
}
@Autowired
private PolicyService policyService;
- private ResponseEntity<Void> report(Device device, List<DLogs> logs) {
+ private ResponseEntity<Void> report(Device device, List<DReport> reports) {
+ for (DReport dReport: reports) {
+ reportService.save(dReport.getReport());
+ }
+ return ResponseEntity.ok().headers(new HttpHeaders()).build();
+ }
+
+ private ResponseEntity<Void> reportold(Device device, List<DLogs> logs) {
for (DLogs l: logs) {
String reportTypeName = l.getModule();
Optional<ReportType> reportType = reportTypeService.findOne(reportTypeName);
switch (data.getType()) {
case "report":
return report(device.get(), data.getData());
+ case "report-old":
+ return reportold(device.get(), data.getData());
case "state-policy":
return statePolicy(device.get(), data.getData());
default:
--- /dev/null
+package com.samsung.samserver.web.rest.service.vm;
+
+import com.fasterxml.jackson.annotation.*;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.samsung.samserver.domain.report.*;
+import lombok.*;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import org.slf4j.LoggerFactory;
+
+import static com.samsung.samserver.web.rest.service.vm.DReport.InputType.*;
+
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "module", visible = true)
+@JsonSubTypes({
+ @JsonSubTypes.Type(value = DReport.DReportSyscall.class, name = SYSCALL),
+ @JsonSubTypes.Type(value = DReport.DReportUser.class, name = USER)
+})
+@Getter @Setter @ToString
+public abstract class DReport {
+
+ @NotNull
+ private String module;
+ public abstract Object getReport();
+
+ final class InputType {
+ private InputType() {}
+ public static final String SYSCALL = "syscall";
+ public static final String USER = "user";
+ }
+
+ @JsonRootName(SYSCALL)
+ @Getter @Setter @ToString
+ public static class DReportSyscall extends DReport {
+ @Valid
+ @JsonProperty("log")
+ private DReportSyscallEmb reportSyscallEmb;
+ public ReportSyscall getReport() {
+ return new ReportSyscall()
+ .time(reportSyscallEmb.getTime())
+ .subj(reportSyscallEmb.getSubj())
+ .subjowneruid(reportSyscallEmb.getSubjowneruid())
+ .subjownerguid(reportSyscallEmb.getSubjownerguid())
+ .subjownereuid(reportSyscallEmb.getSubjownereuid())
+ .subjowneregid(reportSyscallEmb.getSubjowneregid())
+ .subjpid(reportSyscallEmb.getSubjpid())
+ .subjlabel(reportSyscallEmb.getSubjlabel())
+ .obj(reportSyscallEmb.getObj())
+ .objtype(reportSyscallEmb.getObjtype())
+ .objowneruid(reportSyscallEmb.getObjowneruid())
+ .objownergid(reportSyscallEmb.getObjownergid())
+ .objownereuid(reportSyscallEmb.getObjownereuid())
+ .objowneregid(reportSyscallEmb.getObjowneregid())
+ .objperm(reportSyscallEmb.getObjperm())
+ .objlabel(reportSyscallEmb.getObjlabel())
+ .objpid(reportSyscallEmb.getObjpid())
+ .objinode(reportSyscallEmb.getObjinode())
+ .syscall(reportSyscallEmb.getSyscall())
+ .syscallargs(reportSyscallEmb.getPropAsString(reportSyscallEmb.getSyscallargs()))
+ .syscallexitcode(reportSyscallEmb.getSyscallexitcode());
+ }
+ }
+
+ @JsonRootName(USER)
+ @Getter @Setter @ToString
+ public static class DReportUser extends DReport {
+ @Valid
+ @JsonProperty("log")
+ private DReportUserEmb reportUserEmb;
+ public ReportUser getReport() {
+ return new ReportUser()
+ .type(reportUserEmb.getType())
+ .time(reportUserEmb.getTime())
+ .pid(reportUserEmb.getPid())
+ .text(reportUserEmb.getText());
+ }
+ }
+
+ @Getter @Setter @ToString
+ public static class DReportSyscallEmb {
+ private Integer time;
+ private String subj;
+ @JsonProperty("subj_owner_uid")
+ private Integer subjowneruid;
+ @JsonProperty("subj_owner_guid")
+ private Integer subjownerguid;
+ @JsonProperty("subj_owner_euid")
+ private Integer subjownereuid;
+ @JsonProperty("subj_owner_egid")
+ private Integer subjowneregid;
+ @JsonProperty("subj_pid")
+ private Integer subjpid;
+ @JsonProperty("subj_label")
+ private String subjlabel;
+ private String obj;
+ @JsonProperty("obj_type")
+ private Integer objtype;
+ @JsonProperty("obj_owner_uid")
+ private Integer objowneruid;
+ @JsonProperty("obj_owner_gid")
+ private Integer objownergid;
+ @JsonProperty("obj_owner_euid")
+ private Integer objownereuid;
+ @JsonProperty("obj_owner_egid")
+ private Integer objowneregid;
+ @JsonProperty("obj_perm")
+ private Integer objperm;
+ @JsonProperty("obj_label")
+ private String objlabel;
+ @JsonProperty("obj_pid")
+ private Integer objpid;
+ @JsonProperty("obj_inode")
+ private Integer objinode;
+ private Integer syscall;
+ @JsonProperty("syscall_args")
+ private Integer[] syscallargs;
+ @JsonProperty("syscall_exitcode")
+ private Integer syscallexitcode;
+
+ String getPropAsString(Integer[] prop){
+ String result = null;
+ try {
+ result = new ObjectMapper().writeValueAsString(prop);
+ } catch (JsonProcessingException e) {
+ LoggerFactory.getLogger(DReport.class).error("getPropAsString: message: {} stacktrace: {}", e.getMessage(), e.getStackTrace());
+ }
+ return result;
+ }
+ }
+
+ @Getter @Setter @ToString
+ public static class DReportUserEmb {
+ private Integer type;
+ private Integer time;
+ private Integer pid;
+ private String text;
+ }
+
+}
\ No newline at end of file
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true)
@JsonSubTypes({
- @JsonSubTypes.Type(value = Data.DataLogs.class, name = "report"),
+ @JsonSubTypes.Type(value = Data.DataLogs.class, name = "report-old"),
+ @JsonSubTypes.Type(value = Data.DataReports.class, name = "report"),
@JsonSubTypes.Type(value = Data.DataPolicies.class, name = "state-policy"),
})
public interface Data {
String getType();
List getData();
- @JsonRootName("report")
+ @JsonRootName("report-old")
@Getter @Setter @ToString
class DataLogs implements Data{
}
}
+ @JsonRootName("report")
+ @Getter @Setter @ToString
+ class DataReports implements Data{
+
+ @NotNull
+ private String type;
+
+ private String ctime;
+
+ @Valid
+ @JsonProperty("data")
+ private List<DReport> reports;
+
+ public String getType(){
+ return type;
+ }
+
+ public List<DReport> getData(){
+ return reports;
+ }
+ }
+
@JsonRootName("state-policy")
@Getter @Setter @ToString
class DataPolicies implements Data{
<constraints nullable="true" />
</column>
- <column name="syscallargs" type="integer">
+ <column name="syscallargs" type="varchar(1023)">
<constraints nullable="true" />
</column>
<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
+ <property name="clob.type" value="clob" dbms="oracle,h2"/>
+ <property name="clob.type" value="text" dbms="postgresql"/>
+
<!--
Added the entity ReportUser.
-->
<constraints nullable="true" />
</column>
- <column name="text" type="longblob">
- <constraints nullable="true" />
- </column>
- <column name="text_content_type" type="varchar(255)">
+ <column name="text" type="${clob.type}">
<constraints nullable="true" />
</column>
private static final Integer DEFAULT_SYSCALL = 1;
private static final Integer UPDATED_SYSCALL = 2;
- private static final Integer DEFAULT_SYSCALLARGS = 1;
- private static final Integer UPDATED_SYSCALLARGS = 2;
+ private static final Integer[] DEFAULT_SYSCALLARGS = {1};
+ private static final Integer[] UPDATED_SYSCALLARGS = {2};
private static final Integer DEFAULT_SYSCALLEXITCODE = 1;
private static final Integer UPDATED_SYSCALLEXITCODE = 2;
.objpid(DEFAULT_OBJPID)
.objinode(DEFAULT_OBJINODE)
.syscall(DEFAULT_SYSCALL)
- .syscallargs(DEFAULT_SYSCALLARGS)
+ //.syscallargs(DEFAULT_SYSCALLARGS)
.syscallexitcode(DEFAULT_SYSCALLEXITCODE);
return reportSyscall;
}
assertThat(testReportSyscall.getObjpid()).isEqualTo(DEFAULT_OBJPID);
assertThat(testReportSyscall.getObjinode()).isEqualTo(DEFAULT_OBJINODE);
assertThat(testReportSyscall.getSyscall()).isEqualTo(DEFAULT_SYSCALL);
- assertThat(testReportSyscall.getSyscallargs()).isEqualTo(DEFAULT_SYSCALLARGS);
+ //assertThat(testReportSyscall.getSyscallargs()).isEqualTo(DEFAULT_SYSCALLARGS);
assertThat(testReportSyscall.getSyscallexitcode()).isEqualTo(DEFAULT_SYSCALLEXITCODE);
}
.andExpect(jsonPath("$.[*].objpid").value(hasItem(DEFAULT_OBJPID)))
.andExpect(jsonPath("$.[*].objinode").value(hasItem(DEFAULT_OBJINODE)))
.andExpect(jsonPath("$.[*].syscall").value(hasItem(DEFAULT_SYSCALL)))
- .andExpect(jsonPath("$.[*].syscallargs").value(hasItem(DEFAULT_SYSCALLARGS)))
+ //.andExpect(jsonPath("$.[*].syscallargs").value(hasItem(DEFAULT_SYSCALLARGS)))
.andExpect(jsonPath("$.[*].syscallexitcode").value(hasItem(DEFAULT_SYSCALLEXITCODE)));
}
.andExpect(jsonPath("$.objpid").value(DEFAULT_OBJPID))
.andExpect(jsonPath("$.objinode").value(DEFAULT_OBJINODE))
.andExpect(jsonPath("$.syscall").value(DEFAULT_SYSCALL))
- .andExpect(jsonPath("$.syscallargs").value(DEFAULT_SYSCALLARGS))
+ //.andExpect(jsonPath("$.syscallargs").value(DEFAULT_SYSCALLARGS))
.andExpect(jsonPath("$.syscallexitcode").value(DEFAULT_SYSCALLEXITCODE));
}
.objpid(UPDATED_OBJPID)
.objinode(UPDATED_OBJINODE)
.syscall(UPDATED_SYSCALL)
- .syscallargs(UPDATED_SYSCALLARGS)
+ //.syscallargs(UPDATED_SYSCALLARGS)
.syscallexitcode(UPDATED_SYSCALLEXITCODE);
restReportSyscallMockMvc.perform(put("/api/report-syscalls")
assertThat(testReportSyscall.getObjpid()).isEqualTo(UPDATED_OBJPID);
assertThat(testReportSyscall.getObjinode()).isEqualTo(UPDATED_OBJINODE);
assertThat(testReportSyscall.getSyscall()).isEqualTo(UPDATED_SYSCALL);
- assertThat(testReportSyscall.getSyscallargs()).isEqualTo(UPDATED_SYSCALLARGS);
+ //assertThat(testReportSyscall.getSyscallargs()).isEqualTo(UPDATED_SYSCALLARGS);
assertThat(testReportSyscall.getSyscallexitcode()).isEqualTo(UPDATED_SYSCALLEXITCODE);
}
private static final Integer DEFAULT_PID = 1;
private static final Integer UPDATED_PID = 2;
- private static final byte[] DEFAULT_TEXT = TestUtil.createByteArray(1, "0");
- private static final byte[] UPDATED_TEXT = TestUtil.createByteArray(2, "1");
+ private static final String DEFAULT_TEXT = "0000";
+ private static final String UPDATED_TEXT = "1111";
private static final String DEFAULT_TEXT_CONTENT_TYPE = "image/jpg";
private static final String UPDATED_TEXT_CONTENT_TYPE = "image/png";
.type(DEFAULT_TYPE)
.time(DEFAULT_TIME)
.pid(DEFAULT_PID)
- .text(DEFAULT_TEXT)
- .textContentType(DEFAULT_TEXT_CONTENT_TYPE);
+ .text(DEFAULT_TEXT);
return reportUser;
}
assertThat(testReportUser.getTime()).isEqualTo(DEFAULT_TIME);
assertThat(testReportUser.getPid()).isEqualTo(DEFAULT_PID);
assertThat(testReportUser.getText()).isEqualTo(DEFAULT_TEXT);
- assertThat(testReportUser.getTextContentType()).isEqualTo(DEFAULT_TEXT_CONTENT_TYPE);
}
@Test
.andExpect(jsonPath("$.[*].type").value(hasItem(DEFAULT_TYPE)))
.andExpect(jsonPath("$.[*].time").value(hasItem(DEFAULT_TIME)))
.andExpect(jsonPath("$.[*].pid").value(hasItem(DEFAULT_PID)))
- .andExpect(jsonPath("$.[*].textContentType").value(hasItem(DEFAULT_TEXT_CONTENT_TYPE)))
- .andExpect(jsonPath("$.[*].text").value(hasItem(Base64Utils.encodeToString(DEFAULT_TEXT))));
+ .andExpect(jsonPath("$.[*].text").value(hasItem(DEFAULT_TEXT)));
}
@Test
.andExpect(jsonPath("$.type").value(DEFAULT_TYPE))
.andExpect(jsonPath("$.time").value(DEFAULT_TIME))
.andExpect(jsonPath("$.pid").value(DEFAULT_PID))
- .andExpect(jsonPath("$.textContentType").value(DEFAULT_TEXT_CONTENT_TYPE))
- .andExpect(jsonPath("$.text").value(Base64Utils.encodeToString(DEFAULT_TEXT)));
+ .andExpect(jsonPath("$.text").value(DEFAULT_TEXT));
}
@Test
.type(UPDATED_TYPE)
.time(UPDATED_TIME)
.pid(UPDATED_PID)
- .text(UPDATED_TEXT)
- .textContentType(UPDATED_TEXT_CONTENT_TYPE);
+ .text(UPDATED_TEXT);
restReportUserMockMvc.perform(put("/api/report-users")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
assertThat(testReportUser.getTime()).isEqualTo(UPDATED_TIME);
assertThat(testReportUser.getPid()).isEqualTo(UPDATED_PID);
assertThat(testReportUser.getText()).isEqualTo(UPDATED_TEXT);
- assertThat(testReportUser.getTextContentType()).isEqualTo(UPDATED_TEXT_CONTENT_TYPE);
}
@Test
{
- "type": "report",
+ "type": "report-old",
"data": [
{
"module": "MAC",