dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CMakeAnalyzer.java
/**
     * Extracts the version information from the contents. If more then one
     * version is found additional dependencies are added to the dependency
     * list.
     *
     * @param dependency the dependency being analyzed
     * @param engine the dependency-check engine
     * @param contents the version information
     */
Extracts the version information from the contents. If more then one
version is found additional dependencies are added to the dependency
list.

@param dependency the dependency being analyzed
@param engine the dependency-check engine
@param contents the version information
Extracts the version information from the contents . If more then one version is found additional dependencies are added to the dependency list . @param dependency the dependency being analyzed @param engine the dependency - check engine @param contents the version information
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
            value = "DM_DEFAULT_ENCODING",
            justification = "Default encoding is only used if UTF-8 is not available")
    private void analyzeSetVersionCommand(Dependency dependency, Engine engine, String contents) {
        Dependency currentDep = dependency;
        final Matcher m = SET_VERSION.matcher(contents);
        int count = 0;
        while (m.find()) {
            count++;
            LOGGER.debug("Found project command match with {} groups: {}",
                    m.groupCount(), m.group(0));
            String product = m.group(1);
            final String version = m.group(2);
            LOGGER.debug("Group 1: {}", product);
            LOGGER.debug("Group 2: {}", version);
            final String aliasPrefix = "ALIASOF_";
            if (product.startsWith(aliasPrefix)) {
                product = product.replaceFirst(aliasPrefix, "");
            }
            if (count > 1) {
                currentDep = new Dependency(dependency.getActualFile());
                currentDep.setDisplayFileName(String.format("%s:%s", dependency.getDisplayFileName(), product));
                final String filePath = String.format("%s:%s", dependency.getFilePath(), product);
                currentDep.setFilePath(filePath);
                byte[] path;
                try {
                    path = filePath.getBytes("UTF-8");
                } catch (UnsupportedEncodingException ex) {
                    path = filePath.getBytes();
                }
                final MessageDigest sha1 = getSha1MessageDigest();
                currentDep.setSha1sum(Checksum.getHex(sha1.digest(path)));
                engine.getDependencies().add(currentDep);
            }
            final String source = currentDep.getDisplayFileName();
            currentDep.getProductEvidence().addEvidence(source, "Product",
                    product, Confidence.MEDIUM);
            currentDep.getVersionEvidence().addEvidence(source, "Version",
                    version, Confidence.MEDIUM);
        }
        LOGGER.debug("Found {} matches.", count);
    }
@ edu . umd . cs . findbugs . annotations . SuppressFBWarnings ( value = "DM_DEFAULT_ENCODING" , justification = "Default encoding is only used if UTF-8 is not available" ) private void analyzeSetVersionCommand ( Dependency dependency , Engine engine , String contents ) { Dependency currentDep = dependency ; final Matcher m = SET_VERSION . matcher ( contents ) ; int count = 0 ; while ( m . find ( ) ) { count ++ ; LOGGER . debug ( "Found project command match with {} groups: {}" , m . groupCount ( ) , m . group ( 0 ) ) ; String product = m . group ( 1 ) ; final String version = m . group ( 2 ) ; LOGGER . debug ( "Group 1: {}" , product ) ; LOGGER . debug ( "Group 2: {}" , version ) ; final String aliasPrefix = "ALIASOF_" ; if ( product . startsWith ( aliasPrefix ) ) { product = product . replaceFirst ( aliasPrefix , "" ) ; } if ( count > 1 ) { currentDep = new Dependency ( dependency . getActualFile ( ) ) ; currentDep . setDisplayFileName ( String . format ( "%s:%s" , dependency . getDisplayFileName ( ) , product ) ) ; final String filePath = String . format ( "%s:%s" , dependency . getFilePath ( ) , product ) ; currentDep . setFilePath ( filePath ) ; byte [ ] path ; try { path = filePath . getBytes ( "UTF-8" ) ; } catch ( UnsupportedEncodingException ex ) { path = filePath . getBytes ( ) ; } final MessageDigest sha1 = getSha1MessageDigest ( ) ; currentDep . setSha1sum ( Checksum . getHex ( sha1 . digest ( path ) ) ) ; engine . getDependencies ( ) . add ( currentDep ) ; } final String source = currentDep . getDisplayFileName ( ) ; currentDep . getProductEvidence ( ) . addEvidence ( source , "Product" , product , Confidence . MEDIUM ) ; currentDep . getVersionEvidence ( ) . addEvidence ( source , "Version" , version , Confidence . MEDIUM ) ; } LOGGER . debug ( "Found {} matches." , count ) ; }
Extracts the version information from the contents.
Extracts the version information from the contents .
//TODO - refactor so we do not assign to the parameter (checkstyle)