示例#1
0
    def test_minhash(self):
        """Test minhash function."""
        analyzer = phishy_domains.PhishyDomainsSketchPlugin("test_index", 1)
        domain = "www.mbl.is"
        # pylint: disable=protected-access
        minhash = analyzer._get_minhash_from_domain(domain)

        self.assertIsInstance(minhash, MinHash)

        another_domain = "mbl.is"
        # pylint: disable=protected-access
        minhash2 = analyzer._get_minhash_from_domain(another_domain)

        self.assertEqual(minhash.jaccard(minhash2), 0.546875)
示例#2
0
    def test_get_similar_domains(self):
        """Test get_similar_domains function."""
        analyzer = phishy_domains.PhishyDomainsSketchPlugin("test_index", 1)
        domain = "login.stortmbl.is"
        # pylint: disable=protected-access
        minhash = analyzer._get_minhash_from_domain(domain)
        domain_dict = {domain: {"hash": minhash, "depth": 3}}

        # pylint: disable=protected-access
        similar = analyzer._get_similar_domains("login.stortmbi.is",
                                                domain_dict)
        self.assertEqual(len(similar), 1)

        # pylint: disable=protected-access
        similar = analyzer._get_similar_domains("www.google.com", domain_dict)
        self.assertEqual(len(similar), 0)
示例#3
0
    def test_get_similar_domains(self):
        """Test get_similar_domains function."""
        analyzer = phishy_domains.PhishyDomainsSketchPlugin('test_index', 1)
        domain = 'login.stortmbl.is'
        # pylint: disable=protected-access
        minhash = analyzer._get_minhash_from_domain(domain)
        domain_dict = {domain: {'hash': minhash, 'depth': 3}}

        # pylint: disable=protected-access
        similar = analyzer._get_similar_domains('login.stortmbi.is',
                                                domain_dict)
        self.assertEqual(len(similar), 1)

        # pylint: disable=protected-access
        similar = analyzer._get_similar_domains('www.google.com', domain_dict)
        self.assertEqual(len(similar), 0)