# Path: stoq/data_classes.py
# 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__)
# 
# class DispatcherResponse:
#     def __init__(
#         self,
#         plugin_names: Optional[List[str]] = None,
#         meta: Optional[Dict] = None,
#         errors: Optional[List[Error]] = None,
#     ) -> None:
#         """
# 
#         Object containing response from dispatcher plugins
# 
#         :param plugins_names: Plugins to send payload to for scanning
#         :param meta: Metadata pertaining to dispatching results
#         :param errors: Errors that occurred
# 
#         >>> from stoq import DispatcherResponse
#         >>> plugins = ['yara', 'exif']
#         >>> meta = {'hit': 'exe_file'}
#         >>> dispatcher = DispatcherResponse(plugin_names=plugins, meta=meta)
# 
#         """
#         self.plugin_names = [] if plugin_names is None else plugin_names
#         self.meta = {} if meta is None else meta
#         self.errors = errors or []
# 
#     def __str__(self) -> str:
#         return helpers.dumps(self)
# 
#     def __repr__(self):
#         return repr(self.__dict__)
# 
# Path: stoq/plugins/dispatcher.py
# class DispatcherPlugin(BasePlugin, ABC):
#     @abstractmethod
#     async def get_dispatches(
#         self, payload: Payload, request: Request
#     ) -> Optional[DispatcherResponse]:
#         pass


from typing import Optional
from stoq.data_classes import Payload, Request, DispatcherResponse
from stoq.plugins import DispatcherPlugin
#!/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 DummyDispatcher(DispatcherPlugin):
    async def get_dispatches(
        self, payload: Payload, request: Request

# Path: stoq/data_classes.py
# 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__)
# 
# class DispatcherResponse:
#     def __init__(
#         self,
#         plugin_names: Optional[List[str]] = None,
#         meta: Optional[Dict] = None,
#         errors: Optional[List[Error]] = None,
#     ) -> None:
#         """
# 
#         Object containing response from dispatcher plugins
# 
#         :param plugins_names: Plugins to send payload to for scanning
#         :param meta: Metadata pertaining to dispatching results
#         :param errors: Errors that occurred
# 
#         >>> from stoq import DispatcherResponse
#         >>> plugins = ['yara', 'exif']
#         >>> meta = {'hit': 'exe_file'}
#         >>> dispatcher = DispatcherResponse(plugin_names=plugins, meta=meta)
# 
#         """
#         self.plugin_names = [] if plugin_names is None else plugin_names
#         self.meta = {} if meta is None else meta
#         self.errors = errors or []
# 
#     def __str__(self) -> str:
#         return helpers.dumps(self)
# 
#     def __repr__(self):
#         return repr(self.__dict__)
# 
# Path: stoq/plugins/dispatcher.py
# class DispatcherPlugin(BasePlugin, ABC):
#     @abstractmethod
#     async def get_dispatches(
#         self, payload: Payload, request: Request
#     ) -> Optional[DispatcherResponse]:
#         pass


# Path: stoq/tests/data/plugins/dispatcher/dummy_dispatcher/dummy_dispatcher.py
from typing import Optional
from stoq.data_classes import Payload, Request, DispatcherResponse
from stoq.plugins import DispatcherPlugin

#!/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 DummyDispatcher(DispatcherPlugin):
    async def get_dispatches(
        self, payload: Payload, request: Request

    ) -> Optional[DispatcherResponse]: