Commit c96a10bd by 钱炳权

exception is chaged

parent 1c41f8b1
...@@ -27,19 +27,20 @@ public class KittyServerMessageController { ...@@ -27,19 +27,20 @@ public class KittyServerMessageController {
try { try {
return AjaxResult.success(getServerMessageService.getStats()); return AjaxResult.success(getServerMessageService.getStats());
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace())); log.error(e.getMessage());
return AjaxResult.error("stats信息获取失败!"); return AjaxResult.error("stats信息获取失败!");
} }
} }
/** /**
* 获取服务器templateInfo信息 * 获取服务器templateInfo信息
*/ */
//todo first
@RequestMapping(value = "/templateInfo", method = RequestMethod.GET) @RequestMapping(value = "/templateInfo", method = RequestMethod.GET)
public AjaxResult getTemplateInfo( ) { public AjaxResult getTemplateInfo( ) {
try { try {
return AjaxResult.success(getServerMessageService.getTemplateInfo()); return AjaxResult.success(getServerMessageService.getTemplateInfo());
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace())); log.error(e.getMessage());
return AjaxResult.error("templateInfo信息获取失败!"); return AjaxResult.error("templateInfo信息获取失败!");
} }
} }
...@@ -51,7 +52,7 @@ public class KittyServerMessageController { ...@@ -51,7 +52,7 @@ public class KittyServerMessageController {
try { try {
return AjaxResult.success(getServerMessageService.getStages()); return AjaxResult.success(getServerMessageService.getStages());
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace())); log.error(e.getMessage());
return AjaxResult.error("stages信息获取失败!"); return AjaxResult.error("stages信息获取失败!");
} }
} }
...@@ -63,7 +64,7 @@ public class KittyServerMessageController { ...@@ -63,7 +64,7 @@ public class KittyServerMessageController {
try { try {
return AjaxResult.success(getServerMessageService.getReport()); return AjaxResult.success(getServerMessageService.getReport());
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace())); log.error(e.getMessage());
return AjaxResult.error("report信息获取失败!"); return AjaxResult.error("report信息获取失败!");
} }
} }
......
...@@ -33,7 +33,7 @@ public class SeedFileController { ...@@ -33,7 +33,7 @@ public class SeedFileController {
try { try {
files = service.getSeedFiles(); files = service.getSeedFiles();
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace())); log.error(e.getMessage());
return AjaxResult.error("种子文件获取失败!"); return AjaxResult.error("种子文件获取失败!");
} }
return AjaxResult.success(files); return AjaxResult.success(files);
...@@ -47,7 +47,7 @@ public class SeedFileController { ...@@ -47,7 +47,7 @@ public class SeedFileController {
try { try {
service.delFile(fileName); service.delFile(fileName);
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace())); log.error(e.getMessage());
return AjaxResult.error("种子文件删除失败!"); return AjaxResult.error("种子文件删除失败!");
} }
return AjaxResult.success("种子文件删除成功!"); return AjaxResult.success("种子文件删除成功!");
...@@ -60,7 +60,7 @@ public class SeedFileController { ...@@ -60,7 +60,7 @@ public class SeedFileController {
try { try {
service.upload(file); service.upload(file);
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace())); log.error(e.getMessage());
return AjaxResult.error("种子文件upload失败!"); return AjaxResult.error("种子文件upload失败!");
} }
return AjaxResult.success("种子文件upload成功!"); return AjaxResult.success("种子文件upload成功!");
......
...@@ -6,18 +6,21 @@ import com.example.fuzzControll.service.GenerateMethodService; ...@@ -6,18 +6,21 @@ import com.example.fuzzControll.service.GenerateMethodService;
import com.example.fuzzControll.service.MutationService; import com.example.fuzzControll.service.MutationService;
import com.example.fuzzControll.service.ProtocolTemplateService; import com.example.fuzzControll.service.ProtocolTemplateService;
import com.example.fuzzControll.service.VulnerabilityTypeService; import com.example.fuzzControll.service.VulnerabilityTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* 不同类型的测试方法 * 不同类型的测试方法
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/testClass") @RequestMapping("/testClass")
public class TestClassController { public class TestClassController {
...@@ -38,7 +41,8 @@ public class TestClassController { ...@@ -38,7 +41,8 @@ public class TestClassController {
Map<String, List<String>> result = protocolTemplateService.generation(testEntity); Map<String, List<String>> result = protocolTemplateService.generation(testEntity);
return AjaxResult.success(result==null?"模板文件生成未成功运行":result); return AjaxResult.success(result==null?"模板文件生成未成功运行":result);
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error("模板文件生成失败!"); log.error(e.getMessage());
return AjaxResult.error(e.getMessage());
} }
} }
...@@ -51,6 +55,7 @@ public class TestClassController { ...@@ -51,6 +55,7 @@ public class TestClassController {
Map<String, List<String>> result = generateMethodService.generation(testEntity); Map<String, List<String>> result = generateMethodService.generation(testEntity);
return AjaxResult.success(result==null?"生成方法未成功运行":result); return AjaxResult.success(result==null?"生成方法未成功运行":result);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("生成方法使用失败!"); return AjaxResult.error("生成方法使用失败!");
} }
} }
...@@ -64,6 +69,7 @@ public class TestClassController { ...@@ -64,6 +69,7 @@ public class TestClassController {
Map<String, List<String>> result = mutationService.generation(testEntity); Map<String, List<String>> result = mutationService.generation(testEntity);
return AjaxResult.success(result==null?"mutationTest未成功运行":result); return AjaxResult.success(result==null?"mutationTest未成功运行":result);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("mutationTest失败!"); return AjaxResult.error("mutationTest失败!");
} }
} }
...@@ -77,6 +83,7 @@ public class TestClassController { ...@@ -77,6 +83,7 @@ public class TestClassController {
Map<String, List<String>> result = vulnerabilityTypeService.generation(testEntity); Map<String, List<String>> result = vulnerabilityTypeService.generation(testEntity);
return AjaxResult.success(result==null?"漏洞类型未成功运行":result); return AjaxResult.success(result==null?"漏洞类型未成功运行":result);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("漏洞类型测试失败!"); return AjaxResult.error("漏洞类型测试失败!");
} }
} }
......
...@@ -31,11 +31,12 @@ public class TestControler { ...@@ -31,11 +31,12 @@ public class TestControler {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
log.info("aflnet start!");
service.testStart(cmdStartParams); service.testStart(cmdStartParams);
} }
}).start(); }).start();
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace())); log.error(e.getMessage());
return AjaxResult.error("测试启动失败!"); return AjaxResult.error("测试启动失败!");
} }
return AjaxResult.success("测试启动成功!"); return AjaxResult.success("测试启动成功!");
...@@ -49,6 +50,7 @@ public class TestControler { ...@@ -49,6 +50,7 @@ public class TestControler {
try { try {
service.testStop(); service.testStop();
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("测试停止失败!"); return AjaxResult.error("测试停止失败!");
} }
return AjaxResult.success("测试停止成功!"); return AjaxResult.success("测试停止成功!");
......
...@@ -94,7 +94,6 @@ public class WebSocket { ...@@ -94,7 +94,6 @@ public class WebSocket {
public void appointSending(String sender, String name, String message) { public void appointSending(String sender, String name, String message) {
try { try {
// WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(sender + ":" + message); // WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(sender + ":" + message);
WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(message); WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(message);
......
...@@ -18,7 +18,7 @@ public class GetServerMessageImpl implements GetServerMessageService { ...@@ -18,7 +18,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
@Autowired @Autowired
KittyProperties kitty; KittyProperties kitty;
public String getServerMsg(String messageName) throws ServerException{ public String getServerMsg(String messageName) {
switch (messageName) { switch (messageName) {
case "templateInfo": { case "templateInfo": {
HttpGet httpGetTemplateInfo = new HttpGet(kitty.getTemplateInfoHttp()); HttpGet httpGetTemplateInfo = new HttpGet(kitty.getTemplateInfoHttp());
...@@ -26,7 +26,6 @@ public class GetServerMessageImpl implements GetServerMessageService { ...@@ -26,7 +26,6 @@ public class GetServerMessageImpl implements GetServerMessageService {
CloseableHttpResponse templateInfoResponse = httpClient.execute(httpGetTemplateInfo);) { CloseableHttpResponse templateInfoResponse = httpClient.execute(httpGetTemplateInfo);) {
return EntityUtils.toString(templateInfoResponse.getEntity(), "utf-8"); return EntityUtils.toString(templateInfoResponse.getEntity(), "utf-8");
} catch (Exception e) { } catch (Exception e) {
log.error("templateInfo http error!");
throw new ServerException("get server templateInfo error !"); throw new ServerException("get server templateInfo error !");
} }
} }
...@@ -36,7 +35,6 @@ public class GetServerMessageImpl implements GetServerMessageService { ...@@ -36,7 +35,6 @@ public class GetServerMessageImpl implements GetServerMessageService {
CloseableHttpResponse statsResponse = httpClient.execute(httpGetStats);) { CloseableHttpResponse statsResponse = httpClient.execute(httpGetStats);) {
return EntityUtils.toString(statsResponse.getEntity(), "utf-8"); return EntityUtils.toString(statsResponse.getEntity(), "utf-8");
} catch (Exception e) { } catch (Exception e) {
log.error("stats http error!");
throw new ServerException("get server stats error !"); throw new ServerException("get server stats error !");
} }
} }
...@@ -46,7 +44,6 @@ public class GetServerMessageImpl implements GetServerMessageService { ...@@ -46,7 +44,6 @@ public class GetServerMessageImpl implements GetServerMessageService {
CloseableHttpResponse reportResponse = httpClient.execute(httpGetStats);) { CloseableHttpResponse reportResponse = httpClient.execute(httpGetStats);) {
return EntityUtils.toString(reportResponse.getEntity(), "utf-8"); return EntityUtils.toString(reportResponse.getEntity(), "utf-8");
} catch (Exception e) { } catch (Exception e) {
log.error("report http error!");
throw new ServerException("get server report error !"); throw new ServerException("get server report error !");
} }
...@@ -57,7 +54,6 @@ public class GetServerMessageImpl implements GetServerMessageService { ...@@ -57,7 +54,6 @@ public class GetServerMessageImpl implements GetServerMessageService {
CloseableHttpResponse stagesResponse = httpClient.execute(httpGetStats);) { CloseableHttpResponse stagesResponse = httpClient.execute(httpGetStats);) {
return EntityUtils.toString(stagesResponse.getEntity(), "utf-8"); return EntityUtils.toString(stagesResponse.getEntity(), "utf-8");
} catch (Exception e) { } catch (Exception e) {
log.error("stages http error!");
throw new ServerException("get server stages error !"); throw new ServerException("get server stages error !");
} }
} }
...@@ -67,7 +63,7 @@ public class GetServerMessageImpl implements GetServerMessageService { ...@@ -67,7 +63,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
} }
@Override @Override
public String getStats() throws ServerException { public String getStats() {
return getServerMsg("stats"); return getServerMsg("stats");
} }
......
...@@ -8,6 +8,7 @@ import com.example.fuzzControll.exception.CmdException; ...@@ -8,6 +8,7 @@ import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException; import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.CmdStartParams; import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.pojo.vo.TestReturnEntity; import com.example.fuzzControll.pojo.vo.TestReturnEntity;
import lombok.extern.slf4j.Slf4j;
import java.io.*; import java.io.*;
...@@ -15,6 +16,7 @@ import java.util.*; ...@@ -15,6 +16,7 @@ import java.util.*;
//todo need modify //todo need modify
@Slf4j
public class CmdTools { public class CmdTools {
Boolean send = false; Boolean send = false;
WebSocket socket = (WebSocket) SpringContextUtil.getBean("WebSocket"); WebSocket socket = (WebSocket) SpringContextUtil.getBean("WebSocket");
...@@ -67,6 +69,7 @@ public class CmdTools { ...@@ -67,6 +69,7 @@ public class CmdTools {
printMessageByProgramCmd(process.getErrorStream(), error); printMessageByProgramCmd(process.getErrorStream(), error);
process.waitFor(); process.waitFor();
} catch (Exception e) { } catch (Exception e) {
log.error("aflnet run error!");
throw new FuzzException("run fuzz error !"); throw new FuzzException("run fuzz error !");
} }
result.put("out", out); result.put("out", out);
......
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