Search in sources :

Example 1 with ProjectScanLog

use of com.mercedesbenz.sechub.domain.scan.log.ProjectScanLog in project sechub by mercedes-benz.

the class DownloadsFullScanDataForJobRestDocTest method before.

@Before
public void before() {
    jobUUID = UUID.randomUUID();
    FullScanData data = new FullScanData();
    ScanData d = new ScanData();
    d.productId = "productX";
    d.result = "{ 'result':'OK'}";
    d.metaData = "{}";
    data.allScanData.add(d);
    String config = "{}";
    ProjectScanLog log = new ProjectScanLog("theProject", jobUUID, "spartakus", config);
    data.allScanLogs.add(log);
    when(fullScanDataService.getFullScanData(jobUUID)).thenReturn(data);
}
Also used : FullScanData(com.mercedesbenz.sechub.domain.scan.admin.FullScanData) ProjectScanLog(com.mercedesbenz.sechub.domain.scan.log.ProjectScanLog) ScanData(com.mercedesbenz.sechub.domain.scan.admin.ScanData) FullScanData(com.mercedesbenz.sechub.domain.scan.admin.FullScanData) Before(org.junit.Before)

Example 2 with ProjectScanLog

use of com.mercedesbenz.sechub.domain.scan.log.ProjectScanLog in project sechub by mercedes-benz.

the class FullScanDataToZipOutputSupportTest method createFullScanDataTwoProductsOneLogEntry.

private FullScanData createFullScanDataTwoProductsOneLogEntry() {
    FullScanData fullScanData = new FullScanData();
    ScanData data1 = new ScanData();
    data1.productId = "product1";
    data1.result = "{ 'result' : 'OK'}";
    data1.metaData = "{ \"metadata\" : \"product1\" }";
    ScanData data2 = new ScanData();
    data2.productId = "product2";
    data2.result = "<?xml version='1.0'>\n<result>NOT-OK</result>}";
    data2.metaData = "{ \"metadata\" : \"product2\" }";
    fullScanData.allScanData.add(data1);
    fullScanData.allScanData.add(data2);
    ProjectScanLog log1 = new ProjectScanLog("project1", sechubJobUUID, "executor1", "{'config':'heavy'}");
    fullScanData.allScanLogs.add(log1);
    return fullScanData;
}
Also used : ProjectScanLog(com.mercedesbenz.sechub.domain.scan.log.ProjectScanLog)

Example 3 with ProjectScanLog

use of com.mercedesbenz.sechub.domain.scan.log.ProjectScanLog in project sechub by mercedes-benz.

the class FullScanDataService method getFullScanData.

@UseCaseAdminDownloadsFullScanDataForJob(@Step(number = 2, name = "Collect all scan data"))
public FullScanData getFullScanData(UUID sechubJobUUID) {
    assertion.assertIsValidJobUUID(sechubJobUUID);
    LOG.debug("Start getting full scan data for {}", sechubJobUUID);
    FullScanData data = new FullScanData();
    data.sechubJobUUID = sechubJobUUID;
    List<ProjectScanLog> logs = projectScanLogService.fetchLogsForJob(sechubJobUUID);
    data.allScanLogs.addAll(logs);
    List<ProductResult> results = productResultService.fetchAllResultsForJob(sechubJobUUID);
    for (ProductResult result : results) {
        ScanData scanData = new ScanData();
        scanData.productId = result.getProductIdentifier().toString();
        scanData.executorConfigUUID = result.getProductExecutorConfigUUID();
        scanData.result = result.getResult();
        scanData.metaData = result.getMetaData();
        data.allScanData.add(scanData);
    }
    return data;
}
Also used : ProductResult(com.mercedesbenz.sechub.domain.scan.product.ProductResult) ProjectScanLog(com.mercedesbenz.sechub.domain.scan.log.ProjectScanLog) UseCaseAdminDownloadsFullScanDataForJob(com.mercedesbenz.sechub.sharedkernel.usecases.admin.project.UseCaseAdminDownloadsFullScanDataForJob)

Example 4 with ProjectScanLog

use of com.mercedesbenz.sechub.domain.scan.log.ProjectScanLog in project sechub by mercedes-benz.

the class FullScanDataToZipOutputSupport method writeScanData.

public void writeScanData(FullScanData data, OutputStream outputStream) throws IOException {
    List<String> fileNamesAlreadyUsed = new ArrayList<>();
    try (ZipOutputStream zippedOut = new ZipOutputStream(outputStream)) {
        for (ProjectScanLog log : data.allScanLogs) {
            writeStringAsZipFileEntry(zippedOut, log.toString(), "log_" + log.getUUID(), fileNamesAlreadyUsed);
        }
        for (ScanData scanData : data.allScanData) {
            writeStringAsZipFileEntry(zippedOut, scanData.result, createFilenamePart(scanData), fileNamesAlreadyUsed);
            String metaData = scanData.metaData;
            if (metaData == null) {
                metaData = "{ \"message\" : \"no meta data available\" }";
            }
            writeStringAsZipFileEntry(zippedOut, metaData, "metadata_" + createFilenamePart(scanData), fileNamesAlreadyUsed);
        }
        zippedOut.closeEntry();
        zippedOut.finish();
    }
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) ProjectScanLog(com.mercedesbenz.sechub.domain.scan.log.ProjectScanLog) ArrayList(java.util.ArrayList)

Aggregations

ProjectScanLog (com.mercedesbenz.sechub.domain.scan.log.ProjectScanLog)4 FullScanData (com.mercedesbenz.sechub.domain.scan.admin.FullScanData)1 ScanData (com.mercedesbenz.sechub.domain.scan.admin.ScanData)1 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)1 UseCaseAdminDownloadsFullScanDataForJob (com.mercedesbenz.sechub.sharedkernel.usecases.admin.project.UseCaseAdminDownloadsFullScanDataForJob)1 ArrayList (java.util.ArrayList)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 Before (org.junit.Before)1