dependency-check-core/src/test/java/org/owasp/dependencycheck/analyzer/RubyBundleAuditAnalyzerTest.java
/**
     * Test Ruby BundlerAudit analysis.
     *
     * @throws AnalysisException is thrown when an exception occurs.
     */
Test Ruby BundlerAudit analysis.
@throws AnalysisException is thrown when an exception occurs.
Test Ruby BundlerAudit analysis . @throws AnalysisException is thrown when an exception occurs .
@Test
    public void testAnalysis() throws AnalysisException, DatabaseException {
        try {
            analyzer.initialize();
            final String resource = "ruby/vulnerable/gems/rails-4.1.15/Gemfile.lock";
            final Dependency result = new Dependency(BaseTest.getResourceAsFile(this, resource));
            final Engine engine = new Engine();
            analyzer.analyze(result, engine);
            int size = engine.getDependencies().size();
            assertTrue(size >= 1);
            Dependency dependency = engine.getDependencies().get(0);
            assertTrue(dependency.getProductEvidence().toString().toLowerCase().contains("redcarpet"));
            assertTrue(dependency.getVersionEvidence().toString().toLowerCase().contains("2.2.2"));
            assertTrue(dependency.getFilePath().endsWith(resource));
            assertTrue(dependency.getFileName().equals("Gemfile.lock"));
        } catch (InitializationException | DatabaseException | AnalysisException e) {
            LOGGER.warn("Exception setting up RubyBundleAuditAnalyzer. Make sure Ruby gem bundle-audit is installed. You may also need to set property \"analyzer.bundle.audit.path\".");
            Assume.assumeNoException("Exception setting up RubyBundleAuditAnalyzer; bundle audit may not be installed, or property \"analyzer.bundle.audit.path\" may not be set.", e);
        }
    }
@ Test public void testAnalysis ( ) throws AnalysisException , DatabaseException { try { analyzer . initialize ( ) ; final String resource = "ruby/vulnerable/gems/rails-4.1.15/Gemfile.lock" ; final Dependency result = new Dependency ( BaseTest . getResourceAsFile ( this , resource ) ) ; final Engine engine = new Engine ( ) ; analyzer . analyze ( result , engine ) ; int size = engine . getDependencies ( ) . size ( ) ; assertTrue ( size >= 1 ) ; Dependency dependency = engine . getDependencies ( ) . get ( 0 ) ; assertTrue ( dependency . getProductEvidence ( ) . toString ( ) . toLowerCase ( ) . contains ( "redcarpet" ) ) ; assertTrue ( dependency . getVersionEvidence ( ) . toString ( ) . toLowerCase ( ) . contains ( "2.2.2" ) ) ; assertTrue ( dependency . getFilePath ( ) . endsWith ( resource ) ) ; assertTrue ( dependency . getFileName ( ) . equals ( "Gemfile.lock" ) ) ; } catch ( InitializationException | DatabaseException | AnalysisException e ) { LOGGER . warn ( "Exception setting up RubyBundleAuditAnalyzer. Make sure Ruby gem bundle-audit is installed. You may also need to set property \"analyzer.bundle.audit.path\"." ) ; Assume . assumeNoException ( "Exception setting up RubyBundleAuditAnalyzer; bundle audit may not be installed, or property \"analyzer.bundle.audit.path\" may not be set." , e ) ; } }
Test Ruby BundlerAudit analysis.
Test Ruby BundlerAudit analysis .