Commit 3786ab39 by 钱炳权

kitty全流程贯通

parent 6c96d5bf
...@@ -71,20 +71,7 @@ public class aroundAop implements Ordered { ...@@ -71,20 +71,7 @@ public class aroundAop implements Ordered {
} }
if ("generation".equals(function)) { if ("generation".equals(function)) {
/*运行前处理*/ /*运行前处理*/
/*存入kitty启动时的任务信息*/
try {
// int missionId = GlobalClass.missionInfoMapper.selectTopMissionId() + 1;
// SystemRunningParams.kittyMissionId = missionId;
// MissionInfo missionInfo = new MissionInfo(missionId, TableClassEnum.KITTY_RESULT.getTableId(), new Date(), SystemRunningParams.kittyData.get("missionName"),
// MissionStateEnum.RUNNING.getStateCode(), 0L);
// GlobalClass.missionInfoMapper.insertMission(missionInfo);
} catch (Exception e) {
e.printStackTrace();
throw new MysqlException("Kitty start backup failed!");
}
SystemRunningParams.testTimeMessage.get("kitty").put("start", System.currentTimeMillis()); SystemRunningParams.testTimeMessage.get("kitty").put("start", System.currentTimeMillis());
System.out.println("**************1**********");
System.out.println(SystemRunningParams.testTimeMessage.get("kitty").put("start", System.currentTimeMillis()));
/*放行方法*/ /*放行方法*/
try { try {
result = point.proceed(); result = point.proceed();
......
...@@ -31,11 +31,11 @@ public class TestMissionController { ...@@ -31,11 +31,11 @@ public class TestMissionController {
@RequestMapping(value = "/startmission", method = RequestMethod.GET) @RequestMapping(value = "/startmission", method = RequestMethod.GET)
public AjaxResult startmission(@RequestParam int id) { public AjaxResult startmission(@RequestParam int id) {
try { try {
testMissionService.startMission(id); return testMissionService.startMission(id);
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error("测试启动失败!"); return AjaxResult.error("测试启动失败!");
} }
return AjaxResult.success("测试启动成功!");
} }
/** /**
* 测试信息获取 * 测试信息获取
......
...@@ -37,21 +37,6 @@ public class KittyController { ...@@ -37,21 +37,6 @@ public class KittyController {
VulnerabilityTypeService vulnerabilityTypeService; VulnerabilityTypeService vulnerabilityTypeService;
/** /**
* 模板
*/
@RequestMapping(value = "/protocolTemplate", method = RequestMethod.POST)
public AjaxResult protocolTemplate(@RequestBody TestEntity testEntity) {
try {
SystemRunningParams.kittyData.put("missionName",testEntity.getTestClassName());
Map<String, List<String>> result = protocolTemplateService.generation(testEntity);
return AjaxResult.success(result == null ? "模板文件生成未成功运行!第三方接口可能存在问题。" : result);
} catch (CmdException | FuzzException e) {
log.error(e.getDefaultMessage());
return AjaxResult.error("模板生成失败!系统存在问题。");
}
}
/**
* 生成方法 * 生成方法
*/ */
@RequestMapping(value = "/generate", method = RequestMethod.POST) @RequestMapping(value = "/generate", method = RequestMethod.POST)
......
package com.example.fuzzControll.service; package com.example.fuzzControll.service;
import com.example.fuzzControll.domain.bo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.domain.po.MissionInfo;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface ProtocolTemplateService { public interface ProtocolTemplateService {
Map<String,List<String>> generation(TestEntity testEntity); Map<String,List<String>> generation(TestEntity testEntity, MissionInfo missionInfo);
} }
...@@ -6,6 +6,7 @@ import com.example.fuzzControll.domain.bo.FuzzParams; ...@@ -6,6 +6,7 @@ import com.example.fuzzControll.domain.bo.FuzzParams;
import com.example.fuzzControll.domain.bo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.domain.po.Test; import com.example.fuzzControll.domain.po.Test;
import com.example.fuzzControll.domain.po.TestAndParams; import com.example.fuzzControll.domain.po.TestAndParams;
import com.example.fuzzControll.domain.vo.AjaxResult;
import java.util.List; import java.util.List;
...@@ -22,5 +23,5 @@ public interface TestMissionService { ...@@ -22,5 +23,5 @@ public interface TestMissionService {
boolean editTestName(String testName,int id); boolean editTestName(String testName,int id);
void startMission(int id) ; AjaxResult startMission(int id) ;
} }
...@@ -2,6 +2,7 @@ package com.example.fuzzControll.service.impl; ...@@ -2,6 +2,7 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.domain.vo.AflnetResult; import com.example.fuzzControll.domain.vo.AflnetResult;
import com.example.fuzzControll.domain.bo.FuzzLogTransEntity; import com.example.fuzzControll.domain.bo.FuzzLogTransEntity;
import com.example.fuzzControll.domain.vo.KittyPackageFile;
import com.example.fuzzControll.domain.vo.KittyResult; import com.example.fuzzControll.domain.vo.KittyResult;
import com.example.fuzzControll.domain.po.MissionInfo; import com.example.fuzzControll.domain.po.MissionInfo;
import com.example.fuzzControll.exception.mysqlException.MysqlException; import com.example.fuzzControll.exception.mysqlException.MysqlException;
...@@ -51,28 +52,28 @@ public class FuzzLogServiceImpl implements FuzzLogService { ...@@ -51,28 +52,28 @@ public class FuzzLogServiceImpl implements FuzzLogService {
public List<FuzzLogTransEntity> downloadKittyProtocalFile(MissionInfo missionInfo) { public List<FuzzLogTransEntity> downloadKittyProtocalFile(MissionInfo missionInfo) {
/*获取结果日志*/ /*获取结果日志*/
List<FuzzLogTransEntity> fuzzLogList = new ArrayList<FuzzLogTransEntity>(); List<FuzzLogTransEntity> fuzzLogList = new ArrayList<FuzzLogTransEntity>();
// KittyResult kittyResult = kittyMapper.getKittyResultByMissionId(missionInfo.getMissionId()); KittyResult kittyResult = kittyMapper.getKittyResultByMissionId(missionInfo.getId());
// StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
// buffer.append(kittyResult.getResultError()).append(System.lineSeparator()).append(kittyResult.getResultOut()); buffer.append(kittyResult.getResultError()).append(System.lineSeparator()).append(kittyResult.getResultOut());
// FuzzLogTransEntity fuzzLogTransEntity = new FuzzLogTransEntity(buffer.toString().getBytes(), missionInfo.getMissionName() + ".txt"); FuzzLogTransEntity fuzzLogTransEntity = new FuzzLogTransEntity(buffer.toString().getBytes(), missionInfo.getMissionName() + ".txt");
// fuzzLogList.add(fuzzLogTransEntity); fuzzLogList.add(fuzzLogTransEntity);
/*获取数据包文件*/ /*获取数据包文件*/
// KittyPackageFile kittyPackageFile = kittyMapper.getKittyPackageFileById(missionInfo.getMissionId()); KittyPackageFile kittyPackageFile = kittyMapper.getKittyPackageFileById(missionInfo.getId());
// FuzzLogTransEntity fuzzLogTransEntitySend = new FuzzLogTransEntity(kittyPackageFile.getKittySendFile(), kittyPackageFile.getKittyRecvFileName()); FuzzLogTransEntity fuzzLogTransEntitySend = new FuzzLogTransEntity(kittyPackageFile.getKittySendFile(), kittyPackageFile.getKittyRecvFileName());
// FuzzLogTransEntity fuzzLogTransEntityRecv = new FuzzLogTransEntity(kittyPackageFile.getKittyRecvFile(), kittyPackageFile.getKittyRecvFileName()); FuzzLogTransEntity fuzzLogTransEntityRecv = new FuzzLogTransEntity(kittyPackageFile.getKittyRecvFile(), kittyPackageFile.getKittyRecvFileName());
// fuzzLogList.add(fuzzLogTransEntitySend); fuzzLogList.add(fuzzLogTransEntitySend);
// fuzzLogList.add(fuzzLogTransEntityRecv); fuzzLogList.add(fuzzLogTransEntityRecv);
return fuzzLogList; return fuzzLogList;
} }
@Transactional(rollbackFor = MysqlException.class) @Transactional(rollbackFor = MysqlException.class)
public List<FuzzLogTransEntity> downloadKittyOtherMethodFile(MissionInfo missionInfo) { public List<FuzzLogTransEntity> downloadKittyOtherMethodFile(MissionInfo missionInfo) {
List<FuzzLogTransEntity> fuzzLogList = new ArrayList<FuzzLogTransEntity>(); List<FuzzLogTransEntity> fuzzLogList = new ArrayList<FuzzLogTransEntity>();
// KittyResult kittyResult = kittyMapper.getKittyResultByMissionId(missionInfo.getMissionId()); KittyResult kittyResult = kittyMapper.getKittyResultByMissionId(missionInfo.getId());
// StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
// buffer.append(kittyResult.getResultError()).append(System.lineSeparator()).append(kittyResult.getResultOut()); buffer.append(kittyResult.getResultError()).append(System.lineSeparator()).append(kittyResult.getResultOut());
// FuzzLogTransEntity fuzzLogTransEntity = new FuzzLogTransEntity(buffer.toString().getBytes(), missionInfo.getMissionName() + ".txt"); FuzzLogTransEntity fuzzLogTransEntity = new FuzzLogTransEntity(buffer.toString().getBytes(), missionInfo.getMissionName() + ".txt");
// fuzzLogList.add(fuzzLogTransEntity); fuzzLogList.add(fuzzLogTransEntity);
return fuzzLogList; return fuzzLogList;
} }
......
...@@ -44,7 +44,7 @@ public class GenerateMethodServiceImpl implements GenerateMethodService { ...@@ -44,7 +44,7 @@ public class GenerateMethodServiceImpl implements GenerateMethodService {
if (cmd.isEmpty()) { if (cmd.isEmpty()) {
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!");
} }
return cmdTools.runProgramCmdAndResult(cmd,"generate","Generate-"+testEntity.getTestClassName()); return null;
} }
public String parseParameters(TestEntity testEntity) { public String parseParameters(TestEntity testEntity) {
......
...@@ -46,7 +46,8 @@ class MutationServiceImpl implements MutationService { ...@@ -46,7 +46,8 @@ class MutationServiceImpl implements MutationService {
if (cmd.isEmpty()) { if (cmd.isEmpty()) {
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!");
} }
return cmdTools.runProgramCmdAndResult(cmd, "mutation", "Mutation-" + testEntity.getTestClassName()); // cmdTools.runProgramCmdAndResult(cmd, "mutation", "Mutation-" + testEntity.getTestClassName());
return null;
} }
public String parseParameters(TestEntity testEntity) { public String parseParameters(TestEntity testEntity) {
......
...@@ -6,8 +6,10 @@ import com.example.fuzzControll.annotion.NeedCutAround; ...@@ -6,8 +6,10 @@ import com.example.fuzzControll.annotion.NeedCutAround;
import com.example.fuzzControll.annotion.NeedCutBefore; import com.example.fuzzControll.annotion.NeedCutBefore;
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.MissionStateEnum;
import com.example.fuzzControll.constents.ProtocolConstent; import com.example.fuzzControll.constents.ProtocolConstent;
import com.example.fuzzControll.domain.bo.FuzzParams; import com.example.fuzzControll.domain.bo.FuzzParams;
import com.example.fuzzControll.domain.po.MissionInfo;
import com.example.fuzzControll.domain.po.TestAndParams; import com.example.fuzzControll.domain.po.TestAndParams;
import com.example.fuzzControll.exception.testException.AflnetException; import com.example.fuzzControll.exception.testException.AflnetException;
import com.example.fuzzControll.exception.testException.CmdException; import com.example.fuzzControll.exception.testException.CmdException;
...@@ -15,8 +17,8 @@ import com.example.fuzzControll.exception.testException.FuzzException; ...@@ -15,8 +17,8 @@ import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.domain.bo.TestEntity; import com.example.fuzzControll.domain.bo.TestEntity;
import com.example.fuzzControll.service.FuzzParamsService; import com.example.fuzzControll.service.FuzzParamsService;
import com.example.fuzzControll.service.ProtocolTemplateService; import com.example.fuzzControll.service.ProtocolTemplateService;
import com.example.fuzzControll.service.TestMissionService;
import com.example.fuzzControll.tools.system.GlobalClass; import com.example.fuzzControll.tools.system.GlobalClass;
import com.example.fuzzControll.tools.system.SystemRunningParams;
import com.example.fuzzControll.tools.test.SingleCmdTools; import com.example.fuzzControll.tools.test.SingleCmdTools;
import com.example.fuzzControll.tools.test.TestCmdTools; import com.example.fuzzControll.tools.test.TestCmdTools;
import com.example.fuzzControll.tools.test.TestTools; import com.example.fuzzControll.tools.test.TestTools;
...@@ -37,25 +39,28 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -37,25 +39,28 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
KittyProperties kitty; KittyProperties kitty;
@Autowired @Autowired
FuzzParamsService fuzzParamsService; FuzzParamsService fuzzParamsService;
@Autowired
TestMissionService testMissionService;
@Override @Override
@NeedCutAround(name = "kitty", function = "generation") public Map<String, List<String>> generation(TestEntity testEntity, MissionInfo missionInfo) throws FuzzException, CmdException {
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException { Long startTime = System.currentTimeMillis();
/*存入参数*/
// 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!");
// }
/*生成日志前先清除日志*/ /*生成日志前先清除日志*/
singleCmdTools.runCmd(CmdConstent.DELETE_FILE + GlobalClass.kittyProperties.getLogOutPath(), "delete kittyLogs"); singleCmdTools.runCmd(CmdConstent.DELETE_FILE + GlobalClass.kittyProperties.getLogOutPath(), "delete kittyLogs");
String cmd = parseParameters(testEntity); String cmd = parseParameters(testEntity);
if (cmd == null || "".equals(cmd)) { if (cmd == null || "".equals(cmd)) {
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!");
} }
return testCmdTools.runProgramCmdAndResult(cmd, "protocolTemplate", "ProtocolTemplate-" + testEntity.getTestClassName()); /*运行测试*/
Map<String, List<String>> result = testCmdTools.runProgramCmdAndResult(cmd, "protocolTemplate", "ProtocolTemplate-" + testEntity.getTestClassName(),missionInfo);
/*运行完成后存入运行时间等信息*/
Long total = System.currentTimeMillis() - startTime;
missionInfo.setState(MissionStateEnum.DONE.getStateCode());
missionInfo.setRunTime(total);
try {
GlobalClass.missionInfoMapper.updateMission(missionInfo);//更新该次任务的执行时间;
} catch (Exception e) {
log.error("Update mission failed:[{}]", e.getMessage());
}
return result;
} }
public String parseParameters(TestEntity testEntity) throws FuzzException { public String parseParameters(TestEntity testEntity) throws FuzzException {
......
...@@ -12,10 +12,13 @@ import com.example.fuzzControll.domain.po.Test; ...@@ -12,10 +12,13 @@ import com.example.fuzzControll.domain.po.Test;
import com.example.fuzzControll.domain.po.TestAndParams; import com.example.fuzzControll.domain.po.TestAndParams;
import com.example.fuzzControll.domain.vo.AjaxResult; import com.example.fuzzControll.domain.vo.AjaxResult;
import com.example.fuzzControll.exception.mysqlException.MysqlException; import com.example.fuzzControll.exception.mysqlException.MysqlException;
import com.example.fuzzControll.exception.testException.CmdException;
import com.example.fuzzControll.exception.testException.FuzzException;
import com.example.fuzzControll.exception.threadException.MyExceptionHandler; import com.example.fuzzControll.exception.threadException.MyExceptionHandler;
import com.example.fuzzControll.mapper.FuzzParamsMapper; import com.example.fuzzControll.mapper.FuzzParamsMapper;
import com.example.fuzzControll.mapper.MissionInfoMapper; import com.example.fuzzControll.mapper.MissionInfoMapper;
import com.example.fuzzControll.mapper.TestMapper; import com.example.fuzzControll.mapper.TestMapper;
import com.example.fuzzControll.service.ProtocolTemplateService;
import com.example.fuzzControll.service.TestMissionService; import com.example.fuzzControll.service.TestMissionService;
import com.example.fuzzControll.service.TestService; import com.example.fuzzControll.service.TestService;
import com.example.fuzzControll.tools.component.StringUtils; import com.example.fuzzControll.tools.component.StringUtils;
...@@ -42,7 +45,8 @@ public class TestMissionServiceImpl implements TestMissionService { ...@@ -42,7 +45,8 @@ public class TestMissionServiceImpl implements TestMissionService {
MissionInfoMapper missionInfoMapper; MissionInfoMapper missionInfoMapper;
@Autowired @Autowired
TestService service; TestService service;
@Autowired
ProtocolTemplateService protocolTemplateService;
@Override @Override
public List<TestAndParams> getTestAndParamsList() { public List<TestAndParams> getTestAndParamsList() {
List<TestAndParams> testParamsRelevantList = new ArrayList(); List<TestAndParams> testParamsRelevantList = new ArrayList();
...@@ -125,13 +129,13 @@ public class TestMissionServiceImpl implements TestMissionService { ...@@ -125,13 +129,13 @@ public class TestMissionServiceImpl implements TestMissionService {
Test test = testMapper.getTestById(id); Test test = testMapper.getTestById(id);
int fuzzParamsId; int fuzzParamsId;
if (test.getFuzzParamsId() == 0) {//为0则插入id if (test.getFuzzParamsId() == 0) {//为0则插入id
FuzzParams fuzzParams = new FuzzParams(JSON.toJSONString(testEntity.getParamJson()), testEntity.getTestClassName()); FuzzParams fuzzParams = new FuzzParams(JSON.toJSONString(testEntity), testEntity.getTestClassName());
fuzzParamsMapper.insertFuzzParamsReturnId(fuzzParams); fuzzParamsMapper.insertFuzzParamsReturnId(fuzzParams);
fuzzParamsId = fuzzParams.getId(); fuzzParamsId = fuzzParams.getId();
test.setFuzzParamsId(fuzzParamsId); test.setFuzzParamsId(fuzzParamsId);
} else {//有则更新数据 } else {//有则更新数据
FuzzParams fuzzParams = new FuzzParams(JSON.toJSONString(testEntity.getParamJson()), testEntity.getTestClassName()); FuzzParams fuzzParams = new FuzzParams(JSON.toJSONString(testEntity), testEntity.getTestClassName());
if (!fuzzParamsMapper.editFuzzParams(fuzzParams.getId(), fuzzParams.getParams(), fuzzParams.getProtocol())) { if (!fuzzParamsMapper.editFuzzParams(test.getFuzzParamsId(), fuzzParams.getParams(), fuzzParams.getProtocol())) {
throw new RuntimeException("EditFuzzParams failed!"); throw new RuntimeException("EditFuzzParams failed!");
} }
} }
...@@ -158,7 +162,7 @@ public class TestMissionServiceImpl implements TestMissionService { ...@@ -158,7 +162,7 @@ public class TestMissionServiceImpl implements TestMissionService {
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
@Override @Override
public void startMission(int id) { public AjaxResult startMission(int id) {
Boolean isAflnet = false; Boolean isAflnet = false;
Test test = testMapper.getTestById(id); Test test = testMapper.getTestById(id);
if (test.getFuzzParamsId() == 0) { if (test.getFuzzParamsId() == 0) {
...@@ -207,9 +211,11 @@ public class TestMissionServiceImpl implements TestMissionService { ...@@ -207,9 +211,11 @@ public class TestMissionServiceImpl implements TestMissionService {
/*运行程序*/ /*运行程序*/
try { try {
if (isAflnet) {// 启动alfnet if (isAflnet) {// 启动alfnet
aflnetMissionStart(fuzzParams,missionInfo); aflnetMissionStart(fuzzParams, missionInfo);
return AjaxResult.success("启动成功!");
} else { } else {
Map<String, List<String>> result = kittyMissionStart(fuzzParams, missionInfo);
return AjaxResult.success(result);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("Mission start error:[{}]", e.getMessage()); log.error("Mission start error:[{}]", e.getMessage());
...@@ -218,10 +224,36 @@ public class TestMissionServiceImpl implements TestMissionService { ...@@ -218,10 +224,36 @@ public class TestMissionServiceImpl implements TestMissionService {
} }
/** /**
* 启动kitty任务
*/
private Map<String, List<String>> kittyMissionStart(FuzzParams fuzzParams, MissionInfo missionInfo) {
TestEntity testEntity = (TestEntity) JSONObject.parseObject(fuzzParams.getParams(), TestEntity.class);
try {
try {
missionInfo.setState(MissionStateEnum.RUNNING.getStateCode());
missionInfoMapper.updateMission(missionInfo);
} catch (Exception e) {
log.error("Error updating mission:[{}]", e.getMessage());
throw new RuntimeException(e);
}
SystemRunningParams.kittyData.put("missionName", testEntity.getTestClassName());
Map<String, List<String>> result = protocolTemplateService.generation(testEntity,missionInfo);
if (result == null) {
log.error("模板文件生成未成功运行!第三方接口可能存在问题。");
throw new RuntimeException();
}
return result;
} catch (CmdException | FuzzException e) {
log.error("Run error:[{}]",e.getMessage());
throw new RuntimeException();
}
}
/**
* 启动aflnet任务 * 启动aflnet任务
*/ */
private void aflnetMissionStart(FuzzParams fuzzParams,MissionInfo missionInfo) { private void aflnetMissionStart(FuzzParams fuzzParams, MissionInfo missionInfo) {
CmdStartParams cmdStartParams = (CmdStartParams)JSONObject.parseObject(fuzzParams.getParams(), CmdStartParams.class); CmdStartParams cmdStartParams = (CmdStartParams) JSONObject.parseObject(fuzzParams.getParams(), CmdStartParams.class);
try { try {
SystemRunningParams.aflnetData.put("missionName", cmdStartParams.getProtopcol()); SystemRunningParams.aflnetData.put("missionName", cmdStartParams.getProtopcol());
Thread subThread = new Thread(new Runnable() { Thread subThread = new Thread(new Runnable() {
...@@ -231,10 +263,10 @@ public class TestMissionServiceImpl implements TestMissionService { ...@@ -231,10 +263,10 @@ public class TestMissionServiceImpl implements TestMissionService {
missionInfo.setState(MissionStateEnum.RUNNING.getStateCode()); missionInfo.setState(MissionStateEnum.RUNNING.getStateCode());
missionInfoMapper.updateMission(missionInfo); missionInfoMapper.updateMission(missionInfo);
} catch (Exception e) { } catch (Exception e) {
log.error("Error updating mission:[{}]",e.getMessage()); log.error("Error updating mission:[{}]", e.getMessage());
throw new RuntimeException(e); throw new RuntimeException(e);
} }
service.testStart(cmdStartParams,missionInfo); service.testStart(cmdStartParams, missionInfo);
} }
}); });
SystemRunningParams.ThreadState.put(subThread, "start"); SystemRunningParams.ThreadState.put(subThread, "start");
......
...@@ -29,8 +29,9 @@ public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService { ...@@ -29,8 +29,9 @@ public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService {
KittyProperties kitty; KittyProperties kitty;
@Autowired @Autowired
FuzzParamsService fuzzParamsService; FuzzParamsService fuzzParamsService;
@Override @Override
@NeedCutAround(name ="kitty",function = "generation") @NeedCutAround(name = "kitty", function = "generation")
public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException { public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException {
/*存入参数*/ /*存入参数*/
// int missionId = GlobalClass.missionInfoMapper.selectTopMissionId(); // int missionId = GlobalClass.missionInfoMapper.selectTopMissionId();
...@@ -38,11 +39,11 @@ public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService { ...@@ -38,11 +39,11 @@ public class VulnerabilityTypeServiceImpl implements VulnerabilityTypeService {
// if (!flag) { // if (!flag) {
// throw new AflnetException("Save params error!"); // throw new AflnetException("Save params error!");
// } // }
String cmd = parseParameters(testEntity); // String cmd = parseParameters(testEntity);
if (cmd.isEmpty()) { // if (cmd.isEmpty()) {
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!");
} // }
return cmdTools.runProgramCmdAndResult(cmd,"vulnerability","Vulnerability-"+testEntity.getTestClassName()); return null;
} }
public String parseParameters(TestEntity testEntity) { public String parseParameters(TestEntity testEntity) {
......
...@@ -136,7 +136,7 @@ public class TestCmdTools { ...@@ -136,7 +136,7 @@ public class TestCmdTools {
* 运行需要后台运行cmd * 运行需要后台运行cmd
* 将数据存入文件中 * 将数据存入文件中
*/ */
public Map<String, List<String>> runProgramCmdAndResult(String cmd, String caller, String missionName) throws public Map<String, List<String>> runProgramCmdAndResult(String cmd, String caller, String missionName, MissionInfo missionInfo) throws
CmdException { CmdException {
Map<String, List<String>> result = new HashMap(); Map<String, List<String>> result = new HashMap();
List<String> out = Collections.synchronizedList(new ArrayList<String>()); List<String> out = Collections.synchronizedList(new ArrayList<String>());
...@@ -161,7 +161,7 @@ public class TestCmdTools { ...@@ -161,7 +161,7 @@ public class TestCmdTools {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
dataBackUpTransaction(caller, finalOut, finalError, missionName); dataBackUpTransaction(caller, finalOut, finalError, missionName, missionInfo);
} }
}).start(); }).start();
//todo 需要传入任务参数,后期再开发 //todo 需要传入任务参数,后期再开发
...@@ -426,23 +426,14 @@ public class TestCmdTools { ...@@ -426,23 +426,14 @@ public class TestCmdTools {
} }
@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, MissionInfo missionInfo) {
int missionId = SystemRunningParams.kittyMissionId;
try { try {
/*kitty结果存入数据库*/ /*kitty结果存入数据库*/
KittyResult kittyResult = new KittyResult(missionId, out.toString(), error.toString()); KittyResult kittyResult = new KittyResult(missionInfo.getId(), out.toString(), error.toString());
GlobalClass.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的协议模板方法的日志和数据包文件存入数据库*/
// if (caller.equals("protocolTemplate")) {
//// GlobalClass.kittyFuzzPersistenceService.KittyPackagesBackup(missionId);
// GlobalClass.missionInfoMapper.insertMission(new MissionInfo(missionId, 2, new Date(), missionName,));
// } else {
// /*存入missionInfo信息*/
// GlobalClass.missionInfoMapper.insertMission(new MissionInfo(missionId, 3, new Date(), missionName));
// }
} }
} }
\ No newline at end of file
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