dependency-check-core/src/main/java/org/owasp/dependencycheck/Engine.java
/**
     * Scans a specified file. If a dependency is identified it is added to the
     * dependency collection.
     *
     * @param file The file to scan
     * @param projectReference the name of the project or scope in which the
     * dependency was identified
     * @return the scanned dependency
     * @since v1.4.4
     */
Scans a specified file. If a dependency is identified it is added to the
dependency collection.

@param file The file to scan
@param projectReference the name of the project or scope in which the
dependency was identified
@return the scanned dependency
@since v1.4.4
Scans a specified file . If a dependency is identified it is added to the dependency collection . @param file The file to scan @param projectReference the name of the project or scope in which the dependency was identified @return the scanned dependency @since v1 . 4 . 4
protected Dependency scanFile(File file, String projectReference) {
        Dependency dependency = null;
        if (file.isFile()) {
            if (accept(file)) {
                dependency = new Dependency(file);
                if (projectReference != null) {
                    dependency.addProjectReference(projectReference);
                }
                final String sha1 = dependency.getSha1sum();
                boolean found = false;
                synchronized (dependencies) {
                    if (sha1 != null) {
                        for (Dependency existing : dependencies) {
                            if (sha1.equals(existing.getSha1sum())) {
                                found = true;
                                if (projectReference != null) {
                                    existing.addProjectReference(projectReference);
                                }
                                if (existing.getActualFilePath() != null && dependency.getActualFilePath() != null
                                        && !existing.getActualFilePath().equals(dependency.getActualFilePath())) {
                                    existing.addRelatedDependency(dependency);
                                } else {
                                    dependency = existing;
                                }
                                break;
                            }
                        }
                    }
                    if (!found) {
                        dependencies.add(dependency);
                    }
                }
            } else {
                LOGGER.debug("Path passed to scanFile(File) is not a file that can be scanned by dependency-check: {}. Skipping the file.", file);
            }
        }
        return dependency;
    }
protected Dependency scanFile ( File file , String projectReference ) { Dependency dependency = null ; if ( file . isFile ( ) ) { if ( accept ( file ) ) { dependency = new Dependency ( file ) ; if ( projectReference != null ) { dependency . addProjectReference ( projectReference ) ; } final String sha1 = dependency . getSha1sum ( ) ; boolean found = false ; synchronized ( dependencies ) { if ( sha1 != null ) { for ( Dependency existing : dependencies ) { if ( sha1 . equals ( existing . getSha1sum ( ) ) ) { found = true ; if ( projectReference != null ) { existing . addProjectReference ( projectReference ) ; } if ( existing . getActualFilePath ( ) != null && dependency . getActualFilePath ( ) != null && ! existing . getActualFilePath ( ) . equals ( dependency . getActualFilePath ( ) ) ) { existing . addRelatedDependency ( dependency ) ; } else { dependency = existing ; } break ; } } } if ( ! found ) { dependencies . add ( dependency ) ; } } } else { LOGGER . debug ( "Path passed to scanFile(File) is not a file that can be scanned by dependency-check: {}. Skipping the file." , file ) ; } } return dependency ; }
Scans a specified file.
Scans a specified file .