Search in sources :

Example 1 with ToolExecutionDeniedException

use of com.epam.pipeline.exception.ToolExecutionDeniedException in project cloud-pipeline by epam.

the class ToolSecurityPolicyAspect method checkToolBySecurityPolicy.

@Before("@annotation(com.epam.pipeline.manager.docker.scan.ToolSecurityPolicyCheck) && args(runVO,..)")
public void checkToolBySecurityPolicy(JoinPoint joinPoint, PipelineStart runVO) {
    if (runVO.isForce()) {
        PipelineUser user = authManager.getCurrentUser();
        if (user != null && user.isAdmin()) {
            return;
        }
    }
    PipelineConfiguration configuration = configurationManager.getPipelineConfiguration(runVO);
    String tag = toolManager.getTagFromImageName(configuration.getDockerImage());
    Tool tool = toolManager.loadByNameOrId(configuration.getDockerImage());
    if (!clairToolScanManager.checkTool(tool, tag)) {
        throw new ToolExecutionDeniedException(messageHelper.getMessage(MessageConstants.ERROR_TOOL_SECURITY_POLICY_VIOLATION));
    }
}
Also used : PipelineUser(com.epam.pipeline.entity.user.PipelineUser) ToolExecutionDeniedException(com.epam.pipeline.exception.ToolExecutionDeniedException) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Tool(com.epam.pipeline.entity.pipeline.Tool) Before(org.aspectj.lang.annotation.Before)

Aggregations

PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)1 Tool (com.epam.pipeline.entity.pipeline.Tool)1 PipelineUser (com.epam.pipeline.entity.user.PipelineUser)1 ToolExecutionDeniedException (com.epam.pipeline.exception.ToolExecutionDeniedException)1 Before (org.aspectj.lang.annotation.Before)1