Search in sources :

Example 1 with RepoReader

use of com.checkmarx.configprovider.readers.RepoReader in project cx-flow by checkmarx-ltd.

the class GitHubService method initConfigProviderOnPushEvent.

public void initConfigProviderOnPushEvent(String uid, PushEvent event) {
    if (properties != null) {
        try {
            ConfigProvider configProvider = ConfigProvider.getInstance();
            Repository repository = event.getRepository();
            // According to GitHub the recommended way to extract the branch name
            // is by using the 'ref' parameter which is in the following format: 'refs/heads/<branch>'
            configProvider.init(uid, new RepoReader(properties.getApiUrl(), repository.getOwner().getName(), repository.getName(), ScanUtils.getBranchFromRef(event.getRef()), properties.getToken(), SourceProviderType.GITHUB));
        } catch (ConfigurationException e) {
            log.warn("Failed to init config provider with the following error: {}", e.getMessage());
        }
    }
}
Also used : Repository(com.checkmarx.flow.dto.github.Repository) RepoReader(com.checkmarx.configprovider.readers.RepoReader) ConfigProvider(com.checkmarx.configprovider.ConfigProvider) ConfigurationException(javax.naming.ConfigurationException)

Example 2 with RepoReader

use of com.checkmarx.configprovider.readers.RepoReader in project cx-flow by checkmarx-ltd.

the class GitHubService method initConfigProviderOnPullEvent.

public void initConfigProviderOnPullEvent(String uid, PullEvent event) {
    if (properties != null) {
        try {
            ConfigProvider configProvider = ConfigProvider.getInstance();
            Repository repository = event.getRepository();
            String branch = event.getPullRequest().getHead().getRef();
            configProvider.init(uid, new RepoReader(properties.getApiUrl(), repository.getOwner().getLogin(), repository.getName(), branch, properties.getToken(), SourceProviderType.GITHUB));
        } catch (ConfigurationException e) {
            log.warn("Failed to init config provider with the following error: {}", e.getMessage());
        }
    }
}
Also used : Repository(com.checkmarx.flow.dto.github.Repository) RepoReader(com.checkmarx.configprovider.readers.RepoReader) ConfigProvider(com.checkmarx.configprovider.ConfigProvider) ConfigurationException(javax.naming.ConfigurationException)

Example 3 with RepoReader

use of com.checkmarx.configprovider.readers.RepoReader in project cx-flow by checkmarx-ltd.

the class ConfigProviderRemoteRepoSteps method initConfigProvider.

@When("initializing config provider")
public void initConfigProvider() throws ConfigurationException {
    String nameSpace = "cxflowtestuser";
    String repoName = "configProviderTestRepo";
    String branchName = "main";
    ConfigProvider configProvider = ConfigProvider.getInstance();
    configProvider.init(uid, new RepoReader(gitHubProperties.getApiUrl(), nameSpace, repoName, branchName, gitHubProperties.getToken(), sourceProviderType));
}
Also used : RepoReader(com.checkmarx.configprovider.readers.RepoReader) ConfigProvider(com.checkmarx.configprovider.ConfigProvider) When(io.cucumber.java.en.When)

Aggregations

ConfigProvider (com.checkmarx.configprovider.ConfigProvider)3 RepoReader (com.checkmarx.configprovider.readers.RepoReader)3 Repository (com.checkmarx.flow.dto.github.Repository)2 ConfigurationException (javax.naming.ConfigurationException)2 When (io.cucumber.java.en.When)1