# Path: stoq/plugins/archiver.py
# class ArchiverPlugin(BasePlugin):
#     async def archive(
#         self, payload: Payload, request: Request
#     ) -> Optional[ArchiverResponse]:
#         """
#         Archive payload
# 
#         :param payload: Payload object to archive
#         :param request: Originating Request object
# 
#         :return: ArchiverResponse object. Results are used to retrieve payload.
# 
#         >>> import asyncio
#         >>> from stoq import Stoq, Payload
#         >>> payload = Payload(b'this is going to be saved')
#         >>> s = Stoq()
#         >>> loop = asyncio.get_event_loop()
#         >>> archiver = s.load_plugin('filedir')
#         >>> loop.run_until_complete(archiver.archive(payload))
#         ... {'path': '/tmp/bad.exe'}
# 
#         """
#         pass
# 
#     async def get(self, task: ArchiverResponse) -> Optional[Payload]:
#         """
#         Retrieve payload for processing
# 
#         :param task: Task to be processed to load payload. Must contain `ArchiverResponse`
#                      results from `ArchiverPlugin.archive()`
# 
#         :return: Payload object for scanning
# 
#         >>> import asyncio
#         >>> from stoq import Stoq, ArchiverResponse
#         >>> s = Stoq()
#         >>> loop = asyncio.get_event_loop()
#         >>> archiver = s.load_plugin('filedir')
#         >>> task = ArchiverResponse(results={'path': '/tmp/bad.exe'})
#         >>> payload = loop.run_until_complete(archiver.get(task))
# 
#         """
#         pass
# 
# Path: stoq/data_classes.py
# class ArchiverResponse:
#     def __init__(
#         self, results: Optional[Dict] = None, errors: Optional[List[Error]] = None
#     ) -> None:
#         """
# 
#         Object containing response from archiver destination plugins
# 
#         :param results: Results from archiver plugin
#         :param errors: Errors that occurred
# 
#         >>> from stoq import ArchiverResponse
#         >>> results = {'file_id': '12345'}
#         >>> archiver_response = ArchiverResponse(results=results)
# 
#         """
#         self.results = results
#         self.errors = errors or []
# 
#     def __str__(self) -> str:
#         return helpers.dumps(self)
# 
#     def __repr__(self):
#         return repr(self.__dict__)
# 
# class Payload:
#     def __init__(
#         self,
#         content: Union[bytes, str],
#         payload_meta: Optional[PayloadMeta] = None,
#         extracted_by: Optional[Union[str, List[str]]] = None,
#         extracted_from: Optional[Union[str, List[str]]] = None,
#         payload_id: Optional[str] = None,
#     ) -> None:
#         """
# 
#         Object to store payload and related information
# 
#         :param content: Raw bytes to be scanned
#         :param payload_meta: Metadata pertaining to originating source
#         :param extracted_by: Name of plugin that extracted the payload
#         :param extracted_from: Unique payload ID the payload was extracted from
#         :param payload_id: Unique ID of payload
# 
#         >>> from stoq import PayloadMeta, Payload
#         >>> content = b'This is a raw payload'
#         >>> payload_meta = PayloadMeta(should_archive=True)
#         >>> payload = Payload(content, payload_meta=payload_meta)
# 
#         """
#         self.content = content if isinstance(content, bytes) else content.encode()
#         self.dispatch_meta: Dict[str, Dict] = {}
#         self.results = PayloadResults(
#             payload_id=payload_id,
#             size=len(content),
#             payload_meta=payload_meta,
#             extracted_from=extracted_from,
#             extracted_by=extracted_by,
#         )
# 
#     def __repr__(self):
#         return repr(self.__dict__)
# 
# class Request:
#     def __init__(
#         self,
#         payloads: Optional[List[Payload]] = None,
#         request_meta: Optional[RequestMeta] = None,
#         errors: Optional[List[Error]] = None,
#     ):
#         """
# 
#         Object that contains the state of a ``Stoq`` scan. This object is accessible within 
#         all archiver, dispatcher, and worker plugins.
# 
#         :param payloads: All payloads that are being processed, to include extracted payloads
#         :param request_meta: Original ``RequestMeta`` object
#         :param errors: All errors that have been generated by plugins or ``Stoq``
# 
#         """
# 
#         self.payloads = payloads or []
#         self.request_meta = request_meta or RequestMeta()
#         self.errors = errors or []
# 
#     def __str__(self) -> str:
#         return helpers.dumps(self)
# 
#     def __repr__(self):
#         return repr(self.__dict__)


from typing import Optional
from stoq.plugins import ArchiverPlugin
from stoq.data_classes import ArchiverResponse, Payload, Request
#!/usr/bin/env python3

#   Copyright 2014-2018 PUNCH Cyber Analytics Group
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.




