Beispiel #1
0
 def test_empty_reprocess(self):
     db.connect()
     mkdir(cwd(analysis=1))
     process_task_range("1")
     assert os.path.exists(cwd("reports", "report.json", analysis=1))
     obj = json.load(open(cwd("reports", "report.json", analysis=1), "rb"))
     assert "contact back" in obj["debug"]["errors"][0]
Beispiel #2
0
    def test_process_task_range_range(self, p):
        mkdir(cwd(analysis=3))
        for x in xrange(10, 101):
            mkdir(cwd(analysis=x))
        process_task_range("3,5,10-100")
        assert p.call_count == 92  # 101-10+1
        p.assert_any_call({
            "id": 3,
            "category": "file",
            "target": "",
            "options": {},
            "package": None,
            "custom": None,
        })

        # We did not create an analysis directory for analysis=5.
        with pytest.raises(AssertionError):
            p.assert_any_call({
                "id": 5,
                "category": "file",
                "target": "",
                "options": {},
                "package": None,
                "custom": None,
            })

        for x in xrange(10, 101):
            p.assert_any_call({
                "id": x,
                "category": "file",
                "target": "",
                "options": {},
                "package": None,
                "custom": None,
            })
Beispiel #3
0
 def test_process_task_range_single(self, p):
     mkdir(cwd(analysis=1234))
     process_task_range("1234")
     p.assert_called_once_with({
         "id": 1234,
         "category": "file",
         "target": "",
         "options": {},
         "package": None,
         "custom": None,
     })
Beispiel #4
0
 def test_process_task_range_single(self, p):
     mkdir(cwd(analysis=1234))
     process_task_range("1234")
     p.assert_called_once_with({
         "id": 1234,
         "category": "file",
         "target": "",
         "options": {},
         "package": None,
         "custom": None,
     })
Beispiel #5
0
def test_config_load_once():
    set_cwd(tempfile.mkdtemp())
    cuckoo_create()

    db.connect()
    t0 = db.add_path(__file__)
    t1 = db.add_path(__file__)
    shutil.copytree("tests/files/sample_analysis_storage", cwd(analysis=t0))
    shutil.copytree("tests/files/sample_analysis_storage", cwd(analysis=t1))

    with mock.patch("cuckoo.common.config.ConfigParser.ConfigParser") as p:
        process_task_range("%d,%d" % (t0, t1))
        assert p.return_value.read.call_count == 2
        p.return_value.read.assert_any_call(cwd("conf", "processing.conf"))
        p.return_value.read.assert_any_call(cwd("conf", "reporting.conf"))
Beispiel #6
0
 def test_process_task_range_multi(self, p):
     mkdir(cwd(analysis=1234))
     mkdir(cwd(analysis=2345))
     process_task_range("1234,2345")
     assert p.call_count == 2
     p.assert_any_call({
         "id": 1234,
         "category": "file",
         "target": "",
         "options": {},
         "package": None,
         "custom": None,
     })
     p.assert_any_call({
         "id": 2345,
         "category": "file",
         "target": "",
         "options": {},
         "package": None,
         "custom": None,
     })
Beispiel #7
0
 def test_process_task_range_multi(self, p):
     mkdir(cwd(analysis=1234))
     mkdir(cwd(analysis=2345))
     process_task_range("1234,2345")
     assert p.call_count == 2
     p.assert_any_call({
         "id": 1234,
         "category": "file",
         "target": "",
         "options": {},
         "package": None,
         "custom": None,
     })
     p.assert_any_call({
         "id": 2345,
         "category": "file",
         "target": "",
         "options": {},
         "package": None,
         "custom": None,
     })
Beispiel #8
0
 def test_process_task_range_multi_db(self, p):
     mkdir(cwd(analysis=1234))
     mkdir(cwd(analysis=2345))
     p.return_value.view_task.return_value = {}
     process_task_range("2345")
     p.return_value.view_task.assert_called_once_with(2345)
Beispiel #9
0
 def test_process_task_range_single_db(self, p):
     mkdir(cwd(analysis=1234))
     p.return_value.view_task.return_value = {}
     process_task_range("1234")
     p.return_value.view_task.assert_called_once_with(1234)
Beispiel #10
0
 def test_process_task_range_single_noanal(self, p):
     process_task_range("1234")
     p.assert_not_called()
Beispiel #11
0
 def test_process_task_range_duplicate(self, p):
     process_task_range("3,3,42")
     assert p.return_value.view_task.call_count == 2
     p.return_value.view_task.assert_any_call(3)
     p.return_value.view_task.assert_any_call(42)
Beispiel #12
0
 def test_process_task_range_multi_db(self, p):
     mkdir(cwd(analysis=1234))
     mkdir(cwd(analysis=2345))
     p.return_value.view_task.return_value = {}
     process_task_range("2345")
     p.return_value.view_task.assert_called_once_with(2345)
Beispiel #13
0
 def test_process_task_range_single_db(self, p):
     mkdir(cwd(analysis=1234))
     p.return_value.view_task.return_value = {}
     process_task_range("1234")
     p.return_value.view_task.assert_called_once_with(1234)
Beispiel #14
0
 def test_process_task_range_single_noanal(self, p):
     process_task_range("1234")
     p.assert_not_called()