Search in sources :

Example 1 with WorkspaceRule

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

the class WorkspacePolicyApplier method apply.

@Override
public void apply(Payload payload, PolicyEngine policy) throws Exception {
    ProcessKey processKey = payload.getProcessKey();
    Path workDir = payload.getHeader(Payload.WORKSPACE_DIR);
    CheckResult<WorkspaceRule, Path> result = policy.getWorkspacePolicy().check(workDir);
    result.getWarn().forEach(i -> {
        policyWarn.inc();
        logManager.warn(processKey, appendMsg("Potential workspace policy violation (policy: {})", i.getMsg()), i.getRule());
    });
    result.getDeny().forEach(i -> {
        policyDeny.inc();
        logManager.error(processKey, appendMsg("Workspace policy violation", i.getMsg()), i.getRule());
    });
    if (!result.getDeny().isEmpty()) {
        throw new ProcessException(processKey, "Found workspace policy violations");
    }
}
Also used : Path(java.nio.file.Path) ProcessException(com.walmartlabs.concord.server.process.ProcessException) WorkspaceRule(com.walmartlabs.concord.policyengine.WorkspaceRule) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey)

Aggregations

WorkspaceRule (com.walmartlabs.concord.policyengine.WorkspaceRule)1 ProcessException (com.walmartlabs.concord.server.process.ProcessException)1 ProcessKey (com.walmartlabs.concord.server.sdk.ProcessKey)1 Path (java.nio.file.Path)1