class DummyArchiver(ArchiverPlugin):
    async def archive(
        self, payload: Payload, request: Request

# Path: stoq/plugins/archiver.py
# class ArchiverPlugin(BasePlugin):
#     async def archive(
#         self, payload: Payload, request: Request
#     ) -> Optional[ArchiverResponse]:
#         """
#         Archive payload
# 
#         :param payload: Payload object to archive
#         :param request: Originating Request object
# 
#         :return: ArchiverResponse object. Results are used to retrieve payload.
# 
#         >>> import asyncio
#         >>> from stoq import Stoq, Payload
#         >>> payload = Payload(b'this is going to be saved')
#         >>> s = Stoq()
#         >>> loop = asyncio.get_event_loop()
#         >>> archiver = s.load_plugin('filedir')
#         >>> loop.run_until_complete(archiver.archive(payload))
#         ... {'path': '/tmp/bad.exe'}
# 
#         """
#         pass
# 
#     async def get(self, task: ArchiverResponse) -> Optional[Payload]:
#         """
#         Retrieve payload for processing
# 
#         :param task: Task to be processed to load payload. Must contain `ArchiverResponse`
#                      results from `ArchiverPlugin.archive()`
# 
#         :return: Payload object for scanning
# 
#         >>> import asyncio
#         >>> from stoq import Stoq, ArchiverResponse
#         >>> s = Stoq()
#         >>> loop = asyncio.get_event_loop()
#         >>> archiver = s.load_plugin('filedir')
#         >>> task = ArchiverResponse(results={'path': '/tmp/bad.exe'})
#         >>> payload = loop.run_until_complete(archiver.get(task))
# 
#         """
#         pass
# 
# Path: stoq/data_classes.py
# class ArchiverResponse:
#     def __init__(
#         self, results: Optional[Dict] = None, errors: Optional[List[Error]] = None
#     ) -> None:
#         """
# 
#         Object containing response from archiver destination plugins
# 
#         :param results: Results from archiver plugin
#         :param errors: Errors that occurred
# 
#         >>> from stoq import ArchiverResponse
#         >>> results = {'file_id': '12345'}
#         >>> archiver_response = ArchiverResponse(results=results)
# 
#         """
#         self.results = results
#         self.errors = errors or []
# 
#     def __str__(self) -> str:
#         return helpers.dumps(self)
# 
#     def __repr__(self):
#         return repr(self.__dict__)
# 
# class Payload:
#     def __init__(
#         self,
#         content: Union[bytes, str],
#         payload_meta: Optional[PayloadMeta] = None,
#         extracted_by: Optional[Union[str, List[str]]] = None,
#         extracted_from: Optional[Union[str, List[str]]] = None,
#         payload_id: Optional[str] = None,
#     ) -> None:
#         """
# 
#         Object to store payload and related information
# 
#         :param content: Raw bytes to be scanned
#         :param payload_meta: Metadata pertaining to originating source
#         :param extracted_by: Name of plugin that extracted the payload
#         :param extracted_from: Unique payload ID the payload was extracted from
#         :param payload_id: Unique ID of payload
# 
#         >>> from stoq import PayloadMeta, Payload
#         >>> content = b'This is a raw payload'
#         >>> payload_meta = PayloadMeta(should_archive=True)
#         >>> payload = Payload(content, payload_meta=payload_meta)
# 
#         """
#         self.content = content if isinstance(content, bytes) else content.encode()
#         self.dispatch_meta: Dict[str, Dict] = {}
#         self.results = PayloadResults(
#             payload_id=payload_id,
#             size=len(content),
#             payload_meta=payload_meta,
#             extracted_from=extracted_from,
#             extracted_by=extracted_by,
#         )
# 
#     def __repr__(self):
#         return repr(self.__dict__)
# 
# class Request:
#     def __init__(
#         self,
#         payloads: Optional[List[Payload]] = None,
#         request_meta: Optional[RequestMeta] = None,
#         errors: Optional[List[Error]] = None,
#     ):
#         """
# 
#         Object that contains the state of a ``Stoq`` scan. This object is accessible within 
#         all archiver, dispatcher, and worker plugins.
# 
#         :param payloads: All payloads that are being processed, to include extracted payloads
#         :param request_meta: Original ``RequestMeta`` object
#         :param errors: All errors that have been generated by plugins or ``Stoq``
# 
#         """
# 
#         self.payloads = payloads or []
#         self.request_meta = request_meta or RequestMeta()
#         self.errors = errors or []
# 
#     def __str__(self) -> str:
#         return helpers.dumps(self)
# 
#     def __repr__(self):
#         return repr(self.__dict__)


# Path: stoq/tests/data/plugins/archiver/dummy_archiver/dummy_archiver.py
from typing import Optional
from stoq.plugins import ArchiverPlugin
from stoq.data_classes import ArchiverResponse, Payload, Request

#!/usr/bin/env python3

#   Copyright 2014-2018 PUNCH Cyber Analytics Group
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.




class DummyArchiver(ArchiverPlugin):
    async def archive(
        self, payload: Payload, request: Request

    ) -> Optional[ArchiverResponse]: