Exemplo n.º 1
0
 def test_get_included_files_uids(self):
     test_parent = FileObject(binary=b'parent_file')
     test_child = FileObject(binary=b'1st child')
     test_child2 = FileObject(binary=b'2nd child')
     test_parent.add_included_file(test_child)
     test_parent.add_included_file(test_child2)
     self.assertEqual(len(test_parent.get_included_files_uids()), 2, 'number of uids not correct')
     self.assertIn(test_child.get_uid(), test_parent.get_included_files_uids(), 'uid of first file not found')
     self.assertIn(test_child2.get_uid(), test_parent.get_included_files_uids(), 'uid of second file not found')
Exemplo n.º 2
0
 def test_object_processing_one_child(self):
     root_object = FileObject(binary=b'root_file')
     child_object = FileObject(binary=b'first_child_object')
     root_object.add_included_file(child_object)
     self.base_plugin.in_queue.put(root_object)
     processed_object = self.base_plugin.out_queue.get()
     self.assertEqual(processed_object.uid, root_object.uid, 'uid changed')
     self.assertTrue(child_object.uid in root_object.files_included,
                     'child object not in processed file')
Exemplo n.º 3
0
 def test_get_included_files(self):
     test_parent = FileObject(binary=b'parent_file')
     test_child = FileObject(binary=b'1st child')
     test_child2 = FileObject(binary=b'2nd child')
     test_parent.add_included_file(test_child)
     test_parent.add_included_file(test_child2)
     assert len(test_parent.files_included) == 2, 'number of uids not correct'
     assert test_child.uid in test_parent.files_included, 'uid of first file not found'
     assert test_child2.uid in test_parent.files_included, 'uid of second file not found'
Exemplo n.º 4
0
 def test_add_included_file(self):
     parent = FileObject(binary=b'parent_file')
     parent.scheduled_analysis = ['test']
     child = FileObject(binary=b'child')
     parent.add_included_file(child)
     self.assertEqual(len(parent.files_included), 1, 'number of included files not correct')
     self.assertIn(child.get_uid(), parent.files_included, 'child uid not stored correctly')
     self.assertIn(parent.get_uid(), child.parents, 'parent not added to child')
     self.assertEqual(child.depth, parent.depth + 1, 'child depth not updated')
     self.assertEqual(child.scheduled_analysis, ['test'], 'child did not get scheduled analysis list of parent')
Exemplo n.º 5
0
 def test_add_included_file(self):
     parent = FileObject(binary=b'parent_file')
     parent.scheduled_analysis = ['test']
     child = FileObject(binary=b'child')
     parent.add_included_file(child)
     assert len(parent.files_included) == 1, 'number of included files not correct'
     assert child.uid in parent.files_included, 'child uid not stored correctly'
     assert parent.uid in child.parents, 'parent not added to child'
     assert child.depth == parent.depth + 1, 'child depth not updated'
     assert child.scheduled_analysis == ['test'], 'child did not get scheduled analysis list of parent'
Exemplo n.º 6
0
 def test_object_processing_one_child(self):
     root_object = FileObject(binary=b'root_file')
     child_object = FileObject(binary=b'first_child_object')
     root_object.add_included_file(child_object)
     self.pBase.in_queue.put(root_object)
     processed_object = self.pBase.out_queue.get()
     self.assertEqual(processed_object.get_uid(), root_object.get_uid(),
                      'uid changed')
     self.assertTrue(
         child_object.get_uid() in root_object.get_included_files_uids(),
         'child object not in processed file')