Selaa lähdekoodia

update: interface

guochao 5 vuotta sitten
vanhempi
commit
e37a27f6e9

+ 3 - 49
.idea/workspace.xml

@@ -2,55 +2,8 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="c25ee83f-38b8-4a56-8a1f-62ecc8d6cec2" name="Default Changelist" comment="">
-      <change afterPath="$PROJECT_DIR$/target/classes/application.properties" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/application.yml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/bootstrap.yaml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/Application.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/service/AutoReportProductService.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/service/impl/AutoReportProductServiceImpl$1.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/service/impl/AutoReportProductServiceImpl$2.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/service/impl/AutoReportProductServiceImpl.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/ctrl/HandleReportController.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/enums/VulVerifyStatus.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/Bug.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/DeviceBugListItem.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/DeviceDetailItem.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/DeviceDistributionData.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/DeviceUCListItem.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/FunctionalTestVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/GeneralResult.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/ScreenShot.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/TypePassResult.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/UCItemCaseInfo.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/UCPassResult.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/UCResultDeviceItem.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/functionalTestData/UCResultItem.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/ActiveIssueDetailVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/AppBasicInfoVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/DeviceDetailVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/IssueDistributionAttributeVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/IssueDistributionVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/IssuePhoneVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/NeedOptimizedProblemVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/PerformanceDetailAttributeVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/PerformanceDetailItemVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/PerformanceSummaryAttributeVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/PerformanceSummaryItemVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/PieDataVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/ReportDataVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/reportData/TestResultVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/vulData/ProjectInfoVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/vulData/StatVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/vulData/Vul2TaskVo.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/vulData/VulCheckVo.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/vulData/VulReferenceVo.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/vulData/VulReportDataVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/vulData/VulStatisticsVO.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/classes/cn/iselab/mooctest/site/web/data/vulData/VulnerabilityVo.class" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/target/test-classes/com/example/demo/DemoApplicationTests.class" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/cn/iselab/mooctest/site/service/impl/AutoReportProductServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/cn/iselab/mooctest/site/service/impl/AutoReportProductServiceImpl.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.yml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/cn/iselab/mooctest/site/web/ctrl/HandleReportController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/cn/iselab/mooctest/site/web/ctrl/HandleReportController.java" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
@@ -156,7 +109,8 @@
       <workItem from="1573797788287" duration="4744000" />
       <workItem from="1573803183351" duration="6316000" />
       <workItem from="1573817067721" duration="3410000" />
-      <workItem from="1573886504964" duration="5212000" />
+      <workItem from="1573886504964" duration="7019000" />
+      <workItem from="1574039613479" duration="1254000" />
     </task>
     <servers />
   </component>

+ 46 - 29
src/main/java/cn/iselab/mooctest/site/web/ctrl/HandleReportController.java

@@ -14,11 +14,8 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.server.reactive.ServerHttpResponse;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.*;
 import com.google.gson.Gson;
-import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
@@ -46,43 +43,63 @@ public class HandleReportController {
 
     private static final Logger log = LoggerFactory.getLogger(Process.class.getName());
 
-    @RequestMapping(value = "/generate/report/{orderId}/{ownerId}", method = RequestMethod.GET)
-    public String generateReport(@PathVariable(value = "orderId") Long orderId, @PathVariable(value = "ownerId") Long ownerId){
-        List<String> menus = new ArrayList<>();
-        menus.add("APK扫描");
-        ProjectInfoVO projectInfoVO = new ProjectInfoVO();
-        projectInfoVO.setCostTime("2019/11/15");
-        projectInfoVO.setProjectName("途牛APP");
-        projectInfoVO.setStartTime(new Timestamp(new Date().getTime()));
-        projectInfoVO.setUserName("郭超");
-        List<VulnerabilityVo> vulnerabilityVos = new ArrayList<>();
-        VulStatisticsVO vulStatisticsVO = new VulStatisticsVO();
-
-        VulReportDataVO vulReportDataVO = new VulReportDataVO();
-        vulReportDataVO.setMenus(menus);
-        vulReportDataVO.setProjectInfo(projectInfoVO);
-        vulReportDataVO.setVulnerability(vulnerabilityVos);
-        vulReportDataVO.setVulStatistics(vulStatisticsVO);
-        System.out.println(vulReportDataVO.toString());
-        handleReport(orderId, ownerId, vulReportDataVO);
-        return "http://"+HOST_IP+"/reportFile/"+ownerId+"/"+orderId+"/vulReport/dist/vulResults.html";
-    }
+//    @RequestMapping(value = "/generate/report/{orderId}/{ownerId}", method = RequestMethod.GET)
+//    public String generateReport(@PathVariable(value = "orderId") Long orderId, @PathVariable(value = "ownerId") Long ownerId){
+//        List<String> menus = new ArrayList<>();
+//        menus.add("APK扫描");
+//        ProjectInfoVO projectInfoVO = new ProjectInfoVO();
+//        projectInfoVO.setCostTime("2019/11/15");
+//        projectInfoVO.setProjectName("途牛APP");
+//        projectInfoVO.setStartTime(new Timestamp(new Date().getTime()));
+//        projectInfoVO.setUserName("郭超");
+//        List<VulnerabilityVo> vulnerabilityVos = new ArrayList<>();
+//        VulStatisticsVO vulStatisticsVO = new VulStatisticsVO();
+//
+//        VulReportDataVO vulReportDataVO = new VulReportDataVO();
+//        vulReportDataVO.setMenus(menus);
+//        vulReportDataVO.setProjectInfo(projectInfoVO);
+//        vulReportDataVO.setVulnerability(vulnerabilityVos);
+//        vulReportDataVO.setVulStatistics(vulStatisticsVO);
+//        System.out.println(vulReportDataVO.toString());
+//        handleReport(orderId, ownerId, vulReportDataVO);
+//
+//    }
 
 
     //    @RequiresPermissions("task:create")
 //    @RequestMapping(value = "generate/report", method = RequestMethod.POST)
-    private void handleReport(Long orderId, Long ownerId, VulReportDataVO reportData) {
+//    private void handleReport(Long orderId, Long ownerId, VulReportDataVO reportData) {
+//        String builderPath = autoReportProductService.copyReportBuilderToPath(orderId, "static-scan-report");
+//        autoReportProductService.writeDataToJsonFile(new Gson().toJson(reportData), builderPath + REPORT_JSON_UPLOAD_PATH);
+//        boolean bale = autoReportProductService.runBuilderToProductReport("npm run build", builderPath + "/static-scan-report/");
+//        if (bale) {
+//            reportTransferToPath(orderId, ownerId, builderPath + "/static-scan-report/");
+//        }
+//    }
+
+    /**
+     *
+     * @param orderId 任务ID
+     * @param ownerId 用户ID
+     * @param reportData
+     * @return
+     */
+    @RequestMapping(value = "/generate/report/order/{orderId}/owner/{ownerId}", method = RequestMethod.POST)
+    private String handleReport(@PathVariable(value = "orderId") Long orderId,
+                                @PathVariable(value = "ownerId") Long ownerId,
+                                @RequestBody VulReportDataVO reportData) {
         String builderPath = autoReportProductService.copyReportBuilderToPath(orderId, "static-scan-report");
         autoReportProductService.writeDataToJsonFile(new Gson().toJson(reportData), builderPath + REPORT_JSON_UPLOAD_PATH);
         boolean bale = autoReportProductService.runBuilderToProductReport("npm run build", builderPath + "/static-scan-report/");
         if (bale) {
             reportTransferToPath(orderId, ownerId, builderPath + "/static-scan-report/");
         }
+        return "http://" + HOST_IP + "/reportFile/" + ownerId + "/" + orderId + "/vulReport/dist/vulResults.html";
     }
 
     private void reportTransferToPath(Long orderId, Long ownerId, String path) {
         String autoReportPath = REPORT_UPLOAD_PATH + ownerId + "/" + orderId + "/vulReport";
-        String downloadPath = autoReportPath+"/report.zip";
+        String downloadPath = autoReportPath + "/report.zip";
         File uploadFile = new File(autoReportPath);
         File downloadFile = new File(downloadPath);
         boolean sign = uploadFile.mkdirs();
@@ -94,11 +111,11 @@ public class HandleReportController {
             ZipParameters parameters = new ZipParameters();
             parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
             parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
-            zipFile.addFolder(new File(autoReportPath+ "/dist"),parameters);
+            zipFile.addFolder(new File(autoReportPath + "/dist"), parameters);
             log.info("----------------拷贝结束-------------------");
         } catch (IOException e) {
             log.info("----------copy error{}---------", e);
-        }catch (ZipException e){
+        } catch (ZipException e) {
             log.info("----------copy error{}---------", e);
         }
     }