Compare commits
No commits in common. "c765a7417ad078d8f6895f0c1ad1cc94b3ab32a5" and "17da55937e8d700b9d0b52f3e74efb54ca7d1d1d" have entirely different histories.
c765a7417a
...
17da55937e
@ -94,15 +94,6 @@ public class AflManagerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(path="/findImperfection")
|
|
||||||
public CommonResult<AflImperfectionResp> findImperfection(@RequestBody @Valid AflManagerReq req) throws SftpUploadUtil.SftpUploadException {
|
|
||||||
|
|
||||||
AflImperfectionResp resp = aflSeedInfoService.findImperfection(req);
|
|
||||||
|
|
||||||
return CommonResult.success(resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(path="/saveAflSeedInfo")
|
@PostMapping(path="/saveAflSeedInfo")
|
||||||
public CommonResult<Void> saveAflSeedInfo(@RequestBody @Valid AflManagerReq req) throws SftpUploadUtil.SftpUploadException {
|
public CommonResult<Void> saveAflSeedInfo(@RequestBody @Valid AflManagerReq req) throws SftpUploadUtil.SftpUploadException {
|
||||||
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package cd.casic.ci.process.dto.resp.aflManager;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName ReportResp
|
|
||||||
* @Author hopeli
|
|
||||||
* @Date 2025/5/10 10:53
|
|
||||||
* @Version 1.0
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class AflImperfectionResp {
|
|
||||||
private Integer imperfectionCount = 0;
|
|
||||||
|
|
||||||
private Integer verifiedCount = 0;
|
|
||||||
|
|
||||||
private Integer unverifiedCount = 0;
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
package cd.casic.ci.process.process.service.aflManager;
|
package cd.casic.ci.process.process.service.aflManager;
|
||||||
|
|
||||||
import cd.casic.ci.process.dto.req.aflManager.AflManagerReq;
|
import cd.casic.ci.process.dto.req.aflManager.AflManagerReq;
|
||||||
import cd.casic.ci.process.dto.resp.aflManager.AflImperfectionResp;
|
|
||||||
import cd.casic.ci.process.dto.resp.aflManager.SeedsCountResp;
|
import cd.casic.ci.process.dto.resp.aflManager.SeedsCountResp;
|
||||||
import cd.casic.ci.process.process.dataObject.aflManager.AflSeedInfo;
|
import cd.casic.ci.process.process.dataObject.aflManager.AflSeedInfo;
|
||||||
import cd.casic.ci.process.util.SftpUploadUtil;
|
import cd.casic.ci.process.util.SftpUploadUtil;
|
||||||
@ -24,6 +23,4 @@ public interface AflSeedInfoService extends IService<AflSeedInfo> {
|
|||||||
void saveAflSeedInfo(@Valid AflManagerReq req);
|
void saveAflSeedInfo(@Valid AflManagerReq req);
|
||||||
|
|
||||||
void updateHistoryPipelineIdByAflSeedInfo(@Valid AflManagerReq req);
|
void updateHistoryPipelineIdByAflSeedInfo(@Valid AflManagerReq req);
|
||||||
|
|
||||||
AflImperfectionResp findImperfection(@Valid AflManagerReq req);
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package cd.casic.ci.process.process.service.aflManager.impl;
|
package cd.casic.ci.process.process.service.aflManager.impl;
|
||||||
|
|
||||||
import cd.casic.ci.process.dto.req.aflManager.AflManagerReq;
|
import cd.casic.ci.process.dto.req.aflManager.AflManagerReq;
|
||||||
import cd.casic.ci.process.dto.resp.aflManager.AflImperfectionResp;
|
|
||||||
import cd.casic.ci.process.dto.resp.aflManager.SeedsCountResp;
|
import cd.casic.ci.process.dto.resp.aflManager.SeedsCountResp;
|
||||||
import cd.casic.ci.process.dto.resp.resource.ResourceFindResp;
|
import cd.casic.ci.process.dto.resp.resource.ResourceFindResp;
|
||||||
import cd.casic.ci.process.engine.constant.PipelineVariableConstant;
|
import cd.casic.ci.process.engine.constant.PipelineVariableConstant;
|
||||||
import cd.casic.ci.process.engine.manager.RunContextManager;
|
import cd.casic.ci.process.engine.manager.RunContextManager;
|
||||||
import cd.casic.ci.process.engine.runContext.BaseRunContext;
|
import cd.casic.ci.process.engine.runContext.BaseRunContext;
|
||||||
import cd.casic.ci.process.process.dao.aflManager.AflSeedInfoDao;
|
import cd.casic.ci.process.process.dao.aflManager.AflSeedInfoDao;
|
||||||
import cd.casic.ci.process.process.dataObject.aflManager.AflInfo;
|
|
||||||
import cd.casic.ci.process.process.dataObject.aflManager.AflSeedInfo;
|
import cd.casic.ci.process.process.dataObject.aflManager.AflSeedInfo;
|
||||||
import cd.casic.ci.process.process.dataObject.resource.PipResourceMachine;
|
import cd.casic.ci.process.process.dataObject.resource.PipResourceMachine;
|
||||||
import cd.casic.ci.process.process.service.aflManager.AflSeedInfoService;
|
import cd.casic.ci.process.process.service.aflManager.AflSeedInfoService;
|
||||||
@ -291,51 +289,4 @@ public class AflSeedInfoServiceImpl extends ServiceImpl<AflSeedInfoDao, AflSeedI
|
|||||||
}
|
}
|
||||||
baseMapper.updateBatch(aflSeedInfos);
|
baseMapper.updateBatch(aflSeedInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AflImperfectionResp findImperfection(AflManagerReq req) {
|
|
||||||
AflImperfectionResp aflImperfectionResp = new AflImperfectionResp();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(req.getPipelineId()) || StringUtils.isEmpty(req.getTaskId())){
|
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"pipelineId或者taskId不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseRunContext runContext = runContextManager.getContext(req.getPipelineId());
|
|
||||||
if (ObjectUtils.isEmpty(runContext)){
|
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"未找到运行上下文");
|
|
||||||
}
|
|
||||||
String resourceId = runContext.getGlobalVariables().get(PipelineVariableConstant.AFL_RESOURCE_MANAGER_ID_KEY) instanceof String ? ((String) runContext.getGlobalVariables().get(PipelineVariableConstant.AFL_RESOURCE_MANAGER_ID_KEY)) : null;
|
|
||||||
if (StringUtils.isEmpty(resourceId)){
|
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"未找到资源");
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceFindResp resourceById = resourceManagerService.findResourceById(resourceId);
|
|
||||||
if (resourceById == null || resourceById.getResourceMachine() == null) {
|
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"资源信息错误");
|
|
||||||
}
|
|
||||||
|
|
||||||
PipResourceMachine resourceMachine = resourceById.getResourceMachine();
|
|
||||||
String password = CryptogramUtil.doDecrypt(resourceMachine.getPassword());
|
|
||||||
resourceMachine.setPassword(password);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 查询所有缺陷数
|
|
||||||
List<String> files = SftpUploadUtil.listFilesInRemoteDirectory(
|
|
||||||
resourceMachine.getMachineHost(), Integer.parseInt(resourceMachine.getSshPort()), resourceMachine.getUsername(), resourceMachine.getPassword(), null, remoteFilePath + "PIP_" + req.getPipelineId() + seedFilePath);
|
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(files)){
|
|
||||||
aflImperfectionResp.setImperfectionCount(files.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
//查询已验证和未验证缺陷数
|
|
||||||
AflInfo aflInfo = SftpUploadUtil.downloadFileSftpForInputStreamAndSetAflInfo(resourceMachine.getMachineHost(), Integer.parseInt(resourceMachine.getSshPort()), resourceMachine.getUsername(), resourceMachine.getPassword(),null, remoteFilePath + "PIP_" + req.getPipelineId() + "/ai_afl/default/fuzzer_stats");
|
|
||||||
if (!ObjectUtils.isEmpty(aflInfo)){
|
|
||||||
aflImperfectionResp.setVerifiedCount(Integer.parseInt(aflInfo.getSavedCrashes()));
|
|
||||||
aflImperfectionResp.setUnverifiedCount(Integer.parseInt(aflInfo.getPendingFavs()));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return aflImperfectionResp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user