core/src/main/java/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.java
/**
     * Attempts to determine if a zip file is actually a JAR file.
     *
     * @param dependency the dependency to check
     * @return true if the dependency appears to be a JAR file; otherwise false
     */
Attempts to determine if a zip file is actually a JAR file.
@param dependency the dependency to check
@return true if the dependency appears to be a JAR file; otherwise false
Attempts to determine if a zip file is actually a JAR file . @param dependency the dependency to check @return true if the dependency appears to be a JAR file ; otherwise false
private boolean isZipFileActuallyJarFile(Dependency dependency) {
        boolean isJar = false;
        ZipFile zip = null;
        try {
            zip = new ZipFile(dependency.getActualFilePath());
            if (zip.getEntry("META-INF/MANIFEST.MF") != null
                    || zip.getEntry("META-INF/maven") != null) {
                final Enumeration<ZipArchiveEntry> entries = zip.getEntries();
                while (entries.hasMoreElements()) {
                    final ZipArchiveEntry entry = entries.nextElement();
                    if (!entry.isDirectory()) {
                        final String name = entry.getName().toLowerCase();
                        if (name.endsWith(".class")) {
                            isJar = true;
                            break;
                        }
                    }
                }
            }
        } catch (IOException ex) {
            LOGGER.debug("Unable to unzip zip file '{}'", dependency.getFilePath(), ex);
        } finally {
            ZipFile.closeQuietly(zip);
        }
        return isJar;
    }
private boolean isZipFileActuallyJarFile ( Dependency dependency ) { boolean isJar = false ; ZipFile zip = null ; try { zip = new ZipFile ( dependency . getActualFilePath ( ) ) ; if ( zip . getEntry ( "META-INF/MANIFEST.MF" ) != null || zip . getEntry ( "META-INF/maven" ) != null ) { final Enumeration < ZipArchiveEntry > entries = zip . getEntries ( ) ; while ( entries . hasMoreElements ( ) ) { final ZipArchiveEntry entry = entries . nextElement ( ) ; if ( ! entry . isDirectory ( ) ) { final String name = entry . getName ( ) . toLowerCase ( ) ; if ( name . endsWith ( ".class" ) ) { isJar = true ; break ; } } } } } catch ( IOException ex ) { LOGGER . debug ( "Unable to unzip zip file '{}'" , dependency . getFilePath ( ) , ex ) ; } finally { ZipFile . closeQuietly ( zip ) ; } return isJar ; }
Attempts to determine if a zip file is actually a JAR file.
Attempts to determine if a zip file is actually a JAR file .