def main():
    # Create VxCubeApi
    vxcube = VxCubeApi(api_key=API_KEY)

    number = count(start=0)
    # Get all analyses
    for analysis in vxcube.analyses_iter():
        for task in analysis.tasks:
            if task.is_success:
                for dump in task.dumps_iter():

                    # sha1 is None when dump is not available
                    if dump["sha1"] is not None:
                        print("{number}. {sha1}".format(number=next(number),
                                                        sha1=dump["sha1"]))
def main():
    # Create VxCubeApi
    vxcube = VxCubeApi(api_key=API_KEY)

    # Get all analyses
    for analysis in vxcube.analyses_iter():
        for task in analysis.tasks:
            if task.is_success:
                # Get info about task archive
                # This is an extra request to make sure PCAP exists
                info = task.storage_lists()
                assert "network.pcap" in info["files"]

                print("Download PCAP from {task.id}".format(task=task))
                task.download_storage_file(
                    "network.pcap",
                    output_file="task_{task.id}.pcap".format(task=task))
Beispiel #3
0
def test_vxuserapi_analyses_iter():
    kwargs = dict(count=4, offset=2, format_group_name=None)
    request = mock.Mock(return_value=[{"id": 23}, {"id": 42}])
    with mock.patch("vxcube_api.raw_api.VxCubeApiRequest.request",
                    new=request):
        api = VxCubeApi(base_url="http://test", version=2.0)
        analyses = list(api.analyses_iter(**kwargs))

        assert isinstance(analyses, list)
        assert len(analyses) == 2
        assert analyses[0].id == 23
        assert analyses[0]._raw_api is api._raw_api
        assert analyses[1].id == 42
        assert analyses[1]._raw_api is api._raw_api

    request.assert_called_with(method="get",
                               url="http://test/api-2.0/analyses",
                               params={},
                               headers={},
                               json={
                                   "count": 100,
                                   "offset": 2
                               })