Commit 267c45e2 by 钱炳权

项目结构重规划+aflnet信息全流程正常

parent deacd8b0
...@@ -3,13 +3,12 @@ package com.example.fuzzControll.annotion; ...@@ -3,13 +3,12 @@ package com.example.fuzzControll.annotion;
import java.lang.annotation.*; import java.lang.annotation.*;
/** /**
* 切片标识注解 * 方法后置处理
*/ */
@Inherited @Inherited
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD}) @Target({ElementType.METHOD})
public @interface NeedCut { public @interface NeedCutAfter {
String name() default ""; String name() default "";
String moment() default "";
String function() default ""; String function() default "";
} }
package com.example.fuzzControll.annotion;
import java.lang.annotation.*;
/**
* 方法前置处理
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface NeedCutAround {
String name() default "";
String function() default "";
}
package com.example.fuzzControll.annotion;
import java.lang.annotation.*;
/**
* 方法前置处理
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface NeedCutBefore {
String name() default "";
String function() default "";
}
package com.example.fuzzControll.aop; package com.example.fuzzControll.aop;
import com.example.fuzzControll.annotion.NeedCut; import com.example.fuzzControll.annotion.NeedCutBefore;
import com.example.fuzzControll.constents.LogicDeleteEnum; import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.constents.MissionStateEnum; import com.example.fuzzControll.constents.MissionStateEnum;
import com.example.fuzzControll.constents.TableClassEnum; import com.example.fuzzControll.constents.TableClassEnum;
import com.example.fuzzControll.mapper.MissionInfoMapper; import com.example.fuzzControll.domain.po.MissionInfo;
import com.example.fuzzControll.pojo.vo.MissionInfo; import com.example.fuzzControll.exception.mysqlException.MysqlException;
import com.example.fuzzControll.service.AflnetPersistenceService; import com.example.fuzzControll.exception.testException.AflnetException;
import com.example.fuzzControll.tools.GlobalParameters; import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.tools.system.SystemRunningParams;
import com.example.fuzzControll.tools.test.SingleCmdTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
...@@ -17,7 +20,6 @@ import org.aspectj.lang.annotation.Aspect; ...@@ -17,7 +20,6 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -26,20 +28,33 @@ import java.util.Arrays; ...@@ -26,20 +28,33 @@ import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import static com.example.fuzzControll.tools.system.GlobalClass.aflnetPersistenceService;
@Aspect @Aspect
@Component @Component
@Slf4j @Slf4j
public class IntegrationAop implements Ordered { public class IntegrationAop implements Ordered {
SingleCmdTools singleCmdTools = new SingleCmdTools();
@Pointcut(value = "@annotation(com.example.fuzzControll.annotion.NeedCutBefore)")
private void beforCut() {
}
@Pointcut(value = "@annotation(com.example.fuzzControll.annotion.NeedCutBefore)")
private void afterCut() {
}
@Pointcut(value = "@annotation(com.example.fuzzControll.annotion.NeedCut)") @Pointcut(value = "@annotation(com.example.fuzzControll.annotion.NeedCutBefore)")
private void cut() { private void aroundCut() {
} }
@Before("cut()") /**
* 用于aflnet测试相关的数据库操作
*/
@Before("beforCut()")
private void before(JoinPoint point) { private void before(JoinPoint point) {
List<String> needProcess = Arrays.asList("aflnet"); /*负责获取反射对象*/
Signature signature = point.getSignature(); Signature signature = point.getSignature();
MethodSignature methodSignature = null; MethodSignature methodSignature = null;
if (!(signature instanceof MethodSignature)) { if (!(signature instanceof MethodSignature)) {
...@@ -55,17 +70,21 @@ public class IntegrationAop implements Ordered { ...@@ -55,17 +70,21 @@ public class IntegrationAop implements Ordered {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(e); throw new RuntimeException(e);
} }
NeedCut logotype = currentMethod.getAnnotation(NeedCut.class); NeedCutBefore logotype = currentMethod.getAnnotation(NeedCutBefore.class);
if ("before".equals(logotype.moment())) {//需要进行处理 /*aflnet相关处理逻辑,负责数据存入*/
if ("aflnet".equals(logotype.name())) {//aflnet测试信息存储 switch (logotype.name()) {
int missionId = GlobalParameters.missionInfoMapper.selectTopMissionId() + 1; case "aflnet":
GlobalParameters.missionInfoMapper.insertMission(new MissionInfo(missionId, TableClassEnum.AFLNET.getTableId(), new Date(), GlobalParameters.aflnetData.get("missionName"), aflnet(logotype.function());
MissionStateEnum.RUNNING.getStateCode(), 0L)); break;
} case "kitty":
kitty(logotype.function());
break;
default:
throw new AflnetException("Cut error: There is no name of anotation!");
} }
} }
@Around("cut()") @Around("aroundCut()")
public Object around(ProceedingJoinPoint point) throws Throwable { public Object around(ProceedingJoinPoint point) throws Throwable {
Signature signature = point.getSignature(); Signature signature = point.getSignature();
...@@ -78,7 +97,7 @@ public class IntegrationAop implements Ordered { ...@@ -78,7 +97,7 @@ public class IntegrationAop implements Ordered {
Object target = point.getTarget(); Object target = point.getTarget();
Method currentMethod = target.getClass().getMethod(methodSignature.getName(), methodSignature.getParameterTypes()); Method currentMethod = target.getClass().getMethod(methodSignature.getName(), methodSignature.getParameterTypes());
NeedCut logotype = currentMethod.getAnnotation(NeedCut.class); NeedCutBefore logotype = currentMethod.getAnnotation(NeedCutBefore.class);
// if (datasource != null) { // if (datasource != null) {
// DataSourceContextHolder.setDataSourceType(logotype.name()); // DataSourceContextHolder.setDataSourceType(logotype.name());
// log.debug("设置数据源为:" + datasource.name()); // log.debug("设置数据源为:" + datasource.name());
...@@ -94,6 +113,62 @@ public class IntegrationAop implements Ordered { ...@@ -94,6 +113,62 @@ public class IntegrationAop implements Ordered {
// } // }
} }
private void aflnet(String function) {
if (function == null || "".equals(function)) {
throw new AflnetException("There is no value in function!");
}
if ("startBackup".equals(function)) {
/*存入alfnet启动时的任务信息*/
try {
int missionId = GlobalClass.missionInfoMapper.selectTopMissionId() + 1;
SystemRunningParams.aflnetMissionId = missionId;
GlobalClass.missionInfoMapper.insertMission(new MissionInfo(missionId, TableClassEnum.AFLNET.getTableId(), new Date(), SystemRunningParams.aflnetData.get("missionName"),
MissionStateEnum.RUNNING.getStateCode(), 0L));
} catch (Exception e) {
e.printStackTrace();
throw new MysqlException("Aflnet start backup failed!");
}
} else if ("stopBackup".equals(function)) {
/*存入alfnet停止时的任务信息*/
new Thread(new Runnable() {
@Override
public void run() {
try {
int flag = 0;
/*压缩aflnet产生的测试文件,为存入数据库做准备*/
String fileName = SystemRunningParams.aflnetData.get("aflnetName");
String fileZipName = fileName + ".zip";
singleCmdTools.runCmd(CmdConstent.RUN_ZIP_FILE + fileZipName + " " + fileName, "zip file in testStart");
List<String> files = singleCmdTools.runCmd(CmdConstent.GET_FILE_NAME + GlobalClass.aflnetProperties.getOutputPath(), "getSeedFiles");
if (!files.contains(fileZipName)) {
log.error("File zip error!");
}
/*存入压缩包*/
while (files.contains(fileZipName) && flag == 0) {//当前存在压缩包,且没有存过才存入,循环是等待压缩完成 todo 感觉这里后期会出现问题
flag = aflnetPersistenceService.aflnetResultBackup(fileZipName, 1,
SystemRunningParams.testTimeMessage.get("aflnet").get("end") - SystemRunningParams.testTimeMessage.get("aflnet").get("start"));
}
/*清除生成的文件*/
try {
singleCmdTools.runCmd(CmdConstent.DELETE_FILE + fileName, "delete file");
singleCmdTools.runCmd(CmdConstent.DELETE_FILE + fileZipName, "delete zipFile");
} catch (CmdException e) {
e.printStackTrace();
log.error("file delete failed!");
}
log.info("Aflnet Logs has been backuped!");
} catch (Exception e) {
e.printStackTrace();
throw new MysqlException("Aflnet after backup failed!");
}
}
}).start();
}
}
private void kitty(String function) {
}
@Override @Override
public int getOrder() { public int getOrder() {
......
package com.example.fuzzControll.constents; package com.example.fuzzControll.constents;
import com.example.fuzzControll.conf.SpringContextUtil; import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.tools.GlobalParameters;
/**
* 系统内置命令
*/
public class CmdConstent { public class CmdConstent {
public static final String GET_FILE_NAME = "ls -h "; public static final String GET_FILE_NAME = "ls -h ";
public static final String DELETE_FILE = "rm -r "; public static final String DELETE_FILE = "rm -r ";
public static final String COUNT_FILE = "ls -l | grep \"^-\" | wc -l"; public static final String COUNT_FILE = "ls -l | grep \"^-\" | wc -l";
public static final String COUNT_DIR = "ls -l | grep \"^d\" | wc -l"; public static final String COUNT_DIR = "ls -l | grep \"^d\" | wc -l";
public static final String RUN_AFLNET_BEFORE = "afl-fuzz -d -i " + GlobalParameters.aflnetProperties.getAflnetPath() + "aflnet/tutorials/live555/in-rtsp -o "+ public static final String RUN_AFLNET_BEFORE = "afl-fuzz -d -i " + GlobalClass.aflnetProperties.getAflnetPath() + "aflnet/tutorials/live555/in-rtsp -o "+
GlobalParameters.aflnetProperties.getOutputPath(); GlobalClass.aflnetProperties.getOutputPath();
public static final String RUN_AFLNET_AFTER = " -x " + GlobalParameters.aflnetProperties.getAflnetPath() + "aflnet/tutorials/live555/rtsp.dict "; public static final String RUN_AFLNET_AFTER = " -x " + GlobalClass.aflnetProperties.getAflnetPath() + "aflnet/tutorials/live555/rtsp.dict ";
public static final String RUN_PING = "ping www.baidu.com"; public static final String RUN_PING = "ping www.baidu.com";
public static final String RUN_ZIP_FILE = "zip -r "; public static final String RUN_ZIP_FILE = "zip -r ";
......
package com.example.fuzzControll.constents;
public enum LogicDeleteEnum {
ALIVE("alive",0),
LOGIC_DELETE("logic_delete",1);
private String name;
private int code;
LogicDeleteEnum(String name, int code) {
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
package com.example.fuzzControll.constents; package com.example.fuzzControll.constents;
/**
* 任务运行状态枚举类
*/
public enum MissionStateEnum { public enum MissionStateEnum {
DONE("done",1), DONE("done",1),
RUNNING("running",2), RUNNING("running",2),
......
package com.example.fuzzControll.constents; package com.example.fuzzControll.constents;
/**
* 变异脚本路径
*/
public class MutationConstent { public class MutationConstent {
public static final String TEST_GRANULARITY_BIT_BYTE = "test_granularity_bit_byte.py "; public static final String TEST_GRANULARITY_BIT_BYTE = "test_granularity_bit_byte.py ";
public static final String TEST_MUTATED_LIBS = "test_mutated_libs.py "; public static final String TEST_MUTATED_LIBS = "test_mutated_libs.py ";
......
package com.example.fuzzControll.constents; package com.example.fuzzControll.constents;
/**
* 协议模板路径
*/
public class ProtocolConstent { public class ProtocolConstent {
public static final String ARP = "arp_raw.py "; public static final String ARP = "arp_raw.py ";
public static final String BGP = "bgp_tcp.py "; public static final String BGP = "bgp_tcp.py ";
......
package com.example.fuzzControll.constents; package com.example.fuzzControll.constents;
/**
* aflnet目标服务路径
*/
public enum ServerClassEnum { public enum ServerClassEnum {
RTSP("rtsp","testOnDemandRTSPServer 8554"), RTSP("rtsp","testOnDemandRTSPServer 8554"),
FTP("ftp","testOnDemandFTP 8554"),//error FTP("ftp","testOnDemandFTP 8554"),//error
......
package com.example.fuzzControll.constents; package com.example.fuzzControll.constents;
/**
* 数据库表分类枚举
*/
public enum TableClassEnum { public enum TableClassEnum {
AFLNET("alfnetResult",1), AFLNET("alfnetResult",1),
KITTY_PACKAGE("kittyPackageFile",2), KITTY_PACKAGE("kittyPackageFile",2),
......
package com.example.fuzzControll.controller.dataController; package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.pojo.vo.AflnetDataParams; import com.example.fuzzControll.domain.bo.AflnetDataParams;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.KittyResult;
import com.example.fuzzControll.service.AflnetPersistenceService; import com.example.fuzzControll.service.AflnetPersistenceService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController @RestController
@RequestMapping("/aflnet") @RequestMapping("/aflnet")
@Slf4j @Slf4j
......
package com.example.fuzzControll.controller.dataController; package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.pojo.vo.AflnetDataParams; import com.example.fuzzControll.domain.bo.FuzzLogTransEntity;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.FuzzLogTransEntity;
import com.example.fuzzControll.service.FuzzLogService; import com.example.fuzzControll.service.FuzzLogService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
......
package com.example.fuzzControll.controller.dataController; package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.KittyDataParams; import com.example.fuzzControll.domain.bo.KittyDataParams;
import com.example.fuzzControll.pojo.vo.KittyResult; import com.example.fuzzControll.domain.vo.KittyResult;
import com.example.fuzzControll.service.KittyFuzzPersistenceService; import com.example.fuzzControll.service.KittyFuzzPersistenceService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
package com.example.fuzzControll.controller; package com.example.fuzzControll.controller.dataController;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.example.fuzzControll.exception.ServerException; import com.example.fuzzControll.exception.serverException.ServerException;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.service.GetServerMessageService; import com.example.fuzzControll.service.GetServerMessageService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -10,8 +10,6 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -10,8 +10,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
/** /**
* kitty服务器信息 * kitty服务器信息
*/ */
......
package com.example.fuzzControll.controller.dataController; package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.mapper.MissionInfoMapper; import com.example.fuzzControll.mapper.MissionInfoMapper;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.FuzzLogTransEntity;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
......
package com.example.fuzzControll.controller; package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.FileException; import com.example.fuzzControll.exception.fileExcption.FileException;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.service.SeedFileService; import com.example.fuzzControll.service.SeedFileService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
......
package com.example.fuzzControll.controller; package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.service.websocketClientService; import com.example.fuzzControll.service.websocketClientService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -7,6 +7,9 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -7,6 +7,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/**
* websocket 客户端
*/
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/websocket") @RequestMapping("/websocket")
......
package com.example.fuzzControll.controller; package com.example.fuzzControll.controller.testController;
import com.example.fuzzControll.exception.*; import com.example.fuzzControll.exception.mysqlException.MysqlException;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.exception.testException.AflnetException;
import com.example.fuzzControll.pojo.vo.CmdStartParams; import com.example.fuzzControll.exception.threadException.MyExceptionHandler;
import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.domain.bo.CmdStartParams;
import com.example.fuzzControll.service.TestService; import com.example.fuzzControll.service.TestService;
import com.example.fuzzControll.tools.GlobalParameters; import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.tools.system.SystemRunningParams;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -29,18 +32,19 @@ public class AlfnetController { ...@@ -29,18 +32,19 @@ public class AlfnetController {
public AjaxResult start(@RequestBody final CmdStartParams cmdStartParams) { public AjaxResult start(@RequestBody final CmdStartParams cmdStartParams) {
//todo 捕获子线程错误 //todo 捕获子线程错误
try { try {
GlobalParameters.aflnetData.put("missionName", cmdStartParams.getProtopcol()); SystemRunningParams.aflnetData.put("missionName", cmdStartParams.getProtopcol());
Thread subThread = new Thread(new Runnable() { Thread subThread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
service.testStart(cmdStartParams); service.testStart(cmdStartParams);
} }
}); });
GlobalParameters.ThreadState.put(subThread,"start"); SystemRunningParams.ThreadState.put(subThread,"start");
subThread.setUncaughtExceptionHandler(new MyExceptionHandler()); subThread.setUncaughtExceptionHandler(new MyExceptionHandler());
subThread.start(); subThread.start();
subThread.join(); // subThread.join();
if ("error".equals(GlobalParameters.ThreadState.get(subThread))) { Thread.sleep(1000*10);//暂停3s,让系统运行至指令完全运行 todo跟据系统运行设定时间
if ("error".equals(SystemRunningParams.ThreadState.get(subThread))) {//使用join串行就无法停止
throw new Exception(); throw new Exception();
} }
} catch (Exception e) { } catch (Exception e) {
......
package com.example.fuzzControll.controller; package com.example.fuzzControll.controller.testController;
import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.FuzzException; import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.service.GenerateMethodService; import com.example.fuzzControll.service.GenerateMethodService;
import com.example.fuzzControll.service.MutationService; import com.example.fuzzControll.service.MutationService;
import com.example.fuzzControll.service.ProtocolTemplateService; import com.example.fuzzControll.service.ProtocolTemplateService;
......
package com.example.fuzzControll.pojo.vo; package com.example.fuzzControll.domain.bo;
import lombok.Data; import lombok.Data;
......
package com.example.fuzzControll.pojo.vo; package com.example.fuzzControll.domain.bo;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
......
package com.example.fuzzControll.pojo.vo; package com.example.fuzzControll.domain.bo;
import lombok.Data; import lombok.Data;
......
package com.example.fuzzControll.pojo.vo; package com.example.fuzzControll.domain.bo;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
......
package com.example.fuzzControll.pojo.vo; package com.example.fuzzControll.domain.po;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data; import lombok.Data;
......
package com.example.fuzzControll.pojo.vo; package com.example.fuzzControll.domain.vo;
import lombok.Data; import lombok.Data;
......
package com.example.fuzzControll.pojo.vo; package com.example.fuzzControll.domain.vo;
import java.util.HashMap; import java.util.HashMap;
......
package com.example.fuzzControll.pojo.vo; package com.example.fuzzControll.domain.vo;
import lombok.Data; import lombok.Data;
......
package com.example.fuzzControll.pojo.vo; package com.example.fuzzControll.domain.vo;
import lombok.Data; import lombok.Data;
......
package com.example.fuzzControll.pojo.vo; package com.example.fuzzControll.domain.vo;
import lombok.Data; import lombok.Data;
......
package com.example.fuzzControll.exception; package com.example.fuzzControll.exception.fileExcption;
import com.example.fuzzControll.exception.BaseException;
/** /**
* 文件操作异常 * 文件操作异常
*/ */
public class FileException extends BaseException{ public class FileException extends BaseException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public FileException(String defaultMessage) { public FileException(String defaultMessage) {
super(defaultMessage, "file"); super(defaultMessage, "file");
......
package com.example.fuzzControll.exception; package com.example.fuzzControll.exception.mysqlException;
public class MysqlException extends BaseException{ import com.example.fuzzControll.exception.BaseException;
public class MysqlException extends BaseException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public MysqlException(String defaultMessage) { public MysqlException(String defaultMessage) {
......
package com.example.fuzzControll.exception; package com.example.fuzzControll.exception.serverException;
public class ServerException extends BaseException{ import com.example.fuzzControll.exception.BaseException;
public class ServerException extends BaseException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public ServerException(String defaultMessage) { public ServerException(String defaultMessage) {
super(defaultMessage, "server"); super(defaultMessage, "server");
......
package com.example.fuzzControll.exception; package com.example.fuzzControll.exception.testException;
public class AflnetException extends BaseException{ import com.example.fuzzControll.exception.BaseException;
public class AflnetException extends BaseException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public AflnetException(String defaultMessage) { public AflnetException(String defaultMessage) {
......
package com.example.fuzzControll.exception; package com.example.fuzzControll.exception.testException;
import com.example.fuzzControll.exception.BaseException;
/** /**
* cmd运行异常 * cmd运行异常
......
package com.example.fuzzControll.exception; package com.example.fuzzControll.exception.testException;
public class FuzzException extends BaseException{ import com.example.fuzzControll.exception.BaseException;
public class FuzzException extends BaseException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public FuzzException(String defaultMessage) { public FuzzException(String defaultMessage) {
super(defaultMessage, "lock"); super(defaultMessage, "lock");
......
package com.example.fuzzControll.exception; package com.example.fuzzControll.exception.threadException;
public class LockException extends BaseException{ import com.example.fuzzControll.exception.BaseException;
public class LockException extends BaseException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public LockException(String defaultMessage) { public LockException(String defaultMessage) {
super(defaultMessage, "fuzz"); super(defaultMessage, "fuzz");
......
package com.example.fuzzControll.exception; package com.example.fuzzControll.exception.threadException;
import com.example.fuzzControll.tools.GlobalParameters; import com.example.fuzzControll.tools.system.GlobalClass;
import org.springframework.context.annotation.Bean; import com.example.fuzzControll.tools.system.SystemRunningParams;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
...@@ -10,7 +10,7 @@ public class MyExceptionHandler implements Thread.UncaughtExceptionHandler ...@@ -10,7 +10,7 @@ public class MyExceptionHandler implements Thread.UncaughtExceptionHandler
@Override @Override
public void uncaughtException(Thread t, Throwable e) public void uncaughtException(Thread t, Throwable e)
{ {
GlobalParameters.ThreadState.put(t,"error"); SystemRunningParams.ThreadState.put(t,"error");
} }
} }
package com.example.fuzzControll.inital;
import com.example.fuzzControll.tools.system.SystemRunningParams;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* 系统全局初始化
*/
@Component
public class SystemInitial {
@PostConstruct
public void doConstruct() throws Exception {
SystemRunningParams.init();
}
}
package com.example.fuzzControll.mapper; package com.example.fuzzControll.mapper;
import com.example.fuzzControll.pojo.vo.AflnetResult; import com.example.fuzzControll.domain.vo.AflnetResult;
import com.example.fuzzControll.pojo.vo.KittyResult;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
@Mapper @Mapper
@Component("AflnetMapper") @Component("AflnetMapper")
public interface AflnetMapper { public interface AflnetMapper {
......
package com.example.fuzzControll.mapper; package com.example.fuzzControll.mapper;
import com.example.fuzzControll.pojo.vo.KittyResult; import com.example.fuzzControll.domain.vo.KittyResult;
import com.example.fuzzControll.pojo.vo.KittyPackageFile; import com.example.fuzzControll.domain.vo.KittyPackageFile;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
......
package com.example.fuzzControll.mapper; package com.example.fuzzControll.mapper;
import com.example.fuzzControll.pojo.vo.MissionInfo; import com.example.fuzzControll.domain.po.MissionInfo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -21,4 +21,6 @@ public interface MissionInfoMapper { ...@@ -21,4 +21,6 @@ public interface MissionInfoMapper {
int selectTopMissionId(); int selectTopMissionId();
void insertMission(MissionInfo missionInfo); void insertMission(MissionInfo missionInfo);
void updateMission(int state,Long runTime,int missionId);
} }
package com.example.fuzzControll.pojo.vo;
public class KittyLog {
int id;
}
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
public interface AflnetPersistenceService { public interface AflnetPersistenceService {
public int aflnetResultBackup(String filename, String missionName,int state,int logicDelete,Long runTime); public int aflnetResultBackup(String filename, int state, Long runTime);
public void loadInFile(int missionId,String filePath); public void loadInFile(int missionId,String filePath);
} }
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.FuzzLogTransEntity; import com.example.fuzzControll.domain.bo.FuzzLogTransEntity;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
public interface FuzzLogService { public interface FuzzLogService {
......
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
......
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.KittyDataParams; import com.example.fuzzControll.domain.bo.KittyDataParams;
import com.example.fuzzControll.pojo.vo.KittyResult; import com.example.fuzzControll.domain.vo.KittyResult;
import java.util.List; import java.util.List;
......
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
......
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
......
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.CmdStartParams; import com.example.fuzzControll.domain.bo.CmdStartParams;
import java.util.concurrent.CountDownLatch;
public interface TestService { public interface TestService {
......
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
......
...@@ -2,14 +2,14 @@ package com.example.fuzzControll.service.impl; ...@@ -2,14 +2,14 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.AflnetProperties; import com.example.fuzzControll.conf.AflnetProperties;
import com.example.fuzzControll.constents.TableClassEnum; import com.example.fuzzControll.constents.TableClassEnum;
import com.example.fuzzControll.exception.MysqlException; import com.example.fuzzControll.exception.mysqlException.MysqlException;
import com.example.fuzzControll.mapper.AflnetMapper; import com.example.fuzzControll.mapper.AflnetMapper;
import com.example.fuzzControll.mapper.MissionInfoMapper; import com.example.fuzzControll.mapper.MissionInfoMapper;
import com.example.fuzzControll.pojo.vo.AflnetResult; import com.example.fuzzControll.domain.vo.AflnetResult;
import com.example.fuzzControll.pojo.vo.KittyResult; import com.example.fuzzControll.domain.po.MissionInfo;
import com.example.fuzzControll.pojo.vo.MissionInfo;
import com.example.fuzzControll.service.AflnetPersistenceService; import com.example.fuzzControll.service.AflnetPersistenceService;
import com.example.fuzzControll.tools.FileTools; import com.example.fuzzControll.tools.file.FileTools;
import com.example.fuzzControll.tools.system.SystemRunningParams;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -29,8 +29,8 @@ public class AflnetPersistenceServiceImpl implements AflnetPersistenceService { ...@@ -29,8 +29,8 @@ public class AflnetPersistenceServiceImpl implements AflnetPersistenceService {
FileTools fileTools = new FileTools(); FileTools fileTools = new FileTools();
@Override @Override
public int aflnetResultBackup(String filename, String missionName,int state,int logicDelete,Long runTime) { public int aflnetResultBackup(String filename, int state, Long runTime) {
return mysqlTransaction(filename, missionName,state,logicDelete,runTime); return mysqlTransaction(filename, state, runTime);
} }
@Override @Override
...@@ -46,11 +46,11 @@ public class AflnetPersistenceServiceImpl implements AflnetPersistenceService { ...@@ -46,11 +46,11 @@ public class AflnetPersistenceServiceImpl implements AflnetPersistenceService {
} }
@Transactional(rollbackFor = MysqlException.class) @Transactional(rollbackFor = MysqlException.class)
public int mysqlTransaction(String filename, String missionName,int state,int logicDelete,Long runTime) { public int mysqlTransaction(String filename, int state, Long runTime) {
int topMissionId = missionInfoMapper.selectTopMissionId() + 1;//获取最新的missionId int aflnetMissionId = SystemRunningParams.aflnetMissionId;//获取系统正在操作的aflnet的missionId
AflnetResult result = new AflnetResult(topMissionId, fileTools.fileReadAndTranstoBytes(aflnetProperties.getOutputPath(), filename), filename); AflnetResult result = new AflnetResult(aflnetMissionId, fileTools.fileReadAndTranstoBytes(aflnetProperties.getOutputPath(), filename), filename);
aflnetMapper.aflnetOutputBackup(result);//存入日志文件 aflnetMapper.aflnetOutputBackup(result);//存入日志文件
missionInfoMapper.insertMission(new MissionInfo(topMissionId, TableClassEnum.AFLNET.getTableId(), new Date(), missionName, state, runTime));//插入任务信息 missionInfoMapper.updateMission(state,runTime,aflnetMissionId);//更新该次任务的执行时间
return 1; return 1;
} }
} }
package com.example.fuzzControll.service.impl; package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.exception.MysqlException; import com.example.fuzzControll.domain.vo.AflnetResult;
import com.example.fuzzControll.domain.bo.FuzzLogTransEntity;
import com.example.fuzzControll.domain.vo.KittyResult;
import com.example.fuzzControll.domain.po.MissionInfo;
import com.example.fuzzControll.exception.mysqlException.MysqlException;
import com.example.fuzzControll.mapper.AflnetMapper; import com.example.fuzzControll.mapper.AflnetMapper;
import com.example.fuzzControll.mapper.KittyMapper; import com.example.fuzzControll.mapper.KittyMapper;
import com.example.fuzzControll.mapper.MissionInfoMapper; import com.example.fuzzControll.mapper.MissionInfoMapper;
import com.example.fuzzControll.pojo.vo.*;
import com.example.fuzzControll.service.FuzzLogService; import com.example.fuzzControll.service.FuzzLogService;
import com.example.fuzzControll.tools.FileTools; import com.example.fuzzControll.tools.file.FileTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
package com.example.fuzzControll.service.impl; package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.FuzzException; import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.service.GenerateMethodService; import com.example.fuzzControll.service.GenerateMethodService;
import com.example.fuzzControll.tools.CmdTools; import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.TestTools; import com.example.fuzzControll.tools.test.TestTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
......
package com.example.fuzzControll.service.impl; package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.exception.ServerException; import com.example.fuzzControll.exception.serverException.ServerException;
import com.example.fuzzControll.service.GetServerMessageService; import com.example.fuzzControll.service.GetServerMessageService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
......
...@@ -2,14 +2,14 @@ package com.example.fuzzControll.service.impl; ...@@ -2,14 +2,14 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.CmdConstent; import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.exception.MysqlException; import com.example.fuzzControll.exception.mysqlException.MysqlException;
import com.example.fuzzControll.mapper.KittyMapper; import com.example.fuzzControll.mapper.KittyMapper;
import com.example.fuzzControll.pojo.vo.KittyDataParams; import com.example.fuzzControll.domain.bo.KittyDataParams;
import com.example.fuzzControll.pojo.vo.KittyResult; import com.example.fuzzControll.domain.vo.KittyResult;
import com.example.fuzzControll.pojo.vo.KittyPackageFile; import com.example.fuzzControll.domain.vo.KittyPackageFile;
import com.example.fuzzControll.service.KittyFuzzPersistenceService; import com.example.fuzzControll.service.KittyFuzzPersistenceService;
import com.example.fuzzControll.tools.CmdTools; import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.FileTools; import com.example.fuzzControll.tools.file.FileTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
......
...@@ -2,12 +2,12 @@ package com.example.fuzzControll.service.impl; ...@@ -2,12 +2,12 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.MutationConstent; import com.example.fuzzControll.constents.MutationConstent;
import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.FuzzException; import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.service.MutationService; import com.example.fuzzControll.service.MutationService;
import com.example.fuzzControll.tools.CmdTools; import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.TestTools; import com.example.fuzzControll.tools.test.TestTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
......
...@@ -4,13 +4,13 @@ package com.example.fuzzControll.service.impl; ...@@ -4,13 +4,13 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.CmdConstent; import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.constents.ProtocolConstent; import com.example.fuzzControll.constents.ProtocolConstent;
import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.FuzzException; import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.service.ProtocolTemplateService; import com.example.fuzzControll.service.ProtocolTemplateService;
import com.example.fuzzControll.tools.CmdTools; import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.GlobalParameters; import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.tools.TestTools; import com.example.fuzzControll.tools.test.TestTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -28,7 +28,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -28,7 +28,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
@Override @Override
public Map<String, List<String>> generation(TestEntity testEntity,int missionId) throws FuzzException, CmdException { public Map<String, List<String>> generation(TestEntity testEntity,int missionId) throws FuzzException, CmdException {
/*生成日志前先清除日志*/ /*生成日志前先清除日志*/
cmdTools.runCmd(CmdConstent.DELETE_FILE + GlobalParameters.kittyProperties.getLogOutPath(),"delete kittyLogs"); cmdTools.runCmd(CmdConstent.DELETE_FILE + GlobalClass.kittyProperties.getLogOutPath(),"delete kittyLogs");
String cmd = parseParameters(testEntity); String cmd = parseParameters(testEntity);
if (cmd == null || cmd.equals("")) { if (cmd == null || cmd.equals("")) {
throw new FuzzException("cmd is null ! The number of parameters does not match!"); throw new FuzzException("cmd is null ! The number of parameters does not match!");
......
...@@ -2,21 +2,17 @@ package com.example.fuzzControll.service.impl; ...@@ -2,21 +2,17 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.AflnetProperties; import com.example.fuzzControll.conf.AflnetProperties;
import com.example.fuzzControll.constents.CmdConstent; import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.FileException; import com.example.fuzzControll.exception.fileExcption.FileException;
import com.example.fuzzControll.exception.LockException;
import com.example.fuzzControll.service.SeedFileService; import com.example.fuzzControll.service.SeedFileService;
import com.example.fuzzControll.tools.CmdTools; import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.FileTools; import com.example.fuzzControll.tools.file.FileTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.ReentrantLock;
@Slf4j @Slf4j
@Service @Service
......
package com.example.fuzzControll.service.impl; package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.annotion.NeedCutBefore;
import com.example.fuzzControll.conf.AflnetProperties; import com.example.fuzzControll.conf.AflnetProperties;
import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.CmdConstent; import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.exception.AflnetException; import com.example.fuzzControll.exception.testException.AflnetException;
import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.pojo.vo.CmdStartParams; import com.example.fuzzControll.domain.bo.CmdStartParams;
import com.example.fuzzControll.service.AflnetPersistenceService; import com.example.fuzzControll.service.AflnetPersistenceService;
import com.example.fuzzControll.service.TestService; import com.example.fuzzControll.service.TestService;
import com.example.fuzzControll.tools.CmdTools; import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.GlobalParameters; import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.tools.TestControlTools; import com.example.fuzzControll.tools.test.TestControlTools;
import com.example.fuzzControll.tools.system.SystemRunningParams;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -20,14 +20,13 @@ import java.text.DateFormat; ...@@ -20,14 +20,13 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.CountDownLatch;
@Service("testService") @Service("testService")
@Slf4j @Slf4j
public class TestServiceImpl implements TestService { public class TestServiceImpl implements TestService {
@Autowired @Autowired
CmdTools cmdTools ; CmdTools cmdTools;
@Autowired @Autowired
AflnetPersistenceService aflnetPersistenceService; AflnetPersistenceService aflnetPersistenceService;
...@@ -37,55 +36,25 @@ public class TestServiceImpl implements TestService { ...@@ -37,55 +36,25 @@ public class TestServiceImpl implements TestService {
//todo 不同服务不同端口 //todo 不同服务不同端口
@Override @Override
public void testStart(CmdStartParams cmdStartParams) throws AflnetException, CmdException { public void testStart(CmdStartParams cmdStartParams) throws AflnetException, CmdException {
/*拼接指令*/
TestControlTools.setIsRunning(true); TestControlTools.setIsRunning(true);
String cmd = cmdTools.parse(cmdStartParams); String cmd = cmdTools.parse(cmdStartParams);
Date date = new Date(); Date date = new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss-"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss-");
String outputFileName = df.format(date) + cmdStartParams.getProtopcol() + "-output"; String outputFileName = df.format(date) + cmdStartParams.getProtopcol() + "-output";
String finalCmd = CmdConstent.RUN_AFLNET_BEFORE + outputFileName + CmdConstent.RUN_AFLNET_AFTER + cmd + aflnetProperties.getAflnetPath() + "live555/testProgs/" + "testOnDemandRTSPServer 8554"; String finalCmd = CmdConstent.RUN_AFLNET_BEFORE + outputFileName + CmdConstent.RUN_AFLNET_AFTER + cmd + aflnetProperties.getAflnetPath() + "live555/testProgs/" + "testOnDemandRTSPServer 8554";
GlobalParameters.aflnetData.put("aflnetName", outputFileName); SystemRunningParams.aflnetData.put("aflnetName", outputFileName);
log.info("The cmd is [{}]", finalCmd); log.info("The cmd is [{}]", finalCmd);
/*执行指令*/
System.out.println("testStart");
cmdTools.runProgramCmd(finalCmd, outputFileName + ".zip"); cmdTools.runProgramCmd(finalCmd, outputFileName + ".zip");
} }
@Override @Override
@NeedCutBefore(name = "aflnet", function = "stopBackup")//停止时完成数据入库
public void testStop() { public void testStop() {
TestControlTools.setIsRunning(false); TestControlTools.setIsRunning(false);//指令终止 todo 后期需要考虑,发送终止指令停止测试
GlobalParameters.testTimeMessage.get("aflnet").put("end",System.currentTimeMillis()); SystemRunningParams.testTimeMessage.get("aflnet").put("end", System.currentTimeMillis());//指令停止时间
log.info("Aflnet has been stopped ! "); log.info("Aflnet has been stopped ! ");
try {
new Thread(new Runnable() {
@Override
public void run() {
int flag = 0;
String fileName = GlobalParameters.aflnetData.get("aflnetName");
String fileZipName = fileName + ".zip";
cmdTools.runCmd(CmdConstent.RUN_ZIP_FILE + fileZipName + " " + fileName, "zip file in testStart");
List<String> files = cmdTools.runCmd(CmdConstent.GET_FILE_NAME + aflnetProperties.getOutputPath(), "getSeedFiles");
files.stream().forEach(System.out::println);
if (!files.contains(fileZipName)) {
log.error("File zip error!");
}
while (files.contains(fileZipName) && flag == 0) {//当前存在压缩包才存入
flag = aflnetPersistenceService.aflnetResultBackup(fileZipName, GlobalParameters.aflnetData.get("missionName"), 1, 0,
GlobalParameters.testTimeMessage.get("aflnet").get("end")-GlobalParameters.testTimeMessage.get("aflnet").get("start"));
}
/*清除生成的文件*/
try {
cmdTools.runCmd(CmdConstent.DELETE_FILE + fileName, "delete file");
cmdTools.runCmd(CmdConstent.DELETE_FILE + fileZipName, "delete zipFile");
} catch (CmdException e) {
e.printStackTrace();
log.error("file delete failed!");
}
log.info("Aflnet Logs has been backuped!");
}
}).start();
} catch (Exception e) {
log.error("AflnetBackup Error!");
e.printStackTrace();
}
} }
} }
package com.example.fuzzControll.service.impl; package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.FuzzException; import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.service.VulnerabilityTypeService; import com.example.fuzzControll.service.VulnerabilityTypeService;
import com.example.fuzzControll.tools.CmdTools; import com.example.fuzzControll.tools.test.CmdTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
......
package com.example.fuzzControll.tools;
//todo 对ip等增加正则判断
public class RegularTools {
}
package com.example.fuzzControll.tools; package com.example.fuzzControll.tools.file;
import com.example.fuzzControll.conf.AflnetProperties; import com.example.fuzzControll.conf.AflnetProperties;
import com.example.fuzzControll.conf.SpringContextUtil; import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.exception.FileException; import com.example.fuzzControll.exception.fileExcption.FileException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
@Slf4j @Slf4j
...@@ -82,6 +78,4 @@ public class FileTools { ...@@ -82,6 +78,4 @@ public class FileTools {
throw new FileException("Load file failed!"); throw new FileException("Load file failed!");
} }
} }
} }
package com.example.fuzzControll.tools; package com.example.fuzzControll.tools.system;
import com.example.fuzzControll.conf.AflnetProperties; import com.example.fuzzControll.conf.AflnetProperties;
import com.example.fuzzControll.conf.KittyProperties; import com.example.fuzzControll.conf.KittyProperties;
...@@ -10,20 +10,14 @@ import com.example.fuzzControll.service.KittyFuzzPersistenceService; ...@@ -10,20 +10,14 @@ import com.example.fuzzControll.service.KittyFuzzPersistenceService;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class GlobalParameters { /**
public static ConcurrentHashMap<String, String> aflnetData = new ConcurrentHashMap<>();//当前aflnet任务的数据 * 系统类全局参数,负责代码调用
*/
public class GlobalClass {
public static KittyMapper kittyMapper = (KittyMapper) SpringContextUtil.getBean("KittyMapper"); public static KittyMapper kittyMapper = (KittyMapper) SpringContextUtil.getBean("KittyMapper");
public static KittyProperties kittyProperties = (KittyProperties) SpringContextUtil.getBean("kittyProperties"); public static KittyProperties kittyProperties = (KittyProperties) SpringContextUtil.getBean("kittyProperties");
public static KittyFuzzPersistenceService kittyFuzzPersistenceService =(KittyFuzzPersistenceService) SpringContextUtil.getBean("KittyFuzzPersistenceService"); public static KittyFuzzPersistenceService kittyFuzzPersistenceService =(KittyFuzzPersistenceService) SpringContextUtil.getBean("KittyFuzzPersistenceService");
public static AflnetProperties aflnetProperties = (AflnetProperties) SpringContextUtil.getBean("AflnetProperties"); public static AflnetProperties aflnetProperties = (AflnetProperties) SpringContextUtil.getBean("AflnetProperties");
public static AflnetPersistenceService aflnetPersistenceService = (AflnetPersistenceService) SpringContextUtil.getBean("AflnetPersistenceService"); public static AflnetPersistenceService aflnetPersistenceService = (AflnetPersistenceService) SpringContextUtil.getBean("AflnetPersistenceService");
public static MissionInfoMapper missionInfoMapper = (MissionInfoMapper) SpringContextUtil.getBean("MissionInfoMapper"); public static MissionInfoMapper missionInfoMapper = (MissionInfoMapper) SpringContextUtil.getBean("MissionInfoMapper");
/**
* 系统全局测试时间参数
*/
public static ConcurrentHashMap<String, ConcurrentHashMap<String,Long>> testTimeMessage = new ConcurrentHashMap<>();
/**
* 多线程异常控制
*/
public static ConcurrentHashMap<Thread, String> ThreadState = new ConcurrentHashMap<>();
} }
package com.example.fuzzControll.tools.system;
import java.util.concurrent.ConcurrentHashMap;
/**
* 系统运行时,全局参数
*/
public class SystemRunningParams {
/**
* 系统全局测试时间参数
*/
public static ConcurrentHashMap<String, ConcurrentHashMap<String, Long>> testTimeMessage = new ConcurrentHashMap<>();
/**
* 多线程异常控制
*/
public static ConcurrentHashMap<Thread, String> ThreadState = new ConcurrentHashMap<>();
/**
* 系统中运行的aflnet当前missionId
*/
public static int aflnetMissionId = 0;
/**
* aflnet运行时数据
*/
public static ConcurrentHashMap<String, String> aflnetData = new ConcurrentHashMap<>();//当前aflnet任务的数据
public static void init(){
/*初始化aflnet和kitty时间参数*/
testTimeMessage.put("aflnet",new ConcurrentHashMap<>());
testTimeMessage.put("kitty",new ConcurrentHashMap<>());
/*初始化两个测试的起止时间*/
testTimeMessage.get("aflnet").put("start", 0L);
testTimeMessage.get("aflnet").put("end", 0L);
testTimeMessage.get("kitty").put("start", 0L);
testTimeMessage.get("kitty").put("end", 0L);
}
}
package com.example.fuzzControll.tools; package com.example.fuzzControll.tools.test;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.example.fuzzControll.annotion.NeedCut; import com.example.fuzzControll.annotion.NeedCutBefore;
import com.example.fuzzControll.conf.AflnetProperties; import com.example.fuzzControll.domain.bo.CmdStartParams;
import com.example.fuzzControll.conf.SpringContextUtil; import com.example.fuzzControll.domain.vo.KittyResult;
import com.example.fuzzControll.constents.CmdConstent; import com.example.fuzzControll.domain.vo.TestReturnEntity;
import com.example.fuzzControll.constents.TableClassEnum; import com.example.fuzzControll.exception.testException.AflnetException;
import com.example.fuzzControll.exception.AflnetException; import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.mysqlException.MysqlException;
import com.example.fuzzControll.exception.MysqlException;
import com.example.fuzzControll.mapper.KittyMapper;
import com.example.fuzzControll.pojo.vo.*;
import com.example.fuzzControll.service.AflnetPersistenceService;
import com.example.fuzzControll.service.impl.websocketClientServiceImpl; import com.example.fuzzControll.service.impl.websocketClientServiceImpl;
import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.tools.system.SystemRunningParams;
import com.example.fuzzControll.tools.test.TestControlTools;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.swing.*;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.bouncycastle.asn1.x500.style.RFC4519Style.l;
//todo need modify //todo need modify
@Slf4j @Slf4j
...@@ -57,10 +58,11 @@ public class CmdTools { ...@@ -57,10 +58,11 @@ public class CmdTools {
* 运行需要后台运行cmd * 运行需要后台运行cmd
* 通过websocket返回数据 * 通过websocket返回数据
*/ */
@NeedCut(name ="aflnet",moment = "before",function = "backup") @NeedCutBefore(name ="aflnet",function = "startBackup")
public void runProgramCmd(String cmd, String outputFileName) throws AflnetException { public void runProgramCmd(String cmd, String outputFileName) throws AflnetException {
try { try {
Process process = Runtime.getRuntime().exec(cmd); Process process = Runtime.getRuntime().exec(cmd);//执行模糊测试指令
/*打印模糊测试输出*/
printMessageToWeb(process.getInputStream()); printMessageToWeb(process.getInputStream());
printMessage(process.getErrorStream(), new ArrayList<String>()); printMessage(process.getErrorStream(), new ArrayList<String>());
process.waitFor(); process.waitFor();
...@@ -80,7 +82,7 @@ public class CmdTools { ...@@ -80,7 +82,7 @@ public class CmdTools {
List<String> out = Collections.synchronizedList(new ArrayList<String>()); List<String> out = Collections.synchronizedList(new ArrayList<String>());
List<String> error = Collections.synchronizedList(new ArrayList<String>()); List<String> error = Collections.synchronizedList(new ArrayList<String>());
try { try {
GlobalParameters.testTimeMessage.get("kitty").put("start",System.currentTimeMillis()); SystemRunningParams.testTimeMessage.get("kitty").put("start",System.currentTimeMillis());
Process process = Runtime.getRuntime().exec(cmd); Process process = Runtime.getRuntime().exec(cmd);
printMessageByProgramCmd(process.getInputStream(), out); printMessageByProgramCmd(process.getInputStream(), out);
printMessageByProgramCmd(process.getErrorStream(), error); printMessageByProgramCmd(process.getErrorStream(), error);
...@@ -97,7 +99,7 @@ public class CmdTools { ...@@ -97,7 +99,7 @@ public class CmdTools {
/*新开一个线程存入数据*/ /*新开一个线程存入数据*/
List<String> finalOut = out; List<String> finalOut = out;
List<String> finalError = error; List<String> finalError = error;
GlobalParameters.testTimeMessage.get("kitty").put("end",System.currentTimeMillis()); SystemRunningParams.testTimeMessage.get("kitty").put("end",System.currentTimeMillis());
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -128,6 +130,12 @@ public class CmdTools { ...@@ -128,6 +130,12 @@ public class CmdTools {
return result; return result;
} }
/**
* 错误输出
* @param input
* @param result
* @return
*/
private List<String> printMessage(final InputStream input, final List<String> result) { private List<String> printMessage(final InputStream input, final List<String> result) {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
...@@ -166,6 +174,12 @@ public class CmdTools { ...@@ -166,6 +174,12 @@ public class CmdTools {
} }
} }
/**
* aflnet模糊测试数据键值对返回
* @param line
* @param returnEntity
* @return
*/
private TestReturnEntity makeReturnEntity(String line, TestReturnEntity returnEntity) { private TestReturnEntity makeReturnEntity(String line, TestReturnEntity returnEntity) {
if (line.contains("All set and ready to roll!") || line.contains("american fuzzy") || line.contains("process timing overall results")) { if (line.contains("All set and ready to roll!") || line.contains("american fuzzy") || line.contains("process timing overall results")) {
show = false; show = false;
...@@ -176,7 +190,8 @@ public class CmdTools { ...@@ -176,7 +190,8 @@ public class CmdTools {
if (show) { if (show) {
log.info(line); log.info(line);
} }
GlobalParameters.testTimeMessage.get("aflnet").put("start",System.currentTimeMillis()); SystemRunningParams.testTimeMessage.get("aflnet").put("start", System.currentTimeMillis());
try {
if (line.contains("run time")) { if (line.contains("run time")) {
send = false; send = false;
int run_time = line.indexOf(":"); int run_time = line.indexOf(":");
...@@ -263,6 +278,10 @@ public class CmdTools { ...@@ -263,6 +278,10 @@ public class CmdTools {
int trim = line.indexOf(":"); int trim = line.indexOf(":");
returnEntity.setTrim(line.substring(trim + 1, trim + 10)); returnEntity.setTrim(line.substring(trim + 1, trim + 10));
} }
} catch (Exception e) {
log.error("Formarting params error!");
throw new AflnetException("Formarting params error!");
}
return returnEntity; return returnEntity;
} }
...@@ -312,22 +331,22 @@ public class CmdTools { ...@@ -312,22 +331,22 @@ public class CmdTools {
@Transactional(rollbackFor = MysqlException.class) @Transactional(rollbackFor = MysqlException.class)
public void dataBackUpTransaction(String caller, List<String> out, List<String> error, String missionName) { public void dataBackUpTransaction(String caller, List<String> out, List<String> error, String missionName) {
int missionId = GlobalParameters.missionInfoMapper.selectTopMissionId() + 1; int missionId = GlobalClass.missionInfoMapper.selectTopMissionId() + 1;
try { try {
/*kitty结果存入数据库*/ /*kitty结果存入数据库*/
KittyResult kittyResult = new KittyResult(missionId, out.toString(), error.toString()); KittyResult kittyResult = new KittyResult(missionId, out.toString(), error.toString());
GlobalParameters.kittyMapper.kittyResultsBackup(kittyResult); GlobalClass.kittyMapper.kittyResultsBackup(kittyResult);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.error("kitty backup error!"); log.error("kitty backup error!");
} }
// /*kitty的协议模板方法的日志和数据包文件存入数据库*/ // /*kitty的协议模板方法的日志和数据包文件存入数据库*/
// if (caller.equals("protocolTemplate")) { // if (caller.equals("protocolTemplate")) {
//// GlobalParameters.kittyFuzzPersistenceService.KittyPackagesBackup(missionId); //// GlobalClass.kittyFuzzPersistenceService.KittyPackagesBackup(missionId);
// GlobalParameters.missionInfoMapper.insertMission(new MissionInfo(missionId, 2, new Date(), missionName,)); // GlobalClass.missionInfoMapper.insertMission(new MissionInfo(missionId, 2, new Date(), missionName,));
// } else { // } else {
// /*存入missionInfo信息*/ // /*存入missionInfo信息*/
// GlobalParameters.missionInfoMapper.insertMission(new MissionInfo(missionId, 3, new Date(), missionName)); // GlobalClass.missionInfoMapper.insertMission(new MissionInfo(missionId, 3, new Date(), missionName));
// } // }
} }
} }
\ No newline at end of file
package com.example.fuzzControll.tools.test;
import com.example.fuzzControll.exception.testException.CmdException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Component
public class SingleCmdTools {
public List<String> runCmd(String cmd, String caller) throws CmdException {
List<String> result = new ArrayList<String>();
try {
log.info(caller + " is running!");
Process process = Runtime.getRuntime().exec(cmd);
printMessage(process.getInputStream(), result);
printMessage(process.getErrorStream(), new ArrayList<String>());
process.waitFor();
log.info(caller + " end!");
} catch (Exception e) {
e.printStackTrace();
throw new CmdException(caller + " run cmd failed!");
}
return result;
}
private List<String> printMessage(final InputStream input, final List<String> result) {
new Thread(new Runnable() {
@Override
public void run() {
Reader reader = new InputStreamReader(input);
BufferedReader bf = new BufferedReader(reader);
String line = null;
try {
while ((line = bf.readLine()) != null) {
result.add(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
return result;
}
}
package com.example.fuzzControll.tools; package com.example.fuzzControll.tools.test;
public class TestControlTools { public class TestControlTools {
private static Boolean isRunning; private static Boolean isRunning;
......
package com.example.fuzzControll.tools; package com.example.fuzzControll.tools.test;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
...@@ -41,7 +41,7 @@ spring: ...@@ -41,7 +41,7 @@ spring:
discovery: discovery:
server-addr: http://${nacos-docker.ip}:8848 server-addr: http://${nacos-docker.ip}:8848
datasource: datasource:
url: jdbc:mysql://${mysql-docker.ip}:3306/fuzz?allowPublicKeyRetrieval=true&useSSL=falseuseUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://${mysql-docker.ip}:3307/fuzz?allowPublicKeyRetrieval=true&useSSL=falseuseUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: 123456 password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.fuzzControll.mapper.AflnetMapper"> <mapper namespace="com.example.fuzzControll.mapper.AflnetMapper">
<resultMap type="com.example.fuzzControll.pojo.vo.AflnetResult" id="AflnetResult"> <resultMap type="com.example.fuzzControll.domain.vo.AflnetResult" id="AflnetResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="missionId" column="missionId" /> <result property="missionId" column="missionId" />
<result property="file" column="file" /> <result property="file" column="file" />
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.fuzzControll.mapper.KittyMapper"> <mapper namespace="com.example.fuzzControll.mapper.KittyMapper">
<resultMap type="com.example.fuzzControll.pojo.vo.KittyResult" id="KittyResult"> <resultMap type="com.example.fuzzControll.domain.vo.KittyResult" id="KittyResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="missionId" column="missionId" /> <result property="missionId" column="missionId" />
<result property="resultOut" column="resultOut" /> <result property="resultOut" column="resultOut" />
<result property="resultError" column="resultError" /> <result property="resultError" column="resultError" />
</resultMap> </resultMap>
<resultMap type="com.example.fuzzControll.pojo.vo.KittyPackageFile" id="kittyPackageFile"> <resultMap type="com.example.fuzzControll.domain.vo.KittyPackageFile" id="kittyPackageFile">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="missionId" column="missionId" /> <result property="missionId" column="missionId" />
<result property="kittyRecvFile" column="kittyRecvFile" /> <result property="kittyRecvFile" column="kittyRecvFile" />
...@@ -35,11 +35,11 @@ ...@@ -35,11 +35,11 @@
<select id="getKittyResults" resultMap="KittyResult"> <select id="getKittyResults" resultMap="KittyResult">
<include refid="selectKittyResult"/> <include refid="selectKittyResult"/>
</select> </select>
<select id="getKittyPackageFileById" resultType="com.example.fuzzControll.pojo.vo.KittyPackageFile"> <select id="getKittyPackageFileById" resultType="com.example.fuzzControll.domain.vo.KittyPackageFile">
<include refid="selectKittyPackageFile"/> <include refid="selectKittyPackageFile"/>
where missionId=#{missionId} where missionId=#{missionId}
</select> </select>
<select id="getKittyResultByMissionId" resultType="com.example.fuzzControll.pojo.vo.KittyResult"> <select id="getKittyResultByMissionId" resultType="com.example.fuzzControll.domain.vo.KittyResult">
<include refid="selectKittyResult"/> <include refid="selectKittyResult"/>
where missionId = #{missionId} where missionId = #{missionId}
</select> </select>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.fuzzControll.mapper.MissionInfoMapper"> <mapper namespace="com.example.fuzzControll.mapper.MissionInfoMapper">
<resultMap type="com.example.fuzzControll.pojo.vo.MissionInfo" id="MissionInfoInDataBase"> <resultMap type="com.example.fuzzControll.domain.po.MissionInfo" id="MissionInfoInDataBase">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="missionId" column="missionId" /> <result property="missionId" column="missionId" />
<result property="tableId" column="tableId" /> <result property="tableId" column="tableId" />
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<result property="state" column="state" /> <result property="state" column="state" />
<result property="runTime" column="runTime" /> <result property="runTime" column="runTime" />
</resultMap> </resultMap>
<resultMap type="com.example.fuzzControll.pojo.vo.MissionInfo" id="MissionInfoInVo"> <resultMap type="com.example.fuzzControll.domain.po.MissionInfo" id="MissionInfoInVo">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="missionId" column="missionId" /> <result property="missionId" column="missionId" />
<result property="createTime" column="createTime" /> <result property="createTime" column="createTime" />
...@@ -28,6 +28,11 @@ ...@@ -28,6 +28,11 @@
insert into missionIdInfo(missionId, tableId, createTime, missionName, state, runTime) insert into missionIdInfo(missionId, tableId, createTime, missionName, state, runTime)
values (#{missionId}, #{tableId}, #{createTime}, #{missionName}, #{state}, #{runTime}) values (#{missionId}, #{tableId}, #{createTime}, #{missionName}, #{state}, #{runTime})
</insert> </insert>
<update id="updateMission">
update missionIdInfo
set state = #{state}, runTime = #{runTime}
where missionId = #{missionId}
</update>
<select id="selectByMissionId" resultMap="MissionInfoInVo"> <select id="selectByMissionId" resultMap="MissionInfoInVo">
<include refid="selectMissionInfo"/> <include refid="selectMissionInfo"/>
and missionId = #{missionId} and missionId = #{missionId}
......
...@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.io.IOException; import java.io.IOException;
@RestController @RestController
@RequestMapping("/log") @RequestMapping("/mission")
@CrossOrigin @CrossOrigin
public class MissionInfoController { public class MissionInfoController {
@Autowired @Autowired
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment