Exemplo n.º 1
0
    def test_build_rules_and_scan(self):
        """memory - multi-threaded create scan than destroy"""
        def match_rule(rules, path):
            for i in range(10):
                matches = rules.match_path(os.path.join(cdir, sys.executable))
            rules.free()

        cdir = os.path.split(__file__)[0]
        rules_rootpath = os.path.join(cdir, 'rules')
        sm = yr_malloc_count()
        sf = yr_free_count()

        for i in range(5):
            #spool up 4 threads
            rules = yara.load_rules(rules_rootpath, includes=True)
            target = os.path.join(cdir, sys.executable)
            tl = []
            for i in range(4):
                t1 = Thread(target=match_rule, args=[rules, target])
                t2 = Thread(target=match_rule, args=[rules, target])
                t3 = Thread(target=match_rule, args=[rules, target])
                t1.start()
                t2.start()
                t3.start()
                tl.append((t1, t2, t3))
            for t1, t2, t3 in tl:
                t1.join()
                t2.join()
                t3.join()

        dsm = yr_malloc_count()
        dsf = yr_free_count()
        self.assertEqual(dsm, dsf)
Exemplo n.º 2
0
    def test_build_rules_and_scan(self):
        """memory - multi-threaded create scan than destroy"""

        def match_rule(rules, path):
            for i in range(10):
                matches = rules.match_path(sys.executable)
            rules.free()

        sm = yr_malloc_count()
        sf = yr_free_count()
        for i in range(5):
            # spool up 4 threads
            rules = yara.load_rules(RULES_ROOT, blacklist=["broken", "extern"])
            target = sys.executable
            tl = []
            for i in range(4):
                t1 = Thread(target=match_rule, args=[rules, target])
                t2 = Thread(target=match_rule, args=[rules, target])
                t3 = Thread(target=match_rule, args=[rules, target])
                t1.start()
                t2.start()
                t3.start()
                tl.append((t1, t2, t3))
            for t1, t2, t3 in tl:
                t1.join()
                t2.join()
                t3.join()
        dsm = yr_malloc_count()
        dsf = yr_free_count()
        self.assertEqual(dsm, dsf)
Exemplo n.º 3
0
    def test_build_rules_and_scan(self):
        """memory - multi-threaded create scan than destroy"""
        def match_rule(rules, path):
            for i in range(10):
                matches = rules.match_path(os.path.join(cdir, sys.executable))
            rules.free()

        cdir = os.path.split(__file__)[0]
        rules_rootpath = os.path.join(cdir, 'rules')
        sm = yr_malloc_count()
        sf = yr_free_count()

        for i in range(5):
            #spool up 4 threads
            rules = yara.load_rules(rules_rootpath, includes=True)
            target = os.path.join(cdir, sys.executable)
            tl = []
            for i in range(4):
                t1 = Thread(target=match_rule, args=[rules, target])
                t2 = Thread(target=match_rule, args=[rules, target])
                t3 = Thread(target=match_rule, args=[rules, target])
                t1.start()
                t2.start()
                t3.start()
                tl.append((t1, t2, t3))
            for t1, t2, t3 in tl:
                t1.join()
                t2.join()
                t3.join()

        dsm = yr_malloc_count()
        dsf = yr_free_count()
        self.assertEqual(dsm, dsf)
Exemplo n.º 4
0
    def test_build_rules_and_scan(self):
        """memory - multi-threaded create scan than destroy"""
        def match_rule(rules, path):
            for i in range(10):
                matches = rules.match_path(sys.executable)
            rules.free()

        sm = yr_malloc_count()
        sf = yr_free_count()
        for i in range(5):
            #spool up 4 threads
            rules = yara.load_rules(RULES_ROOT,  
                                    blacklist=['broken', 'extern'])
            target = sys.executable
            tl = []
            for i in range(4):
                t1 = Thread(target=match_rule, args=[rules, target])
                t2 = Thread(target=match_rule, args=[rules, target])
                t3 = Thread(target=match_rule, args=[rules, target])
                t1.start()
                t2.start()
                t3.start()
                tl.append((t1, t2, t3))
            for t1, t2, t3 in tl:
                t1.join()
                t2.join()
                t3.join()
        dsm = yr_malloc_count()
        dsf = yr_free_count()
        self.assertEqual(dsm, dsf)
Exemplo n.º 5
0
 def test_create_destroy(self):
     """memory - create and destroy loop"""
     sm = yr_malloc_count()
     sf = yr_free_count()
     for i in range(100):
         rules = yara.load_rules(RULES_ROOT, blacklist=["broken", "extern"])
         rules.free()
     dsm = yr_malloc_count()
     dsf = yr_free_count()
     self.assertEqual(dsm, dsf)
Exemplo n.º 6
0
 def test_create_destroy_and_scan(self):
     """memory - create and destroy for each scan"""
     sm = yr_malloc_count()
     sf = yr_free_count()
     for i in range(10):
         rules = yara.load_rules(RULES_ROOT, blacklist=["broken", "extern"])
         matches = rules.match_path(sys.executable)
         rules.free()
     dsm = yr_malloc_count()
     dsf = yr_free_count()
     self.assertEqual(dsm, dsf)
Exemplo n.º 7
0
 def test_create_destroy(self):
     """memory - create and destroy loop"""
     sm = yr_malloc_count()
     sf = yr_free_count()
     for i in range(100):
         rules = yara.load_rules(RULES_ROOT,  
                                 blacklist=['broken', 'extern'])
         rules.free()
     dsm = yr_malloc_count()
     dsf = yr_free_count()
     self.assertEqual(dsm, dsf)
Exemplo n.º 8
0
 def test_create_destroy_and_scan(self):
     """memory - create and destroy for each scan"""
     sm = yr_malloc_count()
     sf = yr_free_count()
     for i in range(10):
         rules = yara.load_rules(RULES_ROOT,  
                                 blacklist=['broken', 'extern'])
         matches = rules.match_path(sys.executable)
         rules.free()
     dsm = yr_malloc_count()
     dsf = yr_free_count()
     self.assertEqual(dsm, dsf)
Exemplo n.º 9
0
 def test_build_rules_and_scan(self):
     """memory - create multi scan than destroy"""
     sm = yr_malloc_count()
     sf = yr_free_count()
     rules = yara.load_rules(RULES_ROOT, blacklist=["broken", "extern"])
     for i in range(100):
         matches = rules.match_path(sys.executable)
     rules.free()
     del matches
     del rules
     dsm = yr_malloc_count()
     dsf = yr_free_count()
     self.assertEqual(dsm, dsf)
Exemplo n.º 10
0
    def test_create_destroy(self):
        """memory - create and destroy loop"""

        cdir = os.path.split(__file__)[0]
        rules_rootpath = os.path.join(cdir, 'rules')

        sm = yr_malloc_count()
        sf = yr_free_count()
        for i in range(100):
            rules = yara.load_rules(rules_rootpath, includes=True)
            rules.free()
        dsm = yr_malloc_count()
        dsf = yr_free_count()
        self.assertEqual(dsm, dsf)
Exemplo n.º 11
0
 def test_build_rules_and_scan(self):
     """memory - create multi scan than destroy"""
     sm = yr_malloc_count()
     sf = yr_free_count()
     rules = yara.load_rules(RULES_ROOT,  
                             blacklist=['broken', 'extern'])
     for i in range(100):
         matches = rules.match_path(sys.executable)
     rules.free()
     del matches
     del rules
     dsm = yr_malloc_count()
     dsf = yr_free_count()
     self.assertEqual(dsm, dsf)
Exemplo n.º 12
0
    def test_create_destroy_and_scan(self):
        """memory - create and destroy for each scan"""

        cdir = os.path.split(__file__)[0]
        rules_rootpath = os.path.join(cdir, 'rules')
        sm = yr_malloc_count()
        sf = yr_free_count()
        for i in range(10):
            rules = yara.load_rules(rules_rootpath, includes=True)
            matches = rules.match_path(os.path.join(cdir, sys.executable))
            rules.free()

        dsm = yr_malloc_count()
        dsf = yr_free_count()
        self.assertEqual(dsm, dsf)
Exemplo n.º 13
0
    def test_create_destroy(self):
        """memory - create and destroy loop"""

        cdir = os.path.split(__file__)[0]
        rules_rootpath = os.path.join(cdir, 'rules')

        sm = yr_malloc_count()
        sf = yr_free_count()
        for i in range(100):
            rules = yara.load_rules(rules_rootpath,
                    includes=True)
            rules.free()
        dsm = yr_malloc_count()
        dsf = yr_free_count()
        self.assertEqual(dsm, dsf)
Exemplo n.º 14
0
    def test_create_destroy_and_scan(self):
        """memory - create and destroy for each scan"""

        cdir = os.path.split(__file__)[0]
        rules_rootpath = os.path.join(cdir, 'rules')
        sm = yr_malloc_count()
        sf = yr_free_count()
        for i in range(10):
            rules = yara.load_rules(rules_rootpath,
                    includes=True)
            matches = rules.match_path(os.path.join(cdir, sys.executable))
            rules.free()

        dsm = yr_malloc_count()
        dsf = yr_free_count()
        self.assertEqual(dsm, dsf)
Exemplo n.º 15
0
    def test_build_rules_and_scan(self):
        """memory - create multi scan than destroy"""

        cdir = os.path.split(__file__)[0]
        rules_rootpath = os.path.join(cdir, 'rules')
        sm = yr_malloc_count()
        sf = yr_free_count()
        rules = yara.load_rules(rules_rootpath, includes=True)
        for i in range(1000):
            matches = rules.match_path(os.path.join(cdir, sys.executable))
        rules.free()
        del matches
        del rules

        dsm = yr_malloc_count()
        dsf = yr_free_count()
        self.assertEqual(dsm, dsf)
Exemplo n.º 16
0
    def test_build_rules_and_scan(self):
        """memory - create multi scan than destroy"""

        cdir = os.path.split(__file__)[0]
        rules_rootpath = os.path.join(cdir, 'rules')
        sm = yr_malloc_count()
        sf = yr_free_count()
        rules = yara.load_rules(rules_rootpath,
                    includes=True)
        for i in range(1000):
            matches = rules.match_path(os.path.join(cdir, sys.executable))
        rules.free()
        del matches
        del rules

        dsm = yr_malloc_count()
        dsf = yr_free_count()
        self.assertEqual(dsm, dsf)