Commit 267c45e2 by 钱炳权

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

parent deacd8b0
......@@ -3,13 +3,12 @@ package com.example.fuzzControll.annotion;
import java.lang.annotation.*;
/**
* 切片标识注解
* 方法后置处理
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface NeedCut {
public @interface NeedCutAfter {
String name() default "";
String moment() 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;
import com.example.fuzzControll.annotion.NeedCut;
import com.example.fuzzControll.constents.LogicDeleteEnum;
import com.example.fuzzControll.annotion.NeedCutBefore;
import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.constents.MissionStateEnum;
import com.example.fuzzControll.constents.TableClassEnum;
import com.example.fuzzControll.mapper.MissionInfoMapper;
import com.example.fuzzControll.pojo.vo.MissionInfo;
import com.example.fuzzControll.service.AflnetPersistenceService;
import com.example.fuzzControll.tools.GlobalParameters;
import com.example.fuzzControll.domain.po.MissionInfo;
import com.example.fuzzControll.exception.mysqlException.MysqlException;
import com.example.fuzzControll.exception.testException.AflnetException;
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 org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
......@@ -17,7 +20,6 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
......@@ -26,20 +28,33 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static com.example.fuzzControll.tools.system.GlobalClass.aflnetPersistenceService;
@Aspect
@Component
@Slf4j
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)")
private void cut() {
@Pointcut(value = "@annotation(com.example.fuzzControll.annotion.NeedCutBefore)")
private void aroundCut() {
}
@Before("cut()")
/**
* 用于aflnet测试相关的数据库操作
*/
@Before("beforCut()")
private void before(JoinPoint point) {
List<String> needProcess = Arrays.asList("aflnet");
/*负责获取反射对象*/
Signature signature = point.getSignature();
MethodSignature methodSignature = null;
if (!(signature instanceof MethodSignature)) {
......@@ -55,17 +70,21 @@ public class IntegrationAop implements Ordered {
e.printStackTrace();
throw new RuntimeException(e);
}
NeedCut logotype = currentMethod.getAnnotation(NeedCut.class);
if ("before".equals(logotype.moment())) {//需要进行处理
if ("aflnet".equals(logotype.name())) {//aflnet测试信息存储
int missionId = GlobalParameters.missionInfoMapper.selectTopMissionId() + 1;
GlobalParameters.missionInfoMapper.insertMission(new MissionInfo(missionId, TableClassEnum.AFLNET.getTableId(), new Date(), GlobalParameters.aflnetData.get("missionName"),
MissionStateEnum.RUNNING.getStateCode(), 0L));
}
NeedCutBefore logotype = currentMethod.getAnnotation(NeedCutBefore.class);
/*aflnet相关处理逻辑,负责数据存入*/
switch (logotype.name()) {
case "aflnet":
aflnet(logotype.function());
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 {
Signature signature = point.getSignature();
......@@ -78,7 +97,7 @@ public class IntegrationAop implements Ordered {
Object target = point.getTarget();
Method currentMethod = target.getClass().getMethod(methodSignature.getName(), methodSignature.getParameterTypes());
NeedCut logotype = currentMethod.getAnnotation(NeedCut.class);
NeedCutBefore logotype = currentMethod.getAnnotation(NeedCutBefore.class);
// if (datasource != null) {
// DataSourceContextHolder.setDataSourceType(logotype.name());
// log.debug("设置数据源为:" + datasource.name());
......@@ -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
public int getOrder() {
......
package com.example.fuzzControll.constents;
import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.tools.GlobalParameters;
import com.example.fuzzControll.tools.system.GlobalClass;
/**
* 系统内置命令
*/
public class CmdConstent {
public static final String GET_FILE_NAME = "ls -h ";
public static final String DELETE_FILE = "rm -r ";
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 RUN_AFLNET_BEFORE = "afl-fuzz -d -i " + GlobalParameters.aflnetProperties.getAflnetPath() + "aflnet/tutorials/live555/in-rtsp -o "+
GlobalParameters.aflnetProperties.getOutputPath();
public static final String RUN_AFLNET_AFTER = " -x " + GlobalParameters.aflnetProperties.getAflnetPath() + "aflnet/tutorials/live555/rtsp.dict ";
public static final String RUN_AFLNET_BEFORE = "afl-fuzz -d -i " + GlobalClass.aflnetProperties.getAflnetPath() + "aflnet/tutorials/live555/in-rtsp -o "+
GlobalClass.aflnetProperties.getOutputPath();
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_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;
/**
* 任务运行状态枚举类
*/
public enum MissionStateEnum {
DONE("done",1),
RUNNING("running",2),
......
package com.example.fuzzControll.constents;
/**
* 变异脚本路径
*/
public class MutationConstent {
public static final String TEST_GRANULARITY_BIT_BYTE = "test_granularity_bit_byte.py ";
public static final String TEST_MUTATED_LIBS = "test_mutated_libs.py ";
......
package com.example.fuzzControll.constents;
/**
* 协议模板路径
*/
public class ProtocolConstent {
public static final String ARP = "arp_raw.py ";
public static final String BGP = "bgp_tcp.py ";
......
package com.example.fuzzControll.constents;
/**
* aflnet目标服务路径
*/
public enum ServerClassEnum {
RTSP("rtsp","testOnDemandRTSPServer 8554"),
FTP("ftp","testOnDemandFTP 8554"),//error
......
package com.example.fuzzControll.constents;
/**
* 数据库表分类枚举
*/
public enum TableClassEnum {
AFLNET("alfnetResult",1),
KITTY_PACKAGE("kittyPackageFile",2),
......
package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.pojo.vo.AflnetDataParams;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.KittyResult;
import com.example.fuzzControll.domain.bo.AflnetDataParams;
import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.service.AflnetPersistenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/aflnet")
@Slf4j
......
package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.pojo.vo.AflnetDataParams;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.FuzzLogTransEntity;
import com.example.fuzzControll.domain.bo.FuzzLogTransEntity;
import com.example.fuzzControll.service.FuzzLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
......
package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.KittyDataParams;
import com.example.fuzzControll.pojo.vo.KittyResult;
import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.domain.bo.KittyDataParams;
import com.example.fuzzControll.domain.vo.KittyResult;
import com.example.fuzzControll.service.KittyFuzzPersistenceService;
import lombok.extern.slf4j.Slf4j;
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.example.fuzzControll.exception.ServerException;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.exception.serverException.ServerException;
import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.service.GetServerMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -10,8 +10,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
/**
* kitty服务器信息
*/
......
package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.mapper.MissionInfoMapper;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.FuzzLogTransEntity;
import com.example.fuzzControll.domain.vo.AjaxResult;
import lombok.extern.slf4j.Slf4j;
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.RequestMethod;
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.FileException;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.fileExcption.FileException;
import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.service.SeedFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.Arrays;
import java.util.List;
/**
......
package com.example.fuzzControll.controller;
package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.service.websocketClientService;
import lombok.extern.slf4j.Slf4j;
......@@ -7,6 +7,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* websocket 客户端
*/
@Slf4j
@RestController
@RequestMapping("/websocket")
......
package com.example.fuzzControll.controller;
package com.example.fuzzControll.controller.testController;
import com.example.fuzzControll.exception.*;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.exception.mysqlException.MysqlException;
import com.example.fuzzControll.exception.testException.AflnetException;
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.tools.GlobalParameters;
import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.tools.system.SystemRunningParams;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -29,18 +32,19 @@ public class AlfnetController {
public AjaxResult start(@RequestBody final CmdStartParams cmdStartParams) {
//todo 捕获子线程错误
try {
GlobalParameters.aflnetData.put("missionName", cmdStartParams.getProtopcol());
SystemRunningParams.aflnetData.put("missionName", cmdStartParams.getProtopcol());
Thread subThread = new Thread(new Runnable() {
@Override
public void run() {
service.testStart(cmdStartParams);
}
});
GlobalParameters.ThreadState.put(subThread,"start");
SystemRunningParams.ThreadState.put(subThread,"start");
subThread.setUncaughtExceptionHandler(new MyExceptionHandler());
subThread.start();
subThread.join();
if ("error".equals(GlobalParameters.ThreadState.get(subThread))) {
// subThread.join();
Thread.sleep(1000*10);//暂停3s,让系统运行至指令完全运行 todo跟据系统运行设定时间
if ("error".equals(SystemRunningParams.ThreadState.get(subThread))) {//使用join串行就无法停止
throw new Exception();
}
} 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.FuzzException;
import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.service.GenerateMethodService;
import com.example.fuzzControll.service.MutationService;
import com.example.fuzzControll.service.ProtocolTemplateService;
......
package com.example.fuzzControll.pojo.vo;
package com.example.fuzzControll.domain.bo;
import lombok.Data;
import lombok.Getter;
......
package com.example.fuzzControll.pojo.vo;
package com.example.fuzzControll.domain.bo;
import lombok.Data;
import lombok.Getter;
......
package com.example.fuzzControll.pojo.vo;
package com.example.fuzzControll.domain.po;
import com.fasterxml.jackson.annotation.JsonIgnore;
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;
public FileException(String defaultMessage) {
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;
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;
public ServerException(String defaultMessage) {
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;
public AflnetException(String defaultMessage) {
......
package com.example.fuzzControll.exception;
package com.example.fuzzControll.exception.testException;
import com.example.fuzzControll.exception.BaseException;
/**
* 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;
public FuzzException(String defaultMessage) {
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;
public LockException(String defaultMessage) {
super(defaultMessage, "fuzz");
......
package com.example.fuzzControll.exception;
package com.example.fuzzControll.exception.threadException;
import com.example.fuzzControll.tools.GlobalParameters;
import org.springframework.context.annotation.Bean;
import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.tools.system.SystemRunningParams;
import org.springframework.context.annotation.Configuration;
@Configuration
......@@ -10,7 +10,7 @@ public class MyExceptionHandler implements Thread.UncaughtExceptionHandler
@Override
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;
import com.example.fuzzControll.pojo.vo.AflnetResult;
import com.example.fuzzControll.pojo.vo.KittyResult;
import com.example.fuzzControll.domain.vo.AflnetResult;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
import java.util.List;
@Mapper
@Component("AflnetMapper")
public interface AflnetMapper {
......
package com.example.fuzzControll.mapper;
import com.example.fuzzControll.pojo.vo.KittyResult;
import com.example.fuzzControll.pojo.vo.KittyPackageFile;
import com.example.fuzzControll.domain.vo.KittyResult;
import com.example.fuzzControll.domain.vo.KittyPackageFile;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
......
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.springframework.stereotype.Component;
......@@ -21,4 +21,6 @@ public interface MissionInfoMapper {
int selectTopMissionId();
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;
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);
}
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;
public interface FuzzLogService {
......
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.Map;
......
package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.KittyDataParams;
import com.example.fuzzControll.pojo.vo.KittyResult;
import com.example.fuzzControll.domain.bo.KittyDataParams;
import com.example.fuzzControll.domain.vo.KittyResult;
import java.util.List;
......
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.Map;
......
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.Map;
......
package com.example.fuzzControll.service;
import com.example.fuzzControll.pojo.vo.CmdStartParams;
import java.util.concurrent.CountDownLatch;
import com.example.fuzzControll.domain.bo.CmdStartParams;
public interface TestService {
......
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.Map;
......
......@@ -2,14 +2,14 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.AflnetProperties;
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.MissionInfoMapper;
import com.example.fuzzControll.pojo.vo.AflnetResult;
import com.example.fuzzControll.pojo.vo.KittyResult;
import com.example.fuzzControll.pojo.vo.MissionInfo;
import com.example.fuzzControll.domain.vo.AflnetResult;
import com.example.fuzzControll.domain.po.MissionInfo;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -29,8 +29,8 @@ public class AflnetPersistenceServiceImpl implements AflnetPersistenceService {
FileTools fileTools = new FileTools();
@Override
public int aflnetResultBackup(String filename, String missionName,int state,int logicDelete,Long runTime) {
return mysqlTransaction(filename, missionName,state,logicDelete,runTime);
public int aflnetResultBackup(String filename, int state, Long runTime) {
return mysqlTransaction(filename, state, runTime);
}
@Override
......@@ -46,11 +46,11 @@ public class AflnetPersistenceServiceImpl implements AflnetPersistenceService {
}
@Transactional(rollbackFor = MysqlException.class)
public int mysqlTransaction(String filename, String missionName,int state,int logicDelete,Long runTime) {
int topMissionId = missionInfoMapper.selectTopMissionId() + 1;//获取最新的missionId
AflnetResult result = new AflnetResult(topMissionId, fileTools.fileReadAndTranstoBytes(aflnetProperties.getOutputPath(), filename), filename);
public int mysqlTransaction(String filename, int state, Long runTime) {
int aflnetMissionId = SystemRunningParams.aflnetMissionId;//获取系统正在操作的aflnet的missionId
AflnetResult result = new AflnetResult(aflnetMissionId, fileTools.fileReadAndTranstoBytes(aflnetProperties.getOutputPath(), filename), filename);
aflnetMapper.aflnetOutputBackup(result);//存入日志文件
missionInfoMapper.insertMission(new MissionInfo(topMissionId, TableClassEnum.AFLNET.getTableId(), new Date(), missionName, state, runTime));//插入任务信息
missionInfoMapper.updateMission(state,runTime,aflnetMissionId);//更新该次任务的执行时间
return 1;
}
}
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.KittyMapper;
import com.example.fuzzControll.mapper.MissionInfoMapper;
import com.example.fuzzControll.pojo.vo.*;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
......
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.service.GenerateMethodService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.TestTools;
import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.test.TestTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......
package com.example.fuzzControll.service.impl;
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 lombok.extern.slf4j.Slf4j;
import org.apache.http.client.methods.CloseableHttpResponse;
......
......@@ -2,14 +2,14 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties;
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.pojo.vo.KittyDataParams;
import com.example.fuzzControll.pojo.vo.KittyResult;
import com.example.fuzzControll.pojo.vo.KittyPackageFile;
import com.example.fuzzControll.domain.bo.KittyDataParams;
import com.example.fuzzControll.domain.vo.KittyResult;
import com.example.fuzzControll.domain.vo.KittyPackageFile;
import com.example.fuzzControll.service.KittyFuzzPersistenceService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.FileTools;
import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.file.FileTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......
......@@ -2,12 +2,12 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.MutationConstent;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.service.MutationService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.TestTools;
import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.test.TestTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......
......@@ -4,13 +4,13 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.constents.ProtocolConstent;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.service.ProtocolTemplateService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.GlobalParameters;
import com.example.fuzzControll.tools.TestTools;
import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.tools.test.TestTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -28,7 +28,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
@Override
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);
if (cmd == null || cmd.equals("")) {
throw new FuzzException("cmd is null ! The number of parameters does not match!");
......
......@@ -2,21 +2,17 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.AflnetProperties;
import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FileException;
import com.example.fuzzControll.exception.LockException;
import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.fileExcption.FileException;
import com.example.fuzzControll.service.SeedFileService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.FileTools;
import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.file.FileTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.ReentrantLock;
@Slf4j
@Service
......
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.annotion.NeedCutBefore;
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.exception.AflnetException;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.exception.testException.AflnetException;
import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.domain.bo.CmdStartParams;
import com.example.fuzzControll.service.AflnetPersistenceService;
import com.example.fuzzControll.service.TestService;
import com.example.fuzzControll.tools.CmdTools;
import com.example.fuzzControll.tools.GlobalParameters;
import com.example.fuzzControll.tools.TestControlTools;
import com.example.fuzzControll.tools.test.CmdTools;
import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.tools.test.TestControlTools;
import com.example.fuzzControll.tools.system.SystemRunningParams;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -20,14 +20,13 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@Service("testService")
@Slf4j
public class TestServiceImpl implements TestService {
@Autowired
CmdTools cmdTools ;
CmdTools cmdTools;
@Autowired
AflnetPersistenceService aflnetPersistenceService;
......@@ -37,55 +36,25 @@ public class TestServiceImpl implements TestService {
//todo 不同服务不同端口
@Override
public void testStart(CmdStartParams cmdStartParams) throws AflnetException, CmdException {
/*拼接指令*/
TestControlTools.setIsRunning(true);
String cmd = cmdTools.parse(cmdStartParams);
Date date = new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss-");
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";
GlobalParameters.aflnetData.put("aflnetName", outputFileName);
SystemRunningParams.aflnetData.put("aflnetName", outputFileName);
log.info("The cmd is [{}]", finalCmd);
/*执行指令*/
System.out.println("testStart");
cmdTools.runProgramCmd(finalCmd, outputFileName + ".zip");
}
@Override
@NeedCutBefore(name = "aflnet", function = "stopBackup")//停止时完成数据入库
public void testStop() {
TestControlTools.setIsRunning(false);
GlobalParameters.testTimeMessage.get("aflnet").put("end",System.currentTimeMillis());
TestControlTools.setIsRunning(false);//指令终止 todo 后期需要考虑,发送终止指令停止测试
SystemRunningParams.testTimeMessage.get("aflnet").put("end", System.currentTimeMillis());//指令停止时间
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;
import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.TestEntity;
import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.domain.bo.TestEntity;
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 org.springframework.beans.factory.annotation.Autowired;
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.SpringContextUtil;
import com.example.fuzzControll.exception.FileException;
import com.example.fuzzControll.exception.fileExcption.FileException;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@Slf4j
......@@ -82,6 +78,4 @@ public class FileTools {
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.KittyProperties;
......@@ -10,20 +10,14 @@ import com.example.fuzzControll.service.KittyFuzzPersistenceService;
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 KittyProperties kittyProperties = (KittyProperties) SpringContextUtil.getBean("kittyProperties");
public static KittyFuzzPersistenceService kittyFuzzPersistenceService =(KittyFuzzPersistenceService) SpringContextUtil.getBean("KittyFuzzPersistenceService");
public static AflnetProperties aflnetProperties = (AflnetProperties) SpringContextUtil.getBean("AflnetProperties");
public static AflnetPersistenceService aflnetPersistenceService = (AflnetPersistenceService) SpringContextUtil.getBean("AflnetPersistenceService");
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.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 {
private static Boolean isRunning;
......
package com.example.fuzzControll.tools;
package com.example.fuzzControll.tools.test;
import lombok.extern.slf4j.Slf4j;
......
......@@ -41,7 +41,7 @@ spring:
discovery:
server-addr: http://${nacos-docker.ip}:8848
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
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
......
......@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<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="missionId" column="missionId" />
<result property="file" column="file" />
......
......@@ -4,13 +4,13 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<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="missionId" column="missionId" />
<result property="resultOut" column="resultOut" />
<result property="resultError" column="resultError" />
</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="missionId" column="missionId" />
<result property="kittyRecvFile" column="kittyRecvFile" />
......@@ -35,11 +35,11 @@
<select id="getKittyResults" resultMap="KittyResult">
<include refid="selectKittyResult"/>
</select>
<select id="getKittyPackageFileById" resultType="com.example.fuzzControll.pojo.vo.KittyPackageFile">
<select id="getKittyPackageFileById" resultType="com.example.fuzzControll.domain.vo.KittyPackageFile">
<include refid="selectKittyPackageFile"/>
where missionId=#{missionId}
</select>
<select id="getKittyResultByMissionId" resultType="com.example.fuzzControll.pojo.vo.KittyResult">
<select id="getKittyResultByMissionId" resultType="com.example.fuzzControll.domain.vo.KittyResult">
<include refid="selectKittyResult"/>
where missionId = #{missionId}
</select>
......
......@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<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="missionId" column="missionId" />
<result property="tableId" column="tableId" />
......@@ -13,7 +13,7 @@
<result property="state" column="state" />
<result property="runTime" column="runTime" />
</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="missionId" column="missionId" />
<result property="createTime" column="createTime" />
......@@ -28,6 +28,11 @@
insert into missionIdInfo(missionId, tableId, createTime, missionName, state, runTime)
values (#{missionId}, #{tableId}, #{createTime}, #{missionName}, #{state}, #{runTime})
</insert>
<update id="updateMission">
update missionIdInfo
set state = #{state}, runTime = #{runTime}
where missionId = #{missionId}
</update>
<select id="selectByMissionId" resultMap="MissionInfoInVo">
<include refid="selectMissionInfo"/>
and missionId = #{missionId}
......
......@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
@RestController
@RequestMapping("/log")
@RequestMapping("/mission")
@CrossOrigin
public class MissionInfoController {
@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