use of com.checkmarx.flow.dto.Sources in project cx-flow by checkmarx-ltd.
the class GitHubService method getRepoContent.
@Override
public Sources getRepoContent(ScanRequest request) {
log.debug("Auto profiling is enabled");
if (ScanUtils.anyEmpty(request.getNamespace(), request.getRepoName(), request.getBranch())) {
return null;
}
Sources sources = getRepoLanguagePercentages(request);
String endpoint = getGitHubEndPoint(request);
scanGitContent(0, endpoint, sources, request);
return sources;
}
use of com.checkmarx.flow.dto.Sources in project cx-flow by checkmarx-ltd.
the class GitLabService method getRepoContent.
@Override
public Sources getRepoContent(ScanRequest request) {
log.debug("Auto profiling is enabled");
if (ScanUtils.empty(request.getBranch()) || request.getRepoProjectId() == null) {
return null;
}
Sources sources = getRepoLanguagePercentages(request);
scanGitContent(sources, request);
return sources;
}
use of com.checkmarx.flow.dto.Sources in project cx-flow by checkmarx-ltd.
the class BitBucketService method getRepoContent.
@Override
public Sources getRepoContent(ScanRequest request) {
log.debug("Auto profiling is enabled");
if (ScanUtils.anyEmpty(request.getNamespace(), request.getRepoName(), request.getBranch())) {
return null;
}
Sources sources = new Sources();
browseRepoEndpoint = getBitbucketEndPoint(request);
if (request.getRepoType().equals(ScanRequest.Repository.BITBUCKETSERVER)) {
scanGitContentFromBitbucketServer(0, browseRepoEndpoint, request.getScmInstance(), sources);
} else {
scanGitContentFromBBCloud(browseRepoEndpoint, request.getScmInstance(), sources);
}
return sources;
}
use of com.checkmarx.flow.dto.Sources in project cx-flow by checkmarx-ltd.
the class GitLabServiceTest method getSources.
@IfProfileValue(name = "testprofile", value = "integration")
@Test
public void getSources() {
ScanRequest request = ScanRequest.builder().namespace("custodela-test").repoName("WebGoat").branch("develop").build();
request.setRepoProjectId(11842418);
Sources sources = service.getRepoContent(request);
assertNotNull(sources);
}
use of com.checkmarx.flow.dto.Sources in project cx-flow by checkmarx-ltd.
the class HelperServiceTest method testGetPresetFromSources.
@Test
public void testGetPresetFromSources() {
FlowProperties properties = new FlowProperties();
CxProperties cxProperties = new CxProperties();
JiraProperties jiraProperties = new JiraProperties();
cxProperties.setScanPreset(Constants.CX_DEFAULT_PRESET);
CxScannerService cxScannerService = new CxScannerService(cxProperties, null, null, null, null);
HelperService helperService = new HelperService(properties, cxScannerService, jiraProperties, null);
Sources sources = new Sources();
Sources.Source src1 = new Sources.Source();
src1.setFile("abc.java");
src1.setPath("abc.java");
Sources.Source src2 = new Sources.Source();
src2.setFile("abc.html");
src2.setPath("abc.html");
Sources.Source src3 = new Sources.Source();
src3.setFile("abc.css");
src3.setPath("abc.css");
Sources.Source src4 = new Sources.Source();
src4.setFile("buildspec.yml");
src4.setPath("buildspec.yml");
Map<String, Integer> sourceWeight = new HashMap<>();
sourceWeight.put("Java", 65);
sourceWeight.put("CSS", 15);
sourceWeight.put("HTML", 20);
sources.setLanguageStats(sourceWeight);
sources.setSources(Arrays.asList(src1, src2, src3, src4));
ObjectMapper mapper = new ObjectMapper();
System.out.println(HelperService.class.getResource(".").getPath());
File file = new File(getClass().getClassLoader().getResource("CxProfile.json").getFile());
try {
CxProfile[] cxProfiles = mapper.readValue(file, CxProfile[].class);
helperService.setProfiles(Arrays.asList(cxProfiles));
String preset = helperService.getPresetFromSources(sources);
assertEquals(preset, "Checkmarx Express");
} catch (IOException e) {
fail("Unexpected IO Exception");
}
}
Aggregations