Beispiel #1
0
    def test_start_analysis_nofile(self):
        set_cwd(tempfile.mkdtemp())
        cuckoo_create()
        target = mock.MagicMock()
        target.is_file = False
        analysis = mock.MagicMock()
        analysis.status = "starting"
        gm = GuestManager(
            "cuckoo1", "1.2.3.4", "windows", 1, None, analysis,
            target
        )
        gm.wait_available = mock.MagicMock()
        httpresponse = mock.MagicMock()
        httpresponse.status_code = 200
        httpresponse.json.return_value = {
            "version": 0.8,
            "features": ["pinning", "execpy"]
        }
        gm.post = mock.MagicMock()
        gm.get = mock.MagicMock(return_value=httpresponse)
        gm.query_environ = mock.MagicMock()
        gm.upload_analyzer = mock.MagicMock()
        gm.add_config = mock.MagicMock()
        gm.determine_temp_path = mock.MagicMock(return_value="/tmp/sIYUbJJ")
        gm.analysis_manager = mock.MagicMock()

        gm.start_analysis({"timeout": 60, "file_name": "doge"}, None)

        assert gm.analysis.status == "starting"
        gm.get.assert_called_with("/pinning")
        gm.target.helper.get_filepointer.assert_not_called()
        gm.post.assert_called_once_with("/execpy", data=mock.ANY)
Beispiel #2
0
 def test_start_analysis_timeout(self):
     set_cwd(tempfile.mkdtemp())
     cuckoo_create(cfg={
         "cuckoo": {
             "timeouts": {
                 "critical": 123,
             },
         },
     })
     gm = GuestManager("cuckoo1", "1.2.3.4", "windows", 1, None)
     gm.wait_available = mock.MagicMock(side_effect=Exception)
     with pytest.raises(Exception):
         gm.start_analysis({"timeout": 42}, None)
     assert gm.timeout == 165
Beispiel #3
0
 def test_start_analysis_timeout(self):
     set_cwd(tempfile.mkdtemp())
     cuckoo_create(cfg={
         "cuckoo": {
             "timeouts": {
                 "critical": 123,
             },
         },
     })
     gm = GuestManager("cuckoo1", "1.2.3.4", "windows", 1, None)
     gm.wait_available = mock.MagicMock(side_effect=Exception)
     with pytest.raises(Exception):
         gm.start_analysis({"timeout": 42}, None)
     assert gm.timeout == 165