Commit 442473de by 钱炳权

测试插入、测试配置完成;但是更新数据存在问题

parent 26d2fc6e
......@@ -49,20 +49,20 @@ public class FuzzParamsController {
return AjaxResult.success(result);
}
/**
* 跟据id修改参数
*/
@RequestMapping(value = "/editParam", method = RequestMethod.POST)
public AjaxResult editById(@RequestBody FuzzParams fuzzParams) {
boolean flag = false;
try {
fuzzParams.setEditTime(new Date());
flag = fuzzParamsService.editFuzzParams(fuzzParams);
} catch (Exception e) {
log.error("Edit params with id error:{}", e.getMessage());
return AjaxResult.error();
}
return AjaxResult.success(flag);
}
// /**
// * 跟据id修改参数
// */
// @RequestMapping(value = "/editParam", method = RequestMethod.POST)
// public AjaxResult editById(@RequestBody FuzzParams fuzzParams) {
// boolean flag = false;
// try {
// fuzzParams.setEditTime(new Date());
// flag = fuzzParamsService.editFuzzParams(fuzzParams);
// } catch (Exception e) {
// log.error("Edit params with id error:{}", e.getMessage());
// return AjaxResult.error();
// }
// return AjaxResult.success(flag);
// }
}
package com.example.fuzzControll.controller.dataController;
import com.example.fuzzControll.domain.bo.CmdStartParams;
import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.domain.po.TestAndParams;
import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.service.SeedFileService;
import com.example.fuzzControll.service.TestMissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 测试信息控制栏
*/
@Slf4j
@RestController
@RequestMapping("/testmission")
public class TestMissionController {
@Autowired
TestMissionService testMissionService;
/**
* 测试信息获取
*/
@RequestMapping(value = "/getAll", method = RequestMethod.GET)
public AjaxResult getTestAndParamsList() {
List<TestAndParams> testAndParamsList = null;
try {
testAndParamsList = testMissionService.getTestAndParamsList();
} catch (Exception e) {
return AjaxResult.error();
}
return AjaxResult.success(testAndParamsList);
}
/**
* 测试信息删除
*/
@RequestMapping(value = "/deleteById", method = RequestMethod.GET)
public AjaxResult deleteById(@RequestParam int id) {
boolean flag = false;
try {
flag = testMissionService.deleteById(id);
if (!flag) {
throw new RuntimeException();
}
} catch (Exception e) {
return AjaxResult.error("删除失败!");
}
return AjaxResult.success("删除成功!");
}
/**
* 新建测试
*/
@RequestMapping(value = "/insert", method = RequestMethod.GET)
public AjaxResult insert(@RequestParam String testname) {
TestAndParams testAndParams = new TestAndParams(testname);
try {
testMissionService.insert(testAndParams);
} catch (Exception e) {
return AjaxResult.error("新建失败!");
}
return AjaxResult.success("新建成功!");
}
/**
* 给空白测试配置参数
*/
@RequestMapping(value = "/insertWithAflnet/{id}", method = RequestMethod.POST)
public AjaxResult insertParmasInTestAflnet(@PathVariable("id")int id,@RequestBody final CmdStartParams cmdStartParams) {
try {
testMissionService.insertParmasInTestAflnet(id,cmdStartParams);
} catch (Exception e) {
return AjaxResult.error("参数配置失败!");
}
return AjaxResult.success("参数配置成功!");
}
@RequestMapping(value = "/insertWithkitty/{id}", method = RequestMethod.POST)
public AjaxResult insertParmasInTestKitty(@PathVariable("id")int id,@RequestBody TestEntity testEntity) {
try {
testMissionService.insertParmasInTestKitty(id,testEntity);
} catch (Exception e) {
return AjaxResult.error("参数配置失败!");
}
return AjaxResult.success("参数配置成功!");
}
}
......@@ -15,59 +15,21 @@ import java.util.Date;
public class FuzzParams {
private int id;
private String params;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date editTime;
private int missionId;
private String protocol;
public FuzzParams() {
}
public FuzzParams(int id, String params, Date editTime, int missionId) {
public FuzzParams(int id, String params, String protocol) {
this.id = id;
this.params = params;
this.editTime = editTime;
this.missionId = missionId;
}
public FuzzParams(String params, Date editTime, int missionId) {
this.params = params;
this.editTime = editTime;
this.missionId = missionId;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getParams() {
return params;
this.protocol = protocol;
}
public void setParams(String params) {
public FuzzParams(String params, String protocol) {
this.params = params;
this.protocol = protocol;
}
public Date getEditTime() {
return editTime;
}
public void setEditTime(Date editTime) {
this.editTime = editTime;
}
public int getMissionId() {
return missionId;
}
public void setMissionId(int missionId) {
this.missionId = missionId;
}
}
package com.example.fuzzControll.domain.po;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Data
@Setter
@Getter
@AllArgsConstructor
public class Test {
private int id;
private int fuzzParamsId;
private Date createTime;
private Date updateTime;
private String missionIds;
private String testName;
public Test(Date createTime, Date updateTime, String testName) {
this.createTime = createTime;
this.updateTime = updateTime;
this.testName = testName;
}
}
package com.example.fuzzControll.domain.po;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.sql.Date;
@Data
@Setter
@Getter
@AllArgsConstructor
public class TestAndParams {
private int id;
private int fuzzParamsId;
private Date createTime;
private Date updateTime;
private String missionIds;
private String testName;
private String params;
private String protocol;
public TestAndParams(String testName) {
this.testName = testName;
}
}
......@@ -14,5 +14,7 @@ public interface FuzzParamsMapper {
List<FuzzParams> getFuzzParamsList();
FuzzParams getFuzzParamsById(int id);
boolean editFuzzParams(FuzzParams fuzzParams);
int editFuzzParams(FuzzParams fuzzParams);
void insertFuzzParamsReturnId(FuzzParams fuzzParams);
}
package com.example.fuzzControll.mapper;
import com.example.fuzzControll.domain.po.Test;
import com.example.fuzzControll.domain.po.TestAndParams;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
import java.util.List;
@Mapper
@Component("TestMapper")
public interface TestMapper {
List<TestAndParams> getTestAndParamsList();
boolean deleteById(int id);
void insert(Test test);
Test getTestById(int id);
void edit(Test test);
}
......@@ -12,5 +12,5 @@ public interface FuzzParamsService {
//todo 使用切面在运行时插入参数
boolean saveFuzzParams(FuzzParams fuzzParams);
boolean editFuzzParams(FuzzParams fuzzParams);
int editFuzzParams(FuzzParams fuzzParams);
}
package com.example.fuzzControll.service;
import com.example.fuzzControll.domain.bo.CmdStartParams;
import com.example.fuzzControll.domain.bo.FuzzParams;
import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.domain.po.Test;
import com.example.fuzzControll.domain.po.TestAndParams;
import java.util.List;
public interface TestMissionService {
List<TestAndParams> getTestAndParamsList();
boolean deleteById(int id);
void insert(TestAndParams testAndParams);
void insertParmasInTestAflnet(int id,CmdStartParams cmdStartParams);
void insertParmasInTestKitty(int id,TestEntity testEntity);
}
......@@ -19,7 +19,7 @@ public class AgentOfKittyServiceImpl implements AgentOfKittyService {
@Override
public Boolean startNetworkAgent(String networkCard, String monitorName) {
try {
String finalCmd = "python /usr/fuzzenv/fuzzenv/fuzz50/katnip/katnip/monitors/network.py " + networkCard + " " + monitorName;
String finalCmd = "python /usr/fuzzenv/fuzzenv/fuzz_50/katnip/katnip/monitors/network.py " + networkCard + " " + monitorName;
TestCmdTools cmdTools = new TestCmdTools();
List<String> result = cmdTools.runCmd(finalCmd, "startNetworkAgent");
List<String> filter = result.stream().filter(s -> s.contains("calling mon.teardown")).collect(Collectors.toList());
......@@ -34,7 +34,7 @@ public class AgentOfKittyServiceImpl implements AgentOfKittyService {
@Override
public Boolean startSshAgent(String monitorName, String sshUserName, String sshPassword, String sshIp, String sshPort, String command) {
try {
String finalCmd = "python /usr/fuzzenv/fuzzenv/fuzz50/katnip/katnip/monitors/ssh.py " + monitorName
String finalCmd = "python /usr/fuzzenv/fuzzenv/fuzz_50/katnip/katnip/monitors/ssh.py " + monitorName
+ " " + sshUserName + " " + sshPassword + " " + sshIp + " " + sshPort + " " + command;
TestCmdTools cmdTools = new TestCmdTools();
List<String> result = cmdTools.runCmd(finalCmd, "startSshAgent");
......
......@@ -47,7 +47,7 @@ public class FuzzParamsServiceImpl implements FuzzParamsService {
}
@Override
public boolean editFuzzParams(FuzzParams fuzzParams) {
public int editFuzzParams(FuzzParams fuzzParams) {
return fuzzParamsMapper.editFuzzParams(fuzzParams);
}
}
......@@ -34,11 +34,11 @@ public class GenerateMethodServiceImpl implements GenerateMethodService {
@NeedCutAround(name ="kitty",function = "generation")
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException {
/*存入参数*/
int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
boolean flag = fuzzParamsService.saveFuzzParams(new FuzzParams(JSON.toJSONString(testEntity.getParamJson()), new Date(), missionId));
if (!flag) {
throw new AflnetException("Save params error!");
}
// int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
// boolean flag = fuzzParamsService.saveFuzzParams(new FuzzParams(JSON.toJSONString(testEntity.getParamJson()), new Date(), missionId));
// if (!flag) {
// throw new AflnetException("Save params error!");
// }
/*运行指令*/
String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) {
......
......@@ -37,11 +37,11 @@ class MutationServiceImpl implements MutationService {
@NeedCutAround(name ="kitty",function = "generation")
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException {
/*存入参数*/
int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
boolean flag = fuzzParamsService.saveFuzzParams(new FuzzParams(JSON.toJSONString(testEntity.getParamJson()), new Date(), missionId));
if (!flag) {
throw new AflnetException("Save params error!");
}
// int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
// boolean flag = fuzzParamsService.saveFuzzParams(new FuzzParams(JSON.toJSONString(testEntity.getParamJson()), new Date(), missionId));
// if (!flag) {
// throw new AflnetException("Save params error!");
// }
String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) {
throw new FuzzException("cmd is null ! The number of parameters does not match!");
......
......@@ -8,12 +8,14 @@ import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.constents.ProtocolConstent;
import com.example.fuzzControll.domain.bo.FuzzParams;
import com.example.fuzzControll.domain.po.TestAndParams;
import com.example.fuzzControll.exception.testException.AflnetException;
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.FuzzParamsService;
import com.example.fuzzControll.service.ProtocolTemplateService;
import com.example.fuzzControll.service.TestMissionService;
import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.tools.test.SingleCmdTools;
import com.example.fuzzControll.tools.test.TestCmdTools;
......@@ -35,16 +37,18 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
KittyProperties kitty;
@Autowired
FuzzParamsService fuzzParamsService;
@Autowired
TestMissionService testMissionService;
@Override
@NeedCutAround(name ="kitty",function = "generation")
@NeedCutAround(name = "kitty", function = "generation")
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException {
/*存入参数*/
int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
boolean flag = fuzzParamsService.saveFuzzParams(new FuzzParams(JSON.toJSONString(testEntity.getParamJson()), new Date(), missionId));
if (!flag) {
throw new AflnetException("Save params error!");
}
// boolean flag = fuzzParamsService.saveFuzzParams(new FuzzParams(JSON.toJSONString(testEntity.getParamJson()), new Date(), missionId));
// if (!flag) {
// throw new AflnetException("Save params error!");
// }
/*生成日志前先清除日志*/
singleCmdTools.runCmd(CmdConstent.DELETE_FILE + GlobalClass.kittyProperties.getLogOutPath(), "delete kittyLogs");
String cmd = parseParameters(testEntity);
......
package com.example.fuzzControll.service.impl;
import com.alibaba.fastjson.JSON;
import com.example.fuzzControll.domain.bo.CmdStartParams;
import com.example.fuzzControll.domain.bo.FuzzParams;
import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.domain.po.Test;
import com.example.fuzzControll.domain.po.TestAndParams;
import com.example.fuzzControll.exception.mysqlException.MysqlException;
import com.example.fuzzControll.mapper.FuzzParamsMapper;
import com.example.fuzzControll.mapper.TestMapper;
import com.example.fuzzControll.service.TestMissionService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
@Service("TestMissionServiceImpl")
public class TestMissionServiceImpl implements TestMissionService {
@Autowired
TestMapper testMapper;
@Autowired
FuzzParamsMapper fuzzParamsMapper;
@Override
public List<TestAndParams> getTestAndParamsList() {
List<TestAndParams> testParamsList = new ArrayList();
try {
testParamsList = testMapper.getTestAndParamsList();
} catch (Exception e) {
log.error("Failed to get test and params list:{}", e.getMessage());
throw new RuntimeException(e);
}
if (testParamsList == null || testParamsList.size() == 0) {
log.warn("TestAndParams is null!");
}
return testParamsList;
}
@Override
public boolean deleteById(int id) {
boolean flag = false;
try {
flag = testMapper.deleteById(id);
} catch (Exception e) {
log.error("Delete error:{}", e.getMessage());
throw new RuntimeException(e);
}
return false;
}
@Override
public void insert(TestAndParams testAndParams) {
Test test = new Test(new Date(), new Date(), testAndParams.getTestName());
testMapper.insert(test);
}
@Transactional(rollbackFor = MysqlException.class)
@Override
public void insertParmasInTestAflnet(int id, CmdStartParams cmdStartParams) {
try {
/*判断test是否存有paramsId,没数据插入有数据就改变*/
Test test = testMapper.getTestById(id);
int fuzzParamsId;
if (test.getFuzzParamsId() == 0) {//为0则插入id
FuzzParams fuzzParams = new FuzzParams(JSON.toJSONString(cmdStartParams), cmdStartParams.getProtopcol());
fuzzParamsMapper.insertFuzzParamsReturnId(fuzzParams);
fuzzParamsId = fuzzParams.getId();
test.setFuzzParamsId(fuzzParamsId);
} else {//有则更新数据
FuzzParams fuzzParams = new FuzzParams(test.getId(),JSON.toJSONString(cmdStartParams), cmdStartParams.getProtopcol());
fuzzParamsMapper.editFuzzParams(fuzzParams);
}
/*更新修改时间*/
test.setUpdateTime(new Date());
testMapper.edit(test);
} catch (Exception e) {
log.error("Failed to insert:[{}]", e.getMessage());
throw new MysqlException("");
}
}
@Transactional(rollbackFor = MysqlException.class)
@Override
public void insertParmasInTestKitty(int id, TestEntity testEntity) {
/*插入fuzzparams返回id*/
/*更新对应id的测试数据*/
}
}
......@@ -49,17 +49,15 @@ public class TestServiceImpl implements TestService {
@Override
public void testStart(CmdStartParams cmdStartParams) throws AflnetException, CmdException {
/*存入参数*/
System.out.println("1111111111111111111111111111111111111111111111111111111111111111");
int missionId = GlobalClass.missionInfoMapper.selectTopMissionId() + 1;
boolean flag = false;
try {
flag = fuzzParamsService.saveFuzzParams(new FuzzParams(JSON.toJSONString(cmdStartParams), new Date(), missionId));
// flag = fuzzParamsService.saveFuzzParams(new FuzzParams(JSON.toJSONString(cmdStartParams), new Date(), missionId));
System.out.println("flag = " + flag);
} catch (Exception e) {
log.error("Save fuzz error:{}", e.getMessage());
throw new RuntimeException(e);
}
System.out.println("2222222222222222222222222222222222222222222222222222222222222222");
if (!flag) {
log.error("Save fuzzParams failed!");
throw new AflnetException("Save params error!");
......@@ -67,14 +65,12 @@ public class TestServiceImpl implements TestService {
/*拼接指令*/
TestControlTools.setIsRunning(true);
String cmd = cmdTools.parse(cmdStartParams);
System.out.println("33333333333333333333333333333333333333333333333333333333333333333");
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";
SystemRunningParams.aflnetData.put("aflnetName", outputFileName);
log.info("The cmd is [{}]", finalCmd);
System.out.println("444444444444444444444444444444444444444444444444444444444444444444");
/*执行指令*/
System.out.println("testStart");
cmdTools.runProgramCmd(finalCmd, outputFileName + ".zip");
......
......@@ -33,11 +33,11 @@ public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService {
@NeedCutAround(name ="kitty",function = "generation")
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException {
/*存入参数*/
int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
boolean flag = fuzzParamsService.saveFuzzParams(new FuzzParams(JSON.toJSONString(testEntity.getParamJson()), new Date(), missionId));
if (!flag) {
throw new AflnetException("Save params error!");
}
// int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
// boolean flag = fuzzParamsService.saveFuzzParams(new FuzzParams(JSON.toJSONString(testEntity.getParamJson()), new Date(), missionId));
// if (!flag) {
// throw new AflnetException("Save params error!");
// }
String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) {
throw new FuzzException("cmd is null ! The number of parameters does not match!");
......
......@@ -378,7 +378,7 @@ public class TestCmdTools {
}
public String parse(CmdStartParams cmdStartParams) throws AflnetException {
System.out.println("************************1111111111111111111111");
log.info("Cmd is [{}]", cmdStartParams);
System.out.println("cmd is :" + cmdStartParams);
if (cmdStartParams == null) {
throw new AflnetException("CmdStartParams is null !");
......@@ -420,7 +420,6 @@ public class TestCmdTools {
if (cmdStartParams.getSeedSelectionAlgo() != 0) {
cmd.append(" -s " + cmdStartParams.getSeedSelectionAlgo() + " ");
}
System.out.println("************************22222222222222222222222");
return cmd.toString();
}
......
......@@ -26,11 +26,11 @@ aflnet:
kitty:
logOutPath: "/home/kittylogs/"#kitty协议模板日志生成路径
path: "/usr/fuzzenv/fuzzenv/fuzz50/kitty/renix/" #kitty项目下的各协议生成模板python文件路径
venvPath: "/usr/fuzzenv/fuzzenv/fuzz50/kitty/venv/bin/python"
methodPath: "/usr/fuzzenv/fuzzenv/fuzz50/kitty/2020test/"#kitty下变异方法路径
vulnerabilityTypePath: "/usr/fuzzenv/fuzzenv/fuzz50/kitty/2020test/"#kitty下漏洞类型python路径
mutationPath: "/usr/fuzzenv/fuzzenv/fuzz50/kitty/2020test/"
path: "/usr/fuzzenv/fuzzenv/fuzz_50/kitty/renix/" #kitty项目下的各协议生成模板python文件路径
venvPath: "/usr/fuzzenv/fuzzenv/fuzz_50/venv/bin/python"
methodPath: "/usr/fuzzenv/fuzzenv/fuzz_50/kitty/2020test/"#kitty下变异方法路径
vulnerabilityTypePath: "/usr/fuzzenv/fuzzenv/fuzz_50/kitty/2020test/"#kitty下漏洞类型python路径
mutationPath: "/usr/fuzzenv/fuzzenv/fuzz_50/kitty/2020test/"
templateInfoHttp: "http://127.0.0.1:26001/api/template_info.json"#模板信息请求链接
statsHttp: "http://127.0.0.1:26001/api/stats.json"#运行时数据
stagesHttp: "http://127.0.0.1:26001/api/stages.json"#
......
......@@ -7,22 +7,37 @@
<resultMap type="com.example.fuzzControll.domain.bo.FuzzParams" id="fuzzParams">
<result property="id" column="id" />
<result property="params" column="params" />
<result property="editTime" column="editTime" />
<result property="missionId" column="missionId" />
<result property="protocol" column="protocol" />
</resultMap>
<sql id="selectFuzzParams">
select id, params,editTime,missionId from fuzz_params
select id, params,protocol from fuzz_params
</sql>
<insert id="saveFuzzParams">
insert into fuzz_params(id, params,editTime,missionId) values(#{id}, #{params},#{editTime},#{missionId})
<insert id="saveFuzzParams" >
insert into fuzz_params(id, params,protocol) values(#{id}, #{params},#{protocol})
</insert>
<update id="editFuzzParams">
update fuzz_params set params = #{params} ,editTime = #{editTime} where missionId = #{missionId}
<insert id="insertFuzzParamsReturnId" >
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert INTO fuzz_params (params, protocol)
values (#{params}, #{protocol})
</insert>
<update id="editFuzzParams" parameterType="com.example.fuzzControll.domain.bo.FuzzParams">
update fuzz_params
set id = #{id} , params = #{params} ,protocol = #{protocol}
where id = #{id}
<!-- update fuzz_params-->
<!-- <trim prefix="SET" suffixOverrides=",">-->
<!-- <if test="id != null">id = #{id},</if>-->
<!-- <if test="params != null">params = #{params},</if>-->
<!-- <if test="protocol != null">protocol = #{protocol},</if>-->
<!-- </trim>-->
<!-- where id = #{id}-->
</update>
<select id="getFuzzParamsById" resultMap="fuzzParams">
<include refid="selectFuzzParams"/>
where missionId = #{missionId}
whereid = #{id}
</select>
<select id="getFuzzParamsList" resultMap="fuzzParams">
<include refid="selectFuzzParams"/>
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.fuzzControll.mapper.TestMapper">
<resultMap type="com.example.fuzzControll.domain.po.Test" id="test">
<result property="id" column="id" />
<result property="fuzzParamsId" column="fuzzParamsId" />
<result property="createTime" column="createTime" />
<result property="updateTime" column="updateTime" />
<result property="missionIds" column="missionIds" />
<result property="testName" column="testName" />
</resultMap>
<sql id="selectAll">
select id, fuzzParamsId,createTime,updateTime,missionIds,testName from test
</sql>
<insert id="insert">
insert into test (fuzzParamsId, createTime, updateTime,missionIds,testName)
values (#{fuzzParamsId},#{createTime},#{updateTime},#{missionIds},#{testName})
</insert>
<update id="edit">
update test
set fuzzParamsId = #{fuzzParamsId}, updateTime = #{updateTime}
where id = #{id}
</update>
<delete id="deleteById">
DELETE
t1, t2
FROM test t1
INNER JOIN fuzz_params t2 ON t1.fuzzParamsId = t2.id
WHERE t1.id = #{id};
</delete>
<select id="getTestAndParamsList" resultType="com.example.fuzzControll.domain.po.TestAndParams">
select test.id, fuzzParamsId,createTime,updateTime,missionIds,testName,params,protocol from test,fuzz_params
where test.fuzzParamsId = fuzz_params.id
</select>
<select id="getTestById" resultType="com.example.fuzzControll.domain.po.Test">
<include refid="selectAll"/>
where id = #{id}
</select>
</mapper>
\ No newline at end of file
package com.example.fuzzbackendmaster.controller;
import com.example.fuzzbackendmaster.pojo.vo.AjaxResult;
import com.example.fuzzbackendmaster.pojo.vo.CmdStartParams;
import com.example.fuzzbackendmaster.pojo.vo.TestEntity;
import com.example.fuzzbackendmaster.service.FuzzIntegrationFileApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController
@RequestMapping("/testmission")
@CrossOrigin
public class TestMissionController {
@Autowired
FuzzIntegrationFileApi fuzzIntegrationFileApi;
/**
* 获取全部测试信息
*/
@RequestMapping(value = "/getAll", method = RequestMethod.GET)
public AjaxResult getAll() {
return fuzzIntegrationFileApi.getTestAndParamsList();
}
/**
* 跟据id删除测试信息
*/
@RequestMapping(value = "/deleteById", method = RequestMethod.GET)
public AjaxResult deleteById(@RequestParam int id) {
return fuzzIntegrationFileApi.deleteById(id);
}
/**
* 新建测试,由测试名新建空白测试
*/
@RequestMapping(value = "/insert", method = RequestMethod.GET)
public AjaxResult insertTest(@RequestParam String testname) {
return fuzzIntegrationFileApi.insert(testname);
}
/**
* 给aflent相关测试配置参数
*/
@RequestMapping(value = "/insertWithAflnet/{id}", method = RequestMethod.POST)
public AjaxResult insertParmasInTestAflnet(@PathVariable("id") int id, @RequestBody final CmdStartParams cmdStartParams) {
return fuzzIntegrationFileApi.insertParmasInTestAflnet(id, cmdStartParams);
}
/**
* 给kitty相关测试配置参数
*/
@RequestMapping(value = "/insertWithkitty/{id}", method = RequestMethod.POST)
public AjaxResult insertParmasInTestKitty(@PathVariable("id") int id, @RequestBody TestEntity testEntity) {
return fuzzIntegrationFileApi.insertParmasInTestKitty(id, testEntity);
}
}
......@@ -137,13 +137,14 @@ public interface FuzzIntegrationFileApi {
* 异常重放分析
*/
@RequestMapping(value = "/aflnet/analyse", method = RequestMethod.GET)
AjaxResult analyse(@RequestParam String codePath,@RequestParam String programName);
AjaxResult analyse(@RequestParam String codePath, @RequestParam String programName);
/**
* 获取异常分析结果
*/
@RequestMapping(value = "/aflnet/getreplayresult", method = RequestMethod.GET)
AjaxResult getReplayResult();
/**
* 异常重放
*/
......@@ -151,4 +152,29 @@ public interface FuzzIntegrationFileApi {
AjaxResult replay(@RequestParam String targetServer, @RequestParam String targetServerCodePath,
@RequestParam String targetServerPort, @RequestParam String protocol,
@RequestParam String pathToCrash);
/**
* 查询测试信息(测试是任务的概念)
*/
@RequestMapping(value = "/testmission/getAll", method = RequestMethod.GET)
AjaxResult getTestAndParamsList();
/**
* 跟据id删除测试
*/
@RequestMapping(value = "/testmission/deleteById", method = RequestMethod.GET)
AjaxResult deleteById(int id);
/**
* 插入空白测试信息
*/
@RequestMapping(value = "/testmission/insert", method = RequestMethod.GET)
AjaxResult insert(@RequestParam String testname);
/**
* 给配置信息配置参数
*/
@RequestMapping(value = "/testmission/insertWithAflnet/{id}", method = RequestMethod.POST)
AjaxResult insertParmasInTestAflnet(@PathVariable("id")int id,@RequestBody final CmdStartParams cmdStartParams);
@RequestMapping(value = "/testmission/insertWithkitty/{id}", method = RequestMethod.POST)
AjaxResult insertParmasInTestKitty(@PathVariable("id")int id,@RequestBody TestEntity testEntity);
}
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