def test_find_versions_in_file_return_set_of_strings_that_match_version_pattern(
            self):
        homepage0 = html_file_to_hammertime_response(
            join(dirname(__file__), "samples/delvelabs_homepage.html"))
        homepage1 = html_file_to_hammertime_response(
            join(dirname(__file__), "samples/sample_homepage.html"))
        login_page0 = html_file_to_hammertime_response(
            join(dirname(__file__), "samples/delvelabs_login.html"))
        login_page1 = html_file_to_hammertime_response(
            join(dirname(__file__), "samples/canola_login.html"))
        homepage0_versions = {"4.7.5"}
        login_page0_versions = {"4.7.5"}
        homepage1_versions = {"4.2.2", "1.11.2", "1.2.1", "3.2"}
        login_page1_versions = {"4.2.2"}

        homepage0_result = self.version_identification._find_versions_in_file(
            homepage0)
        login_page0_result = self.version_identification._find_versions_in_file(
            login_page0)
        homepage1_result = self.version_identification._find_versions_in_file(
            homepage1)
        login_page1_result = self.version_identification._find_versions_in_file(
            login_page1)

        self.assertEqual(homepage0_versions, homepage0_result)
        self.assertEqual(login_page0_versions, login_page0_result)
        self.assertEqual(homepage1_versions, homepage1_result)
        self.assertEqual(login_page1_versions, login_page1_result)
Exemple #2
0
    def test_list_themes_find_theme_in_comments_with_theme_url(self):
        sample_page = join(dirname(__file__), "samples/comment.html")
        hammertime_response = html_file_to_hammertime_response(sample_page)

        themes = self.themes_finder.list_themes(hammertime_response)

        self.assertEqual({"themes/twenty11"}, themes)
    def test_find_versions_in_file_confirm_version_with_generator_meta_tag_if_present(
            self):
        """Some wordpress sites have the tag <meta name="generator" content="WordPress X.Y.Z" />"""
        homepage0 = html_file_to_hammertime_response(
            join(dirname(__file__), "samples/delvelabs_homepage.html"))
        homepage1 = html_file_to_hammertime_response(
            join(dirname(__file__), "samples/canola_homepage.html"))
        homepage0_versions = {"4.7.5"}
        homepage1_versions = {"4.2.2"}

        homepage0_result = self.version_identification._find_versions_in_file(
            homepage0)
        homepage1_result = self.version_identification._find_versions_in_file(
            homepage1)

        self.assertEqual(homepage0_versions, homepage0_result)
        self.assertEqual(homepage1_versions, homepage1_result)
    def test_find_versions_in_file_find_version_in_wp_links_opml_php_file(
            self):
        file = html_file_to_hammertime_response(
            join(dirname(__file__), "samples/wp-links-opml.php"))
        version_exposed = {"4.7.5"}

        found_version = self.version_identification._find_versions_in_file(
            file)

        self.assertEqual(version_exposed, found_version)
    def test_search_plugin_in_comments_outside_document_parse_comments_outside_html_closing_tag(
            self):
        sample_page = join(dirname(__file__), "samples/starwars.html")
        response = html_file_to_hammertime_response(sample_page)

        plugins = next(
            self.plugin_finder._search_plugin_in_comments_outside_document(
                response))

        self.assertEqual(plugins, {self.total_cache_meta.key: None})
Exemple #6
0
    def test_list_themes_return_list_of_theme_keys_found_in_page_source_that_exist_in_metas(
            self):
        sample_page = join(dirname(__file__), "samples/playstation.html")
        page_hammertime_response = html_file_to_hammertime_response(
            sample_page)

        themes = self.themes_finder.list_themes(page_hammertime_response)

        self.assertIn("themes/twenty11", themes)
        self.assertIn("themes/kratos", themes)
        self.assertEqual(len(themes), 2)
Exemple #7
0
    async def test_is_wordpress_return_true_if_url_with_wp_content_in_homepage(
            self):
        entry = MagicMock()
        entry.response = html_file_to_hammertime_response(
            join(dirname(__file__), "samples/delvelabs_homepage.html"))
        entry.response.headers = {
            "link": "http://example.com/url/unrelated/to_wordpress"
        }
        self.vane.hammertime.request = make_mocked_coro(return_value=entry)

        self.assertTrue(await self.vane.is_wordpress("http://example.com/"))
    def test_list_plugins_find_plugin_references_and_version_in_page_source(
            self):
        # yoast seo, disqus comment system and google analytics by monster insights:
        sample_page0 = join(dirname(__file__), "samples/delvelabs.html")

        # yoast seo, jm-twitter-cards (impossible à trouver?), yet-another-related-posts-plugin, cyclone-slider-2,
        # wp-jquery-lightbox, panopress, sitepress-multilingual-cms, W3 Total Cache
        # possibles: MH Cookie, DOL Web Analytics
        sample_page1 = join(dirname(__file__), "samples/starwars.html")

        # wp-polls, lift-search, wp-postratings, jetpack, Google Analytics by MonsterInsights, audio-player
        # possibles: scea-omniture, image-rotator-2
        sample_page2 = join(dirname(__file__), "samples/playstation.html")

        page0_response = html_file_to_hammertime_response(sample_page0)
        page1_response = html_file_to_hammertime_response(sample_page1)
        page2_response = html_file_to_hammertime_response(sample_page2)

        disqus_meta = Meta(key="plugins/disqus-comment-system",
                           name="Disqus Comment System")
        jetpack_meta = Meta(key="plugins/jetpack",
                            name="Jetpack by WordPress.com")
        cyclone_slider_meta = Meta(key="plugins/cyclone-slider-2",
                                   name="Cyclone Slider 2")
        sitepress_meta = Meta(key="plugins/sitepress-multilingual-cms")
        audio_player_meta = Meta(key="plugins/audio-player")
        lightbox_meta = Meta(key="plugins/wp-jquery-lightbox",
                             name="WP jQuery Lightbox")
        panopress_meta = Meta(key="plugins/panopress", name="PanoPress")
        wp_polls_meta = Meta(key="plugins/wp-polls", name="WP-Polls")
        posts_plugin_meta = Meta(
            key="plugins/yet-another-related-posts-plugin",
            name="Yet Another Related Posts Plugin (YARPP)")
        lift_search_meta = Meta(key="plugins/lift-search",
                                name="Lift: Search for WordPress")
        self.plugin_finder.meta_list.metas.extend([
            disqus_meta, jetpack_meta, cyclone_slider_meta, sitepress_meta,
            audio_player_meta, lightbox_meta, panopress_meta, wp_polls_meta,
            posts_plugin_meta, lift_search_meta
        ])

        plugins_in_page0 = self.plugin_finder.list_plugins(page0_response)
        plugins_in_page1 = self.plugin_finder.list_plugins(page1_response)
        plugins_in_page2 = self.plugin_finder.list_plugins(page2_response)

        self.assertIn(disqus_meta.key, plugins_in_page0)
        self.assertIn(self.yoast_seo_meta.key, plugins_in_page0)
        self.assertIn(self.google_analytics_meta.key, plugins_in_page0)
        self.assertEqual(plugins_in_page0[self.yoast_seo_meta.key], "4.0.2")
        self.assertEqual(plugins_in_page0[self.google_analytics_meta.key],
                         "5.5.4")
        self.assertEqual(len(plugins_in_page0), 3)

        self.assertIn(cyclone_slider_meta.key, plugins_in_page1)
        self.assertIn(sitepress_meta.key, plugins_in_page1)
        self.assertIn(lightbox_meta.key, plugins_in_page1)
        self.assertIn(panopress_meta.key, plugins_in_page1)
        self.assertIn(posts_plugin_meta.key, plugins_in_page1)
        self.assertIn(self.yoast_seo_meta.key, plugins_in_page1)
        self.assertEqual(plugins_in_page1[self.yoast_seo_meta.key], "3.4.1")
        self.assertIn(self.total_cache_meta.key, plugins_in_page1)
        self.assertEqual(len(plugins_in_page1), 7)

        self.assertIn(wp_polls_meta.key, plugins_in_page2)
        self.assertIn(self.postratings_meta.key, plugins_in_page2)
        self.assertIn(lift_search_meta.key, plugins_in_page2)
        self.assertIn(jetpack_meta.key, plugins_in_page2)
        self.assertIn(audio_player_meta.key, plugins_in_page2)
        self.assertIn(self.google_analytics_meta.key, plugins_in_page2)
        self.assertEqual(plugins_in_page2[self.google_analytics_meta.key],
                         "5.5.2")
        self.assertEqual(len(plugins_in_page2), 6)