Search in sources :

Example 6 with Sources

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;
}
Also used : Sources(com.checkmarx.flow.dto.Sources)

Example 7 with 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;
}
Also used : Sources(com.checkmarx.flow.dto.Sources)

Example 8 with 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;
}
Also used : Sources(com.checkmarx.flow.dto.Sources)

Example 9 with 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);
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) Sources(com.checkmarx.flow.dto.Sources) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test) IfProfileValue(org.springframework.test.annotation.IfProfileValue)

Example 10 with 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");
    }
}
Also used : FlowProperties(com.checkmarx.flow.config.FlowProperties) HashMap(java.util.HashMap) CxProfile(com.checkmarx.flow.dto.CxProfile) IOException(java.io.IOException) Sources(com.checkmarx.flow.dto.Sources) CxProperties(com.checkmarx.sdk.config.CxProperties) JiraProperties(com.checkmarx.flow.config.JiraProperties) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Sources (com.checkmarx.flow.dto.Sources)11 JSONObject (org.json.JSONObject)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)3 ScanRequest (com.checkmarx.flow.dto.ScanRequest)2 HashMap (java.util.HashMap)2 HttpHeaders (org.springframework.http.HttpHeaders)2 IfProfileValue (org.springframework.test.annotation.IfProfileValue)2 FlowProperties (com.checkmarx.flow.config.FlowProperties)1 JiraProperties (com.checkmarx.flow.config.JiraProperties)1 CxProfile (com.checkmarx.flow.dto.CxProfile)1 CxProperties (com.checkmarx.sdk.config.CxProperties)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 IOException (java.io.IOException)1 JSONArray (org.json.JSONArray)1 DefaultUriBuilderFactory (org.springframework.web.util.DefaultUriBuilderFactory)1