/** * Test Ruby Bundler created gemspec analysis. * * @throws AnalysisException is thrown when an exception occurs. */ @Test public void testAnalyzeGemspec() throws AnalysisException { final Dependency result = new Dependency( BaseTest.getResourceAsFile( this, "ruby/vulnerable/gems/rails-4.1.15/vendor/bundle/ruby/2.2.0/specifications/dalli-2.7.5.gemspec")); analyzer.analyze(result, null); final String vendorString = result.getVendorEvidence().toString(); assertThat(vendorString, containsString("Peter M. Goldstein")); assertThat(vendorString, containsString("Mike Perham")); assertThat(vendorString, containsString("*****@*****.**")); assertThat(vendorString, containsString("https://github.com/petergoldstein/dalli")); assertThat(vendorString, containsString("MIT")); assertThat(result.getProductEvidence().toString(), containsString("dalli")); assertThat( result.getProductEvidence().toString(), containsString("High performance memcached client for Ruby")); assertThat(result.getVersionEvidence().toString(), containsString("2.7.5")); }
/** Test Ruby Gemspec file support. */ @Test public void testSupportsFiles() { assertThat(analyzer.accept(new File("test.gemspec")), is(false)); assertThat( analyzer.accept(new File("specifications" + File.separator + "test.gemspec")), is(true)); }
/** * Cleanup the analyzer's temp files, etc. * * @throws Exception thrown if there is a problem */ @After public void tearDown() throws Exception { analyzer.close(); analyzer = null; }
/** Test Analyzer name. */ @Test public void testGetName() { assertThat(analyzer.getName(), is("Ruby Bundler Analyzer")); }
/** * Correctly setup the analyzer for testing. * * @throws Exception thrown if there is a problem */ @Before public void setUp() throws Exception { analyzer = new RubyBundlerAnalyzer(); analyzer.setFilesMatched(true); analyzer.initialize(); }