Collects information about the file name.

@param dependency the dependency to analyze.
@param engine the engine that is scanning the dependencies
@throws AnalysisException is thrown if there is an error reading the JAR
file.
496084
@Override
    protected void analyzeDependency(Dependency dependency, Engine engine) throws AnalysisException {
        //strip any path information that may get added by ArchiveAnalyzer, etc.
        final File f = dependency.getActualFile();
        final String fileName = FilenameUtils.removeExtension(f.getName());
        final String ext = FilenameUtils.getExtension(f.getName());
        if (!IGNORED_FILES.accept(f) && !"js".equals(ext)) {
            //add version evidence
            final DependencyVersion version = DependencyVersionUtil.parseVersion(fileName);
            final String packageName = DependencyVersionUtil.parsePreVersion(fileName);

            if (version != null) {
                // If the version number is just a number like 2 or 23, reduce the confidence
                // a shade. This should hopefully correct for cases like log4j.jar or
                // struts2-core.jar
                if (version.getVersionParts() == null || version.getVersionParts().size() < 2) {
                    dependency.addEvidence(EvidenceType.VERSION, "file", "version", version.toString(), Confidence.MEDIUM);
                } else {
                    dependency.addEvidence(EvidenceType.VERSION, "file", "version", version.toString(), Confidence.HIGHEST);
                }
                dependency.addEvidence(EvidenceType.VERSION, "file", "name", packageName, Confidence.MEDIUM);
            }

            dependency.addEvidence(EvidenceType.PRODUCT, "file", "name", packageName, Confidence.HIGH);
            dependency.addEvidence(EvidenceType.VENDOR, "file", "name", packageName, Confidence.HIGH);
        }
    }
407011
public final void analyze(final File classesDir) {

        final FileProcessor fileProcessor = new FileProcessor(new FileHandler() {
            @Override
            public final FileHandlerResult handleFile(final File classFile) {
                if (!classFile.getName().endsWith(".class")) {
                    return FileHandlerResult.CONTINUE;
                }
                try {
                    final ClassInfo classInfo = new ClassInfo(classFile);

                    final Package<DependsOn> allowedPkg = dependencies.findAllowedByName(classInfo.getPackageName());
                    if (allowedPkg == null) {
                        final Package<NotDependsOn> forbiddenPkg = dependencies.findForbiddenByName(classInfo.getPackageName());
                        if (forbiddenPkg == null) {
                            dependencyErrors.addAll(checkAlwaysForbiddenSection(dependencies, classInfo));
                        } else {
                            dependencyErrors.addAll(checkForbiddenSection(dependencies, forbiddenPkg, classInfo));
                        }
                    } else {
                        dependencyErrors.addAll(checkAllowedSection(dependencies, allowedPkg, classInfo));
                    }
                } catch (final IOException ex) {
                    throw new RuntimeException("Error handling file: " + classFile, ex);
                }

                return FileHandlerResult.CONTINUE;

            }
        });

        dependencyErrors.clear();
        fileProcessor.process(classesDir);

    }
847641
private static void collectWheelMetadata(Dependency dependency, File file) {
        final InternetHeaders headers = getManifestProperties(file);
        addPropertyToEvidence(dependency, EvidenceType.VERSION, Confidence.HIGHEST, headers, "Version");
        addPropertyToEvidence(dependency, EvidenceType.PRODUCT, Confidence.HIGHEST, headers, "Name");
        addPropertyToEvidence(dependency, EvidenceType.PRODUCT, Confidence.MEDIUM, headers, "Name");

        final String name = headers.getHeader("Name", null);
        final String version = headers.getHeader("Version", null);
        final String packagePath = String.format("%s:%s", name, version);
        dependency.setName(name);
        dependency.setVersion(version);
        dependency.setPackagePath(packagePath);
        dependency.setDisplayFileName(packagePath);
        final String url = headers.getHeader("Home-page", null);
        if (StringUtils.isNotBlank(url)) {
            if (UrlStringUtils.isUrl(url)) {
                dependency.addEvidence(EvidenceType.VENDOR, METADATA, "vendor", url, Confidence.MEDIUM);
            }
        }
        addPropertyToEvidence(dependency, EvidenceType.VENDOR, Confidence.LOW, headers, "Author");
        final String summary = headers.getHeader("Summary", null);
        if (StringUtils.isNotBlank(summary)) {
            JarAnalyzer.addDescription(dependency, summary, METADATA, "summary");
        }

        try {
            final PackageURL purl = PackageURLBuilder.aPackageURL().withType("pypi")
                    .withName(name).withVersion(version).build();
            dependency.addSoftwareIdentifier(new PurlIdentifier(purl, Confidence.HIGHEST));
        } catch (MalformedPackageURLException ex) {
            LOGGER.debug("Unable to build package url for python", ex);
            final GenericIdentifier id = new GenericIdentifier("generic:" + name + "@" + version, Confidence.HIGHEST);
            dependency.addSoftwareIdentifier(id);
        }
    }
870685
@Override
    public void prepareFileTypeAnalyzer(Engine engine) throws InitializationException {
        LOGGER.debug("Initializing Nexus Analyzer");
        LOGGER.debug("Nexus Analyzer enabled: {}", isEnabled());
        if (isEnabled()) {
            final boolean useProxy = useProxy();
            LOGGER.debug("Using proxy: {}", useProxy);
            try {
                searcher = new NexusSearch(getSettings(), useProxy);
                if (!searcher.preflightRequest()) {
                    setEnabled(false);
                    throw new InitializationException("There was an issue getting Nexus status. Disabling analyzer.");
                }
            } catch (MalformedURLException mue) {
                setEnabled(false);
                throw new InitializationException("Malformed URL to Nexus", mue);
            }
        }
    }
900954
private void generateExternalReports(Engine engine, File outDirectory) throws ScanAgentException {
        try {
            engine.writeReports(applicationName, outDirectory, this.reportFormat.name());
        } catch (ReportException ex) {
            LOGGER.debug("Unexpected exception occurred during analysis; please see the verbose error log for more details.", ex);
            throw new ScanAgentException("Error generating the report", ex);
        }
    }
1346061
public static void analyzePOM(Dependency dependency, File pomFile) throws AnalysisException {
        final Model pom = PomUtils.readPom(pomFile);
        JarAnalyzer.setPomEvidence(dependency, pom, null, true);
    }
488663
protected boolean shouldAnalyze() {
        if (analyzer instanceof FileTypeAnalyzer) {
            final FileTypeAnalyzer fileTypeAnalyzer = (FileTypeAnalyzer) analyzer;
            return fileTypeAnalyzer.accept(dependency.getActualFile());
        }
        return true;
    }
698657
private void analyzePodfileLockDependencies(Dependency podfileLock, Engine engine)
            throws AnalysisException {
        engine.removeDependency(podfileLock);

        final String contents;
        try {
            contents = FileUtils.readFileToString(podfileLock.getActualFile(), Charset.defaultCharset());
        } catch (IOException e) {
            throw new AnalysisException(
                    "Problem occurred while reading dependency file.", e);
        }

        final Matcher matcher = PODFILE_LOCK_DEPENDENCY_PATTERN.matcher(contents);
        while (matcher.find()) {
            final String name = matcher.group(1);
            final String version = matcher.group(2);

            final Dependency dependency = new Dependency(podfileLock.getActualFile(), true);
            dependency.setEcosystem(DEPENDENCY_ECOSYSTEM);
            dependency.setName(name);
            dependency.setVersion(version);
            final String packagePath = String.format("%s:%s", name, version);
            dependency.setPackagePath(packagePath);
            dependency.setDisplayFileName(packagePath);
            dependency.setSha1sum(Checksum.getSHA1Checksum(packagePath));
            dependency.setSha256sum(Checksum.getSHA256Checksum(packagePath));
            dependency.setMd5sum(Checksum.getMD5Checksum(packagePath));
            dependency.addEvidence(EvidenceType.VENDOR, PODFILE_LOCK, "name", name, Confidence.HIGHEST);
            dependency.addEvidence(EvidenceType.PRODUCT, PODFILE_LOCK, "name", name, Confidence.HIGHEST);
            dependency.addEvidence(EvidenceType.VERSION, PODFILE_LOCK, "version", version, Confidence.HIGHEST);
            engine.addDependency(dependency);
        }
    }
75294
@Override
    public Collection<DependencyInfo> parse(File dir) {
        BufferedReader br = null;
        FileReader fr = null;
        Collection<DependencyInfo> dependencyInfos = new LinkedList<>();
        if (dir.isDirectory()) {
            Collection<File> files = new LinkedList<>();
            getDescFiles(dir, files);
            if (!files.isEmpty()) {
                for (File file : files) {
                    try {
                        DependencyInfo dependencyInfo = null;
                        Package packageInfo = new Package();
                        fr = new FileReader(file);
                        br = new BufferedReader(fr);
                        String line = null;
                        // Create Arch Linux package - package-version-architecture.pkg.tar.xz
                        while ((line = br.readLine()) != null) {
                            switch (line) {
                                case PACKAGE:
                                    packageInfo.setPackageName(br.readLine());
                                    break;
                                case VERSION:
                                    packageInfo.setVersion(br.readLine());
                                    break;
                                case ARCHITECTURE:
                                    packageInfo.setArchitecture(br.readLine());
                                    break;
                                default:
                                    break;
                            }
                        }
                        dependencyInfos.add(createDependencyInfo(packageInfo));
                    } catch (FileNotFoundException e) {
                        logger.error("Error getting package data", e.getMessage());
                    } catch (IOException e) {
                        logger.error("Error getting package data", e.getMessage());
                    } finally {
                        closeStream(br, fr);
                    }
                }
            }
        }
        return dependencyInfos;
    }
285815
@Override
    public ConstantDataflow analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
        MethodGen methodGen = getMethodGen(analysisCache, descriptor);
        if (methodGen == null) {
            return null;
        }
        ConstantAnalysis analysis = new ConstantAnalysis(methodGen, getDepthFirstSearch(analysisCache, descriptor));
        ConstantDataflow dataflow = new ConstantDataflow(getCFG(analysisCache, descriptor), analysis);
        dataflow.execute();

        return dataflow;
    }
42156
@Override
    public Collection<DependencyInfo> parse(File file) {
        BufferedReader br = null;
        FileReader fr = null;
        Collection<DependencyInfo> dependencyInfos = new LinkedList<>();
        try {
            File[] files = file.listFiles();
            for (File directory : files) {
                File[] packageDirectories = directory.listFiles();
                for (File packageDirectory : packageDirectories) {
                    // parse the package name from package directory
                    // get the start index of package name
                    // package Directory Name for
                    int firstHyphenIndex = packageDirectory.getName().indexOf(Constants.DASH);
                    String packageInfoString = packageDirectory.getName().substring(firstHyphenIndex + 1, packageDirectory.getName().length());
                    // change rpm pattern name to application pattern
                    int lastIndexOfHyphen = packageInfoString.lastIndexOf(Constants.DASH);
                    packageInfoString = packageInfoString.substring(0, lastIndexOfHyphen) + Constants.DOT + packageInfoString.substring(lastIndexOfHyphen + 1);
                    // create dependencyInfo object
                    DependencyInfo dependencyInfo = null;
                    String packVersion = getPackageVersion(packageInfoString);
                    if (packVersion != null) {
                        dependencyInfo = new DependencyInfo(
                                null, MessageFormat.format(RPM_PACKAGE_PATTERN, packageInfoString), packVersion);
                        dependencyInfos.add(dependencyInfo);
                    }
                }
            }
        } catch (Exception e) {
            logger.warn("Failed to parse {} : {}", file, e.getMessage());
        } finally {
            closeStream(br, fr);
        }
        return dependencyInfos;
    }
569903
Set<String> dependences(Archive source) {
        if (!results.containsKey(source)) {
            return Collections.emptySet();
        }

        return results.get(source).dependencies()
                      .stream()
                      .map(Dep::target)
                      .collect(Collectors.toSet());
    }
1217170
public void process(JCas jcas) {
		try {
			tagger.process(jcas);
		} catch(AnalysisEngineProcessException e) {
			e.printStackTrace();
		}
	}
169485
@Override
    public void registerAnalysisEngines(IAnalysisCache analysisCache) {
        for (IClassAnalysisEngine<?> engine : classAnalysisEngineList) {
            engine.registerWith(analysisCache);
        }
        for (IMethodAnalysisEngine<?> engine : methodAnalysisEngineList) {
            engine.registerWith(analysisCache);
        }
    }
196461
public void addDependency(org.apache.maven.model.Dependency projectDependency) {
        log.debug( "Adding dependency: {}", projectDependency );
        
        DefaultArtifact artifact = null;
        
        if ( Const.TEST.equals( projectDependency.getType() ) || Const.TEST_JAR.equals( projectDependency.getType() ) ) {
            
            ArtifactType artifactType = new DefaultArtifactType( Const.TEST_JAR, Const.JAR, Const.TEST_JAR, null );
            
            artifact = new DefaultArtifact( projectDependency.getGroupId(), projectDependency.getArtifactId(),
                    null, Const.JAR, projectDependency.getVersion(), artifactType );
        } else {
            artifact = new DefaultArtifact( projectDependency.getGroupId(), projectDependency.getArtifactId(),
                    null, Const.JAR, projectDependency.getVersion() );
        }
        
        Dependency dependency = new Dependency( artifact , projectDependency.getScope());
        dependency.setOptional( projectDependency.isOptional() );
        
        List<Exclusion> exclusions = new ArrayList<Exclusion>();
        for ( org.apache.maven.model.Exclusion projectExclusion : projectDependency.getExclusions() ) {
            exclusions.add( new Exclusion(projectExclusion.getGroupId(), projectExclusion.getArtifactId(), "*", "*") );            
        }
        log.debug( "Exclusion: {}", exclusions );
        dependency = dependency.setExclusions( exclusions );
        
        dependencies.add( dependency );
    }
654113
public void addDependency(Dependency dependency) {
        Dependency newDep = null;
        String classifier = dependency.getArtifact().getClassifier();
        if ( Const.TEST.equals( classifier ) || Const.TEST_JAR.equals( classifier ) ) {
            ArtifactType artifactType = new DefaultArtifactType( Const.TEST_JAR, Const.JAR, Const.TEST_JAR, null );
            
            Artifact artifact = dependency.getArtifact();
            
            artifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
                    null, Const.JAR, artifact.getBaseVersion(), artifactType );
            newDep =  new Dependency(artifact, dependency.getScope());
        } else {
            newDep = dependency;
        }
        dependencies.add(newDep);
    }
715079
@Override
    public ClassContext analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException {

        JavaClass javaClass = analysisCache.getClassAnalysis(JavaClass.class, descriptor);
        ClassContext classContext = new ClassContext(javaClass, AnalysisContext.currentAnalysisContext());
        return classContext;
    }