Search in sources :

Example 56 with ScanRequest

use of com.checkmarx.flow.dto.ScanRequest in project cx-flow by checkmarx-ltd.

the class SanitizingFilenameFormatterTest method format_parentDirs_sanitizingCorrectly.

@Test
void format_parentDirs_sanitizingCorrectly() {
    SanitizingFilenameFormatter formatter = new SanitizingFilenameFormatter();
    ScanRequest request = ScanRequest.builder().build();
    String formatted = formatter.formatPath(request, "../../../output.csv", BASE_DIR);
    assertEquals(EXPECTED_RESULT, formatted, "Sanitizing doesn't work as expected.");
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) Test(org.junit.jupiter.api.Test)

Example 57 with ScanRequest

use of com.checkmarx.flow.dto.ScanRequest in project cx-flow by checkmarx-ltd.

the class SanitizingFilenameFormatterTest method format_placeholders_replacementWorks.

@Test
void format_placeholders_replacementWorks() {
    SanitizingFilenameFormatter formatter = new SanitizingFilenameFormatter();
    ScanRequest request = ScanRequest.builder().team("ninjas").application("CX").project("ePayment").namespace("myOrg").repoName("myRepo").branch("fixed-last-bug").build();
    final String filenameTemplate = "[TEAM]-[APP]-[PROJECT]-[NAMESPACE]-[REPO]-[BRANCH].csv";
    final String expected = String.format("%s/ninjas-CX-ePayment-myOrg-myRepo-fixed-last-bug.csv", BASE_DIR);
    String actual = formatter.formatPath(request, filenameTemplate, BASE_DIR);
    assertEquals(expected, actual, "Unexpected path after formatting by template.");
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) Test(org.junit.jupiter.api.Test)

Example 58 with ScanRequest

use of com.checkmarx.flow.dto.ScanRequest in project cx-flow by checkmarx-ltd.

the class ScanUtilsTest method testCxConfigOverride.

@Test
public void testCxConfigOverride() {
    ScanRequest request = ScanRequest.builder().application("abc").product(ScanRequest.Product.CX).project("test").team("\\CxServer\\SP\\Checkmarx").namespace("Custodela").repoName("Riches").repoUrl("https://github.com/Custodela/Riches.git").repoType(ScanRequest.Repository.GITHUB).branch("master").refs(Constants.CX_BRANCH_PREFIX.concat("master")).email(null).incremental(true).scanPreset(Constants.CX_DEFAULT_PRESET).build();
    File file = new File(getClass().getClassLoader().getResource("CxConfig.json").getFile());
    CxConfig cxConfig = ScanUtils.getConfigAsCode(file);
    assertNotNull(cxConfig);
    configOverrider.overrideScanRequestProperties(cxConfig, request);
    assertEquals("/a/b/c", request.getTeam());
    assertEquals("XYZ-Riches-master", request.getProject());
    assertFalse(request.isIncremental());
    assertEquals("All", request.getScanPreset());
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) CxConfig(com.checkmarx.sdk.dto.sast.CxConfig) File(java.io.File) Test(org.junit.Test)

Example 59 with ScanRequest

use of com.checkmarx.flow.dto.ScanRequest in project cx-flow by checkmarx-ltd.

the class ScaZipScanSteps method initScan.

@When("initiating a new scan")
public void initScan() {
    ScanRequest scanRequest = getBasicScanRequest(PROJECT_NAME, GIT_REPO_URL);
    ScanResults scanResults = scaScanner.scan(scanRequest);
    scaResults = Objects.requireNonNull(scanResults).getScaResults();
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) ScanResults(com.checkmarx.sdk.dto.ScanResults) When(io.cucumber.java.en.When)

Example 60 with ScanRequest

use of com.checkmarx.flow.dto.ScanRequest in project cx-flow by checkmarx-ltd.

the class AbstractScanSteps method callSast.

protected ScanDTO callSast() {
    ScanRequest request = generateRequest();
    try {
        scanDetails = sastScanner.executeCxScan(request, fileRepo);
        CompletableFuture<ScanResults> future = new CompletableFuture<>();
        // TODO async these, and join and merge after
        results = cxClient.getReportContentByScanId(scanDetails.getScanId(), request.getFilter());
        future.complete(results);
        results = future.join();
        errorExpected = false;
        return retainOutputValues();
    } catch (Exception e) {
        if (!errorExpected) {
            fail(e.getMessage());
        }
        return null;
    }
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) CompletableFuture(java.util.concurrent.CompletableFuture) ScanResults(com.checkmarx.sdk.dto.ScanResults)

Aggregations

ScanRequest (com.checkmarx.flow.dto.ScanRequest)68 BugTracker (com.checkmarx.flow.dto.BugTracker)24 ScanResults (com.checkmarx.sdk.dto.ScanResults)20 When (io.cucumber.java.en.When)14 FilterConfiguration (com.checkmarx.sdk.dto.filtering.FilterConfiguration)12 MachinaException (com.checkmarx.flow.exception.MachinaException)11 CxConfig (com.checkmarx.sdk.dto.sast.CxConfig)11 Test (org.junit.Test)11 File (java.io.File)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 Issue (com.checkmarx.flow.dto.Issue)5 MachinaRuntimeException (com.checkmarx.flow.exception.MachinaRuntimeException)5 IOException (java.io.IOException)5 ExecutionException (java.util.concurrent.ExecutionException)5 TimeoutException (java.util.concurrent.TimeoutException)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 IfProfileValue (org.springframework.test.annotation.IfProfileValue)4 EventResponse (com.checkmarx.flow.dto.EventResponse)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 FlowProperties (com.checkmarx.flow.config.FlowProperties)2