0624 ljc 报告详情页开发,文件夹上传接口编写,测试用例接口开发
This commit is contained in:
parent
5419ee5dce
commit
24c2e9acac
@ -3,8 +3,8 @@ package cd.casic.ci.api;
|
|||||||
|
|
||||||
import cd.casic.ci.process.dto.req.report.ReportAssetTaskReq;
|
import cd.casic.ci.process.dto.req.report.ReportAssetTaskReq;
|
||||||
import cd.casic.ci.process.dto.req.report.ReportDeleteReq;
|
import cd.casic.ci.process.dto.req.report.ReportDeleteReq;
|
||||||
import cd.casic.ci.process.dto.resp.report.ReportResp;
|
import cd.casic.ci.process.dto.req.report.ReportInfoQueryReq;
|
||||||
import cd.casic.ci.process.dto.resp.report.ReportTaskResp;
|
import cd.casic.ci.process.dto.resp.report.*;
|
||||||
import cd.casic.ci.process.process.dataObject.base.BaseIdPageReq;
|
import cd.casic.ci.process.process.dataObject.base.BaseIdPageReq;
|
||||||
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
||||||
import cd.casic.ci.process.process.service.report.ReportService;
|
import cd.casic.ci.process.process.service.report.ReportService;
|
||||||
@ -15,11 +15,15 @@ import jakarta.annotation.security.PermitAll;
|
|||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStoreException;
|
import java.security.KeyStoreException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName ReportController
|
* @ClassName ReportController
|
||||||
@ -76,4 +80,29 @@ public class ReportController {
|
|||||||
return CommonResult.success(taskResp);
|
return CommonResult.success(taskResp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(path = "/createVulListByScaTaskId")
|
||||||
|
public CommonResult<Void> createVulListByScaTaskId(@RequestBody @Valid BaseIdReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||||
|
reportService.createVulListByScaTaskId(req);
|
||||||
|
return CommonResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(path = "/findInfoConsoleSum")
|
||||||
|
public CommonResult<ReportInfoConsoleSumResp> findInfoConsoleSum(){
|
||||||
|
ReportInfoConsoleSumResp resp = reportService.findInfoConsoleSum();
|
||||||
|
return CommonResult.success(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(path = "/findInfoConsole")
|
||||||
|
public CommonResult<List<ReportInfoConsoleResp>> findInfoConsole(@RequestBody @Valid ReportInfoQueryReq query){
|
||||||
|
List<ReportInfoConsoleResp> resp = reportService.findInfoConsole(query);
|
||||||
|
return CommonResult.success(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(path = "/findReportInfo")
|
||||||
|
public CommonResult<PageResult<ReportInfoResp>> findReportInfo(@RequestBody @Valid ReportInfoQueryReq query){
|
||||||
|
PageResult<ReportInfoResp> resp = reportService.findReportInfo(query);
|
||||||
|
return CommonResult.success(resp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
|||||||
import cd.casic.ci.process.process.service.target.TargetManagerService;
|
import cd.casic.ci.process.process.service.target.TargetManagerService;
|
||||||
import cd.casic.ci.process.process.service.target.TargetVersionService;
|
import cd.casic.ci.process.process.service.target.TargetVersionService;
|
||||||
import cd.casic.ci.process.util.SftpUploadUtil;
|
import cd.casic.ci.process.util.SftpUploadUtil;
|
||||||
|
import cd.casic.framework.commons.exception.ServiceException;
|
||||||
|
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
||||||
import cd.casic.framework.commons.pojo.CommonResult;
|
import cd.casic.framework.commons.pojo.CommonResult;
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,4 +140,22 @@ public class TargetController {
|
|||||||
|
|
||||||
return CommonResult.success(inputStream);
|
return CommonResult.success(inputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(path = "/uploadFolder")
|
||||||
|
public CommonResult<List<String>> uploadFolder(@RequestParam("files") MultipartFile[] files) {
|
||||||
|
List<String> fileUrls = new ArrayList<>();
|
||||||
|
|
||||||
|
for (MultipartFile file : files) {
|
||||||
|
if (!file.isEmpty()) {
|
||||||
|
try {
|
||||||
|
String filePath = targetManagerService.fileUpload(file);
|
||||||
|
fileUrls.add(filePath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"文件夹上传失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CommonResult.success(fileUrls);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
package cd.casic.ci.api;
|
||||||
|
|
||||||
|
|
||||||
|
import cd.casic.ci.process.dto.req.testCase.TestCaseInfoQueryReq;
|
||||||
|
import cd.casic.ci.process.dto.req.testCase.TestCaseInfoReq;
|
||||||
|
import cd.casic.ci.process.dto.resp.testCase.TestCaseInfoResp;
|
||||||
|
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
||||||
|
import cd.casic.ci.process.process.service.testCase.TestCaseInfoService;
|
||||||
|
import cd.casic.framework.commons.pojo.CommonResult;
|
||||||
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ResourceController
|
||||||
|
* @Author hopeli
|
||||||
|
* @Date 2025/5/10 10:57
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/testCase")
|
||||||
|
public class TestCaseInfoController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TestCaseInfoService testCaseInfoService;
|
||||||
|
|
||||||
|
@PostMapping(path="/create")
|
||||||
|
public CommonResult<String> create(@RequestBody @Valid TestCaseInfoReq req){
|
||||||
|
|
||||||
|
String id = testCaseInfoService.create(req);
|
||||||
|
|
||||||
|
return CommonResult.success(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(path="/delete")
|
||||||
|
public CommonResult<Void> delete(@RequestBody @Valid BaseIdReq req){
|
||||||
|
|
||||||
|
testCaseInfoService.delete(req.getId());
|
||||||
|
|
||||||
|
return CommonResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(path="/update")
|
||||||
|
public CommonResult<Void> update(@RequestBody @NotNull @Valid TestCaseInfoReq req){
|
||||||
|
|
||||||
|
testCaseInfoService.updateTestCase(req);
|
||||||
|
|
||||||
|
return CommonResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(path="/findList")
|
||||||
|
public CommonResult<List<TestCaseInfoResp>> findList(@RequestBody @Valid TestCaseInfoQueryReq query){
|
||||||
|
|
||||||
|
List<TestCaseInfoResp> respList = testCaseInfoService.findList(query);
|
||||||
|
|
||||||
|
return CommonResult.success(respList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(path="/findPage")
|
||||||
|
public CommonResult<PageResult<TestCaseInfoResp>> findResourcePage(@RequestBody @NotNull @Valid TestCaseInfoQueryReq query){
|
||||||
|
|
||||||
|
PageResult<TestCaseInfoResp> respPage = testCaseInfoService.findPage(query);
|
||||||
|
return CommonResult.success(respPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(path="/findById")
|
||||||
|
public CommonResult<TestCaseInfoResp> findById(@RequestBody @Valid BaseIdReq req){
|
||||||
|
|
||||||
|
TestCaseInfoResp resp = testCaseInfoService.findById(req.getId());
|
||||||
|
|
||||||
|
return CommonResult.success(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package cd.casic.ci.process.dto.req.report;
|
||||||
|
|
||||||
|
import cd.casic.framework.commons.pojo.PageParam;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName PipelineReq
|
||||||
|
* @Author hopeli
|
||||||
|
* @Date 2025/5/10 10:53
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class ReportInfoQueryReq extends PageParam {
|
||||||
|
//任务id
|
||||||
|
private String taskId;
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package cd.casic.ci.process.dto.req.testCase;
|
||||||
|
|
||||||
|
import cd.casic.framework.commons.pojo.PageParam;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class TestCaseInfoQueryReq extends PageParam {
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private List<String> idList;
|
||||||
|
|
||||||
|
// 测试用例名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
// 文件名称
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
// 测试文件类型(如:txt, csv, xml 等)
|
||||||
|
private String testFileType;
|
||||||
|
|
||||||
|
// 测试文件地址(存储路径或URL)
|
||||||
|
private String testFileList;
|
||||||
|
|
||||||
|
// 描述信息
|
||||||
|
private String remark;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package cd.casic.ci.process.dto.req.testCase;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TestCaseInfoReq {
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
// 测试用例名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
// 文件名称
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
// 测试文件类型(如:txt, csv, xml 等)
|
||||||
|
private String testFileType;
|
||||||
|
|
||||||
|
// 测试文件地址(存储路径或URL)
|
||||||
|
private String testFileList;
|
||||||
|
|
||||||
|
// 描述信息
|
||||||
|
private String remark;
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package cd.casic.ci.process.dto.resp.report;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ReportResp
|
||||||
|
* @Author hopeli
|
||||||
|
* @Date 2025/5/10 10:53
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ReportInfoConsoleResp {
|
||||||
|
//流水线名称
|
||||||
|
private String pipelineName;
|
||||||
|
|
||||||
|
//任务id
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
//任务名称
|
||||||
|
private String taskName;
|
||||||
|
|
||||||
|
//高危漏洞类型数量
|
||||||
|
private Integer highRiskCount;
|
||||||
|
|
||||||
|
//中危漏洞类型数量
|
||||||
|
private Integer poorRiskCount;
|
||||||
|
|
||||||
|
//低危漏洞类型数量
|
||||||
|
private Integer lowRiskCount;
|
||||||
|
|
||||||
|
//漏洞总数量
|
||||||
|
private Integer riskCount;
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package cd.casic.ci.process.dto.resp.report;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ReportResp
|
||||||
|
* @Author hopeli
|
||||||
|
* @Date 2025/5/10 10:53
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ReportInfoConsoleSumResp {
|
||||||
|
|
||||||
|
//漏洞总数量
|
||||||
|
private Integer riskCount;
|
||||||
|
|
||||||
|
//高危漏洞类型总数量
|
||||||
|
private Integer highRiskSum;
|
||||||
|
|
||||||
|
//新增漏洞总数量
|
||||||
|
private Integer newlyIncreasedRiskCount;
|
||||||
|
|
||||||
|
//新增高危漏洞类型总数量
|
||||||
|
private Integer newlyIncreasedHighRiskSum;
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package cd.casic.ci.process.dto.resp.report;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ReportResp
|
||||||
|
* @Author hopeli
|
||||||
|
* @Date 2025/5/10 10:53
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ReportInfoResp {
|
||||||
|
// 任务id
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
// sca任务id
|
||||||
|
private String scaTaskId;
|
||||||
|
|
||||||
|
// 风险等级 1-严重 2-高危 3-中危 4-低危 5-无漏洞
|
||||||
|
private Integer securityLevelId;
|
||||||
|
|
||||||
|
// 漏洞名称
|
||||||
|
private String vulName;
|
||||||
|
|
||||||
|
// cnnvd编号
|
||||||
|
private String cnnvdId;
|
||||||
|
|
||||||
|
// cnvd编号
|
||||||
|
private String cnvdId;
|
||||||
|
|
||||||
|
// cve编号
|
||||||
|
private String cveId;
|
||||||
|
|
||||||
|
// cwe编号
|
||||||
|
private String cweId;
|
||||||
|
|
||||||
|
// 漏洞类型
|
||||||
|
private String vulType;
|
||||||
|
|
||||||
|
// 漏洞状态
|
||||||
|
private String vulMarkStatus;
|
||||||
|
|
||||||
|
// 攻击类型
|
||||||
|
private String attackType;
|
||||||
|
|
||||||
|
// cvssV2评分
|
||||||
|
private Double cvssV2Score;
|
||||||
|
|
||||||
|
// cvssV3评分
|
||||||
|
private Double cvssV3Score;
|
||||||
|
|
||||||
|
// 漏洞利用难度 -2-未知 0-困难 1-容易 2-一般
|
||||||
|
private Integer exploitLevelIndex;
|
||||||
|
|
||||||
|
// 发布时间
|
||||||
|
private String releaseDate;
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package cd.casic.ci.process.dto.resp.testCase;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TestCaseInfoResp {
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
// 测试用例名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
// 文件名称
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
// 测试文件类型(如:txt, csv, xml 等)
|
||||||
|
private String testFileType;
|
||||||
|
|
||||||
|
// 测试文件地址(存储路径或URL)
|
||||||
|
private String testFileList;
|
||||||
|
|
||||||
|
// 描述信息
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
//创建人id
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
//创建人姓名
|
||||||
|
private String creatorName;
|
||||||
|
|
||||||
|
//最后修改人id
|
||||||
|
private String updater;
|
||||||
|
|
||||||
|
//最后修改人姓名
|
||||||
|
private String updaterName;
|
||||||
|
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package cd.casic.ci.process.process.converter;
|
||||||
|
|
||||||
|
import cd.casic.ci.process.dto.resp.report.ReportInfoResp;
|
||||||
|
import cd.casic.ci.process.process.dataObject.report.PipReportInfo;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author HopeLi
|
||||||
|
* @version v1.0
|
||||||
|
* @ClassName PipelineConverter
|
||||||
|
* @Date: 2025/5/13 14:39
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface PipReportInfoConverter {
|
||||||
|
PipReportInfoConverter INSTANCE = Mappers.getMapper(PipReportInfoConverter.class);
|
||||||
|
|
||||||
|
List<ReportInfoResp> toRespList(List<PipReportInfo> records);
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package cd.casic.ci.process.process.converter;
|
||||||
|
|
||||||
|
import cd.casic.ci.process.dto.req.testCase.TestCaseInfoReq;
|
||||||
|
import cd.casic.ci.process.dto.resp.testCase.TestCaseInfoResp;
|
||||||
|
import cd.casic.ci.process.process.dataObject.testCase.TestCaseInfo;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author HopeLi
|
||||||
|
* @version v1.0
|
||||||
|
* @ClassName PipelineConverter
|
||||||
|
* @Date: 2025/5/13 14:39
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface TestCaseInfoConverter {
|
||||||
|
TestCaseInfoConverter INSTANCE = Mappers.getMapper(TestCaseInfoConverter.class);
|
||||||
|
|
||||||
|
TestCaseInfo toBean(TestCaseInfoReq req);
|
||||||
|
|
||||||
|
List<TestCaseInfoResp> toRespList(List<TestCaseInfo> testCaseInfos);
|
||||||
|
|
||||||
|
TestCaseInfoResp toResp(TestCaseInfo testCaseInfo);
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package cd.casic.ci.process.process.dao.report;
|
||||||
|
|
||||||
|
import cd.casic.ci.process.process.dataObject.report.PipReportInfo;
|
||||||
|
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author HopeLi
|
||||||
|
* @version v1.0
|
||||||
|
* @ClassName PipelineDao
|
||||||
|
* @Date: 2025/5/13 14:39
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public interface ReportInfoDao extends BaseMapperX<PipReportInfo> {
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package cd.casic.ci.process.process.dao.testCase;
|
||||||
|
|
||||||
|
import cd.casic.ci.process.process.dataObject.testCase.TestCaseInfo;
|
||||||
|
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author HopeLi
|
||||||
|
* @version v1.0
|
||||||
|
* @ClassName PipelineDao
|
||||||
|
* @Date: 2025/5/13 14:39
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public interface TestCaseInfoDao extends BaseMapperX<TestCaseInfo>, BaseMapper<TestCaseInfo> {
|
||||||
|
}
|
@ -19,5 +19,6 @@ public class BaseIdReq {
|
|||||||
private String childId;
|
private String childId;
|
||||||
private String projectId;
|
private String projectId;
|
||||||
private String taskId;
|
private String taskId;
|
||||||
|
private String scaTaskId;
|
||||||
private List<Integer> reportIds;
|
private List<Integer> reportIds;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package cd.casic.ci.process.process.dataObject.report;
|
||||||
|
|
||||||
|
import cd.casic.ci.process.process.dataObject.base.PipBaseElement;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author HopeLi
|
||||||
|
* @version v1.0
|
||||||
|
* @ClassName PipReportInfo
|
||||||
|
* @Date: 2025/6/23 20:29
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("pip_report_info")
|
||||||
|
public class PipReportInfo extends PipBaseElement {
|
||||||
|
// 任务id
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
// sca任务id
|
||||||
|
private String scaTaskId;
|
||||||
|
|
||||||
|
// 风险等级 1-严重 2-高危 3-中危 4-低危 5-无漏洞
|
||||||
|
private Integer securityLevelId;
|
||||||
|
|
||||||
|
// 漏洞名称
|
||||||
|
private String vulName;
|
||||||
|
|
||||||
|
// cnnvd编号
|
||||||
|
private String cnnvdId;
|
||||||
|
|
||||||
|
// cnvd编号
|
||||||
|
private String cnvdId;
|
||||||
|
|
||||||
|
// cve编号
|
||||||
|
private String cveId;
|
||||||
|
|
||||||
|
// cwe编号
|
||||||
|
private String cweId;
|
||||||
|
|
||||||
|
// 漏洞类型
|
||||||
|
private String vulType;
|
||||||
|
|
||||||
|
// 漏洞状态
|
||||||
|
private String vulMarkStatus;
|
||||||
|
|
||||||
|
// 攻击类型
|
||||||
|
private String attackType;
|
||||||
|
|
||||||
|
// cvssV2评分
|
||||||
|
private Double cvssV2Score;
|
||||||
|
|
||||||
|
// cvssV3评分
|
||||||
|
private Double cvssV3Score;
|
||||||
|
|
||||||
|
// 漏洞利用难度 -2-未知 0-困难 1-容易 2-一般
|
||||||
|
private Integer exploitLevelIndex;
|
||||||
|
|
||||||
|
// 发布时间
|
||||||
|
private String releaseDate;
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package cd.casic.ci.process.process.dataObject.testCase;
|
||||||
|
|
||||||
|
import cd.casic.ci.process.process.dataObject.base.PipBaseElement;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author HopeLi
|
||||||
|
* @version v1.0
|
||||||
|
* @ClassName TestCaseInfo
|
||||||
|
* @Date: 2025/6/24 16:40
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("test_case_info")
|
||||||
|
public class TestCaseInfo extends PipBaseElement {
|
||||||
|
|
||||||
|
// 测试用例名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
// 文件名称
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
// 测试文件类型(如:txt, csv, xml 等)
|
||||||
|
private String testFileType;
|
||||||
|
|
||||||
|
// 测试文件地址(存储路径或URL)
|
||||||
|
private String testFileList;
|
||||||
|
|
||||||
|
// 描述信息
|
||||||
|
private String remark;
|
||||||
|
}
|
@ -2,8 +2,8 @@ package cd.casic.ci.process.process.service.report;
|
|||||||
|
|
||||||
import cd.casic.ci.process.dto.req.report.ReportAssetTaskReq;
|
import cd.casic.ci.process.dto.req.report.ReportAssetTaskReq;
|
||||||
import cd.casic.ci.process.dto.req.report.ReportDeleteReq;
|
import cd.casic.ci.process.dto.req.report.ReportDeleteReq;
|
||||||
import cd.casic.ci.process.dto.resp.report.ReportResp;
|
import cd.casic.ci.process.dto.req.report.ReportInfoQueryReq;
|
||||||
import cd.casic.ci.process.dto.resp.report.ReportTaskResp;
|
import cd.casic.ci.process.dto.resp.report.*;
|
||||||
import cd.casic.ci.process.process.dataObject.base.BaseIdPageReq;
|
import cd.casic.ci.process.process.dataObject.base.BaseIdPageReq;
|
||||||
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
@ -13,6 +13,7 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStoreException;
|
import java.security.KeyStoreException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author HopeLi
|
* @author HopeLi
|
||||||
@ -31,4 +32,12 @@ public interface ReportService{
|
|||||||
ReportResp assetReportTask(@Valid ReportAssetTaskReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException;
|
ReportResp assetReportTask(@Valid ReportAssetTaskReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException;
|
||||||
|
|
||||||
ReportTaskResp findByScaTaskId(String taskId) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException;
|
ReportTaskResp findByScaTaskId(String taskId) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException;
|
||||||
|
|
||||||
|
void createVulListByScaTaskId(@Valid BaseIdReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException;
|
||||||
|
|
||||||
|
ReportInfoConsoleSumResp findInfoConsoleSum();
|
||||||
|
|
||||||
|
List<ReportInfoConsoleResp> findInfoConsole(@Valid ReportInfoQueryReq query);
|
||||||
|
|
||||||
|
PageResult<ReportInfoResp> findReportInfo(@Valid ReportInfoQueryReq query);
|
||||||
}
|
}
|
||||||
|
@ -2,22 +2,33 @@ package cd.casic.ci.process.process.service.report.impl;
|
|||||||
|
|
||||||
import cd.casic.ci.process.dto.req.report.ReportAssetTaskReq;
|
import cd.casic.ci.process.dto.req.report.ReportAssetTaskReq;
|
||||||
import cd.casic.ci.process.dto.req.report.ReportDeleteReq;
|
import cd.casic.ci.process.dto.req.report.ReportDeleteReq;
|
||||||
import cd.casic.ci.process.dto.resp.report.ImageLayerInfo;
|
import cd.casic.ci.process.dto.req.report.ReportInfoQueryReq;
|
||||||
import cd.casic.ci.process.dto.resp.report.ReportResp;
|
import cd.casic.ci.process.dto.resp.report.*;
|
||||||
import cd.casic.ci.process.dto.resp.report.ReportTaskResp;
|
|
||||||
import cd.casic.ci.process.engine.context.ConstantContextHolder;
|
import cd.casic.ci.process.engine.context.ConstantContextHolder;
|
||||||
|
import cd.casic.ci.process.process.converter.PipReportInfoConverter;
|
||||||
|
import cd.casic.ci.process.process.dao.pipeline.PipTaskDao;
|
||||||
|
import cd.casic.ci.process.process.dao.pipeline.PipelineDao;
|
||||||
|
import cd.casic.ci.process.process.dao.report.ReportInfoDao;
|
||||||
import cd.casic.ci.process.process.dataObject.base.BaseIdPageReq;
|
import cd.casic.ci.process.process.dataObject.base.BaseIdPageReq;
|
||||||
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
||||||
|
import cd.casic.ci.process.process.dataObject.pipeline.PipPipeline;
|
||||||
|
import cd.casic.ci.process.process.dataObject.report.PipReportInfo;
|
||||||
|
import cd.casic.ci.process.process.dataObject.task.PipTask;
|
||||||
import cd.casic.ci.process.process.service.report.ReportService;
|
import cd.casic.ci.process.process.service.report.ReportService;
|
||||||
|
import cd.casic.ci.process.util.WebFrameworkUtils;
|
||||||
import cd.casic.framework.commons.exception.ServiceException;
|
import cd.casic.framework.commons.exception.ServiceException;
|
||||||
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
|
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
@ -25,10 +36,9 @@ import org.springframework.web.util.UriComponentsBuilder;
|
|||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStoreException;
|
import java.security.KeyStoreException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.ArrayList;
|
import java.time.LocalDate;
|
||||||
import java.util.Base64;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.stream.Collectors;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static cd.casic.ci.process.engine.worker.base.HttpWorker.getRestTemplateWithoutSANCheck;
|
import static cd.casic.ci.process.engine.worker.base.HttpWorker.getRestTemplateWithoutSANCheck;
|
||||||
|
|
||||||
@ -43,6 +53,15 @@ import static cd.casic.ci.process.engine.worker.base.HttpWorker.getRestTemplateW
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ReportServiceImpl implements ReportService {
|
public class ReportServiceImpl implements ReportService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ReportInfoDao reportInfoDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PipTaskDao pipTaskDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PipelineDao pipelineDao;
|
||||||
|
|
||||||
public static final String PATH = "/openapi/v1/asset/report/downLoadReport/batch";
|
public static final String PATH = "/openapi/v1/asset/report/downLoadReport/batch";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -199,6 +218,151 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createVulListByScaTaskId(BaseIdReq req) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||||
|
if (ObjectUtils.isEmpty(req.getTaskId())){
|
||||||
|
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"任务ID不能为空");
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(req.getScaTaskId())){
|
||||||
|
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"scaTaskId不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
RestTemplate restTemplate = getRestTemplateWithoutSANCheck();
|
||||||
|
String reportDeleteUrl = ConstantContextHolder.getScaIp() + "/openapi/v1/task/vul/list";
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("taskId", Integer.parseInt(req.getScaTaskId()));
|
||||||
|
String body = json.toJSONString();
|
||||||
|
|
||||||
|
HttpHeaders headers = createHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
HttpEntity<String> requestEntity = new HttpEntity<>(body, headers);
|
||||||
|
|
||||||
|
log.info("根据任务ID查询漏洞列表:" + reportDeleteUrl);
|
||||||
|
JSONObject response = restTemplate.postForObject(reportDeleteUrl, requestEntity, JSONObject.class);
|
||||||
|
String message = response.getString("message");
|
||||||
|
if (message.equals("success")) {
|
||||||
|
log.info("===============根据任务ID查询漏洞列表成功=================");
|
||||||
|
JSONObject data = response.getJSONObject("data");
|
||||||
|
|
||||||
|
//映射到报告信息表中去,做存储操作
|
||||||
|
List<PipReportInfo> infoList = setReportInfoToCreate(data,req.getScaTaskId(),req.getTaskId());
|
||||||
|
|
||||||
|
reportInfoDao.insertBatch(infoList);
|
||||||
|
} else {
|
||||||
|
log.error("===============根据任务ID查询漏洞列表失败,新增报告信息失败=================");
|
||||||
|
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"新增报告信息失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReportInfoConsoleSumResp findInfoConsoleSum() {
|
||||||
|
ReportInfoConsoleSumResp resp = new ReportInfoConsoleSumResp();
|
||||||
|
List<PipReportInfo> infoList = reportInfoDao.selectList(new QueryWrapper<>());
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(infoList)){
|
||||||
|
//根据日期进行过滤计算
|
||||||
|
List<PipReportInfo> todayReportInfoList = infoList.stream().filter(info -> info.getCreateTime().toLocalDate().isEqual(LocalDate.now())).toList();
|
||||||
|
//今日新增总数量
|
||||||
|
resp.setNewlyIncreasedRiskCount(todayReportInfoList.size());
|
||||||
|
|
||||||
|
List<PipReportInfo> highRickReportInfoLIst = todayReportInfoList.stream().filter(info -> 2 == info.getSecurityLevelId()).toList();
|
||||||
|
//今日高危新增总数量
|
||||||
|
resp.setNewlyIncreasedHighRiskSum(highRickReportInfoLIst.size());
|
||||||
|
|
||||||
|
//总漏洞数量
|
||||||
|
resp.setRiskCount(infoList.size());
|
||||||
|
|
||||||
|
//总高危漏洞数量
|
||||||
|
List<PipReportInfo> highRickReportSum = infoList.stream().filter(info -> 2 == info.getSecurityLevelId()).toList();
|
||||||
|
resp.setHighRiskSum(highRickReportSum.size());
|
||||||
|
}
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ReportInfoConsoleResp> findInfoConsole(ReportInfoQueryReq query) {
|
||||||
|
List<ReportInfoConsoleResp> respList = new ArrayList<>();
|
||||||
|
|
||||||
|
QueryWrapper<PipReportInfo> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq("creator", Objects.requireNonNull(WebFrameworkUtils.getLoginUserId()).toString());
|
||||||
|
List<PipReportInfo> infoList = reportInfoDao.selectList(wrapper);
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(infoList)){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> distinctTaskIds = infoList.stream().map(PipReportInfo::getTaskId).distinct().toList();
|
||||||
|
|
||||||
|
//根据taskId查询对应的流水线信息名称
|
||||||
|
// 1.查询PipTask列表
|
||||||
|
List<PipTask> taskList = pipTaskDao.selectList(new QueryWrapper<PipTask>().in("task_id", distinctTaskIds));
|
||||||
|
|
||||||
|
// 2.转换taskList为id:taskName的map
|
||||||
|
Map<String, String> taskIdToNameMap = taskList.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
PipTask::getId,
|
||||||
|
PipTask::getTaskName,
|
||||||
|
(existing, replacement) -> existing
|
||||||
|
));
|
||||||
|
|
||||||
|
// 3.提取pipelineId列表
|
||||||
|
Set<String> pipelineIdSet = taskList.stream()
|
||||||
|
.map(PipTask::getPipelineId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 4.查询PipPipeline列表并转成map: pipelineId -> pipelineName
|
||||||
|
Map<String, String> pipelineMap = pipelineDao.selectList(
|
||||||
|
new QueryWrapper<PipPipeline>().in("pipeline_id", pipelineIdSet))
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
PipPipeline::getId,
|
||||||
|
PipPipeline::getName,
|
||||||
|
(existing, replacement) -> existing // 遇到重复 key 保留第一个
|
||||||
|
));
|
||||||
|
|
||||||
|
// 5.构建taskId -> pipelineName映射
|
||||||
|
Map<String, String> taskMap = taskList.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
PipTask::getId,
|
||||||
|
task -> pipelineMap.getOrDefault(task.getPipelineId(), "数据错误")
|
||||||
|
));
|
||||||
|
|
||||||
|
// 6.根据pipelineName+taskName统计漏洞信息
|
||||||
|
taskMap.forEach((taskId, pipelineName) -> {
|
||||||
|
ReportInfoConsoleResp resp = new ReportInfoConsoleResp();
|
||||||
|
resp.setPipelineName(pipelineName);
|
||||||
|
resp.setTaskId(taskId);
|
||||||
|
resp.setTaskName(taskIdToNameMap.get(taskId));
|
||||||
|
|
||||||
|
//计算高中低危的总数量
|
||||||
|
List<PipReportInfo> nowTaskReportInfo = infoList.stream().filter(info -> taskId.equals(info.getTaskId())).toList();
|
||||||
|
resp.setHighRiskCount(nowTaskReportInfo.stream().filter(info -> 2 == info.getSecurityLevelId()).toList().size());
|
||||||
|
resp.setPoorRiskCount(nowTaskReportInfo.stream().filter(info -> 3 == info.getSecurityLevelId()).toList().size());
|
||||||
|
resp.setLowRiskCount(nowTaskReportInfo.stream().filter(info -> 4 == info.getSecurityLevelId()).toList().size());
|
||||||
|
resp.setRiskCount(nowTaskReportInfo.size());
|
||||||
|
respList.add(resp);
|
||||||
|
});
|
||||||
|
|
||||||
|
return respList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<ReportInfoResp> findReportInfo(ReportInfoQueryReq query) {
|
||||||
|
QueryWrapper<PipReportInfo> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq("taskId", query.getTaskId());
|
||||||
|
Page<PipReportInfo> pipReportInfoPage = reportInfoDao.selectPage(new Page<>(query.getPageNo(), query.getPageSize()), wrapper);
|
||||||
|
if (ObjectUtils.isEmpty(pipReportInfoPage)){
|
||||||
|
return new PageResult<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(pipReportInfoPage.getRecords())){
|
||||||
|
return new PageResult<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ReportInfoResp> respList = PipReportInfoConverter.INSTANCE.toRespList(pipReportInfoPage.getRecords());
|
||||||
|
return new PageResult<>(respList,pipReportInfoPage.getTotal(),pipReportInfoPage.getCurrent(),pipReportInfoPage.getSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private HttpHeaders createHeaders() {
|
private HttpHeaders createHeaders() {
|
||||||
@ -370,6 +534,45 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<PipReportInfo> setReportInfoToCreate(JSONObject data,String scaTaskId,String taskId) {
|
||||||
|
List<PipReportInfo> pipReportInfos = new ArrayList<>();
|
||||||
|
JSONArray records = data.getJSONArray("records");
|
||||||
|
|
||||||
|
String creator = "";
|
||||||
|
//根据taskId查询流水线信息并且设置漏洞归属人
|
||||||
|
PipTask pipTask = pipTaskDao.selectById(taskId);
|
||||||
|
if (!ObjectUtils.isEmpty(pipTask)){
|
||||||
|
PipPipeline pipeline = pipelineDao.selectById(pipTask.getPipelineId());
|
||||||
|
creator = pipeline.getCreator();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < records.size(); i++) {
|
||||||
|
JSONObject report = records.getJSONObject(i);
|
||||||
|
PipReportInfo pipReportInfo = new PipReportInfo();
|
||||||
|
Long loginUserId = WebFrameworkUtils.getLoginUserId();
|
||||||
|
|
||||||
|
pipReportInfo.setTaskId(taskId);
|
||||||
|
pipReportInfo.setScaTaskId(scaTaskId);
|
||||||
|
pipReportInfo.setSecurityLevelId(report.getInteger("securityLevelId"));
|
||||||
|
pipReportInfo.setVulName(report.getString("vulName"));
|
||||||
|
pipReportInfo.setCveId(report.getString("cveId"));
|
||||||
|
pipReportInfo.setCweId(report.getString("cweId"));
|
||||||
|
pipReportInfo.setCnnvdId(report.getString("cnnvdId"));
|
||||||
|
pipReportInfo.setCnvdId(report.getString("cnvdId"));
|
||||||
|
pipReportInfo.setVulType(report.getString("vulType"));
|
||||||
|
pipReportInfo.setVulMarkStatus(report.getString("vulMarkStatus"));
|
||||||
|
pipReportInfo.setAttackType(report.getString("attackType"));
|
||||||
|
pipReportInfo.setCvssV2Score(report.getDouble("cvssV2Score"));
|
||||||
|
pipReportInfo.setCvssV3Score(report.getDouble("cvssV3Score"));
|
||||||
|
pipReportInfo.setExploitLevelIndex(report.getInteger("exploitLevelIndex"));
|
||||||
|
pipReportInfo.setReleaseDate(report.getString("releaseDate"));
|
||||||
|
pipReportInfo.setCreator(creator);
|
||||||
|
pipReportInfos.add(pipReportInfo);
|
||||||
|
}
|
||||||
|
return pipReportInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public enum FileType {
|
public enum FileType {
|
||||||
// 文档类
|
// 文档类
|
||||||
XLSX("xlsx", "Excel", new byte[]{0x50, 0x4B, 0x03, 0x04}),
|
XLSX("xlsx", "Excel", new byte[]{0x50, 0x4B, 0x03, 0x04}),
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package cd.casic.ci.process.process.service.testCase;
|
||||||
|
|
||||||
|
|
||||||
|
import cd.casic.ci.process.dto.req.testCase.TestCaseInfoQueryReq;
|
||||||
|
import cd.casic.ci.process.dto.req.testCase.TestCaseInfoReq;
|
||||||
|
import cd.casic.ci.process.dto.resp.testCase.TestCaseInfoResp;
|
||||||
|
import cd.casic.ci.process.process.dataObject.testCase.TestCaseInfo;
|
||||||
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author HopeLi
|
||||||
|
* @version v1.0
|
||||||
|
* @ClassName PipelineService
|
||||||
|
* @Date: 2025/5/13 10:27
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public interface TestCaseInfoService extends IService<TestCaseInfo> {
|
||||||
|
|
||||||
|
String create(@Valid TestCaseInfoReq req);
|
||||||
|
|
||||||
|
void delete(String id);
|
||||||
|
|
||||||
|
void updateTestCase(@Valid TestCaseInfoReq req);
|
||||||
|
|
||||||
|
List<TestCaseInfoResp> findList(@Valid TestCaseInfoQueryReq query);
|
||||||
|
|
||||||
|
PageResult<TestCaseInfoResp> findPage(@Valid TestCaseInfoQueryReq query);
|
||||||
|
|
||||||
|
TestCaseInfoResp findById(String id);
|
||||||
|
}
|
@ -0,0 +1,118 @@
|
|||||||
|
package cd.casic.ci.process.process.service.testCase.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import cd.casic.ci.process.dto.req.testCase.TestCaseInfoQueryReq;
|
||||||
|
import cd.casic.ci.process.dto.req.testCase.TestCaseInfoReq;
|
||||||
|
import cd.casic.ci.process.dto.resp.testCase.TestCaseInfoResp;
|
||||||
|
import cd.casic.ci.process.process.converter.TestCaseInfoConverter;
|
||||||
|
import cd.casic.ci.process.process.dao.testCase.TestCaseInfoDao;
|
||||||
|
import cd.casic.ci.process.process.dataObject.testCase.TestCaseInfo;
|
||||||
|
import cd.casic.ci.process.process.service.testCase.TestCaseInfoService;
|
||||||
|
import cd.casic.framework.commons.exception.ServiceException;
|
||||||
|
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
||||||
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
|
import cd.casic.framework.security.dal.user.AdminUserDO;
|
||||||
|
import cd.casic.framework.tenant.core.service.AdminUserServiceImpl;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author HopeLi
|
||||||
|
* @version v1.0
|
||||||
|
* @ClassName PipelineServiceImpl
|
||||||
|
* @Date: 2025/5/13 10:31
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class TestCaseInfoServiceImpl extends ServiceImpl<TestCaseInfoDao, TestCaseInfo> implements TestCaseInfoService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TestCaseInfoDao testCaseInfoDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AdminUserServiceImpl adminUserService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String create(TestCaseInfoReq req) {
|
||||||
|
TestCaseInfo testCaseInfo = TestCaseInfoConverter.INSTANCE.toBean(req);
|
||||||
|
testCaseInfoDao.insert(testCaseInfo);
|
||||||
|
return testCaseInfo.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(String id) {
|
||||||
|
testCaseInfoDao.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTestCase(TestCaseInfoReq req) {
|
||||||
|
TestCaseInfo testCaseInfo = TestCaseInfoConverter.INSTANCE.toBean(req);
|
||||||
|
testCaseInfoDao.updateById(testCaseInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TestCaseInfoResp> findList(TestCaseInfoQueryReq query) {
|
||||||
|
QueryWrapper<TestCaseInfo> wrapper = new QueryWrapper<>();
|
||||||
|
List<TestCaseInfo> testCaseInfos = testCaseInfoDao.selectList(wrapper);
|
||||||
|
|
||||||
|
if (ObjectUtils.isEmpty(testCaseInfos)){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
List<TestCaseInfoResp> respList = TestCaseInfoConverter.INSTANCE.toRespList(testCaseInfos);
|
||||||
|
respList.forEach(this::setUserName);
|
||||||
|
return respList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<TestCaseInfoResp> findPage(TestCaseInfoQueryReq query) {
|
||||||
|
QueryWrapper<TestCaseInfo> wrapper = new QueryWrapper<>();
|
||||||
|
Page<TestCaseInfo> testCaseInfoPage = testCaseInfoDao.selectPage(new Page<>(query.getPageNo(), query.getPageSize()), wrapper);
|
||||||
|
if (ObjectUtils.isEmpty(testCaseInfoPage)){
|
||||||
|
return new PageResult<>();
|
||||||
|
}
|
||||||
|
List<TestCaseInfoResp> respList = TestCaseInfoConverter.INSTANCE.toRespList(testCaseInfoPage.getRecords());
|
||||||
|
respList.forEach(this::setUserName);
|
||||||
|
return new PageResult<>(respList,testCaseInfoPage.getTotal(),testCaseInfoPage.getCurrent(),testCaseInfoPage.getSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TestCaseInfoResp findById(String id) {
|
||||||
|
TestCaseInfo testCaseInfo = testCaseInfoDao.selectById(id);
|
||||||
|
if (ObjectUtils.isEmpty(testCaseInfo)){
|
||||||
|
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"数据错误请联系管理员");
|
||||||
|
}
|
||||||
|
TestCaseInfoResp testCaseInfoResp = TestCaseInfoConverter.INSTANCE.toResp(testCaseInfo);
|
||||||
|
setUserName(testCaseInfoResp);
|
||||||
|
return testCaseInfoResp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void setUserName(TestCaseInfoResp testCaseInfoResp) {
|
||||||
|
if (!StringUtils.isEmpty(testCaseInfoResp.getCreator())){
|
||||||
|
AdminUserDO user = adminUserService.getUser(Long.valueOf(testCaseInfoResp.getCreator()));
|
||||||
|
if (!ObjectUtils.isEmpty(user)){
|
||||||
|
testCaseInfoResp.setCreatorName(user.getUsername());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(testCaseInfoResp.getUpdater())){
|
||||||
|
AdminUserDO user = adminUserService.getUser(Long.valueOf(testCaseInfoResp.getUpdater()));
|
||||||
|
if (!ObjectUtils.isEmpty(user)){
|
||||||
|
testCaseInfoResp.setUpdaterName(user.getUsername());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -71,9 +71,9 @@ spring:
|
|||||||
data:
|
data:
|
||||||
redis:
|
redis:
|
||||||
host: 127.0.0.1 # 地址
|
host: 127.0.0.1 # 地址
|
||||||
port: 16379 # 端口
|
# port: 16379 # 端口
|
||||||
# host: 192.168.1.120 # 地址
|
# host: 192.168.1.120 # 地址
|
||||||
# port: 6379 # 端口
|
port: 6379 # 端口
|
||||||
database: 0 # 数据库索引
|
database: 0 # 数据库索引
|
||||||
# password: dev # 密码,建议生产环境开启
|
# password: dev # 密码,建议生产环境开启
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user