private Collection<DockerImage> filterDockerImagesToScan(Collection<DockerImage> dockerImages, String[] dockerImageIncludes, String[] dockerImageExcludes) {
        logger.info("Filtering docker images list by includes and excludes lists");
        Collection<DockerImage> dockerImagesToScan = new LinkedList<>();
        Collection<String> imageIncludesList = Arrays.asList(dockerImageIncludes);
        Collection<String> imageExcludesList = Arrays.asList(dockerImageExcludes);
        for (DockerImage dockerImage : dockerImages) {
            String dockerImageString = dockerImage.getRepository() + Constants.WHITESPACE + dockerImage.getTag() + Constants.WHITESPACE + dockerImage.getId();
            // add images to scan according to dockerIncludes pattern
            if (isMatchingPattern(dockerImageString, imageIncludesList)) {
                dockerImagesToScan.add(dockerImage);
            }
            // remove images from scan according to dockerExcludes pattern
            if (isMatchingPattern(dockerImageString, imageExcludesList)) {
                dockerImagesToScan.remove(dockerImage);
            }
        }
        return dockerImagesToScan;
    }
private Collection < DockerImage > filterDockerImagesToScan ( Collection < DockerImage > dockerImages , String [ ] dockerImageIncludes , String [ ] dockerImageExcludes ) { logger . info ( "Filtering docker images list by includes and excludes lists" ) ; Collection < DockerImage > dockerImagesToScan = new LinkedList < > ( ) ; Collection < String > imageIncludesList = Arrays . asList ( dockerImageIncludes ) ; Collection < String > imageExcludesList = Arrays . asList ( dockerImageExcludes ) ; for ( DockerImage dockerImage : dockerImages ) { String dockerImageString = dockerImage . getRepository ( ) + Constants . WHITESPACE + dockerImage . getTag ( ) + Constants . WHITESPACE + dockerImage . getId ( ) ; if ( isMatchingPattern ( dockerImageString , imageIncludesList ) ) { dockerImagesToScan . add ( dockerImage ) ; } if ( isMatchingPattern ( dockerImageString , imageExcludesList ) ) { dockerImagesToScan . remove ( dockerImage ) ; } } return dockerImagesToScan ; }
Filter the images using includes and excludes lists