Search in sources :

Example 1 with DependencyRule

use of com.walmartlabs.concord.policyengine.DependencyRule in project concord by walmartlabs.

the class RunnerJobExecutor method validateDependencies.

private void validateDependencies(RunnerJob job, Collection<DependencyEntity> resolvedDepEntities) throws ExecutionException {
    PolicyEngine policyEngine = job.getPolicyEngine();
    if (policyEngine == null) {
        return;
    }
    ProcessLog processLog = job.getLog();
    processLog.info("Checking the dependency policy...");
    CheckResult<DependencyRule, DependencyEntity> result = policyEngine.getDependencyPolicy().check(resolvedDepEntities);
    result.getWarn().forEach(d -> processLog.warn("Potentially restricted artifact '{}' (dependency policy: {})", d.getEntity(), d.getRule().getMsg()));
    result.getDeny().forEach(d -> processLog.warn("Artifact '{}' is forbidden by the dependency policy {}", d.getEntity(), d.getRule().getMsg()));
    if (!result.getDeny().isEmpty()) {
        throw new ExecutionException("Found restricted dependencies");
    }
}
Also used : DependencyEntity(com.walmartlabs.concord.dependencymanager.DependencyEntity) PolicyEngine(com.walmartlabs.concord.policyengine.PolicyEngine) DependencyRule(com.walmartlabs.concord.policyengine.DependencyRule) ExecutionException(com.walmartlabs.concord.agent.ExecutionException) ProcessLog(com.walmartlabs.concord.agent.logging.ProcessLog)

Aggregations

ExecutionException (com.walmartlabs.concord.agent.ExecutionException)1 ProcessLog (com.walmartlabs.concord.agent.logging.ProcessLog)1 DependencyEntity (com.walmartlabs.concord.dependencymanager.DependencyEntity)1 DependencyRule (com.walmartlabs.concord.policyengine.DependencyRule)1 PolicyEngine (com.walmartlabs.concord.policyengine.PolicyEngine)1