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.");
}
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.");
}
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());
}
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();
}
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;
}
}
Aggregations