diff --git a/.github/workflows/build_tests.yml b/.github/workflows/build_tests.yml index f5a9411..cfa61fa 100644 --- a/.github/workflows/build_tests.yml +++ b/.github/workflows/build_tests.yml @@ -13,4 +13,4 @@ jobs: uses: neongeckocom/.github/.github/workflows/python_build_tests.yml@master with: test_pipaudit: true - pipaudit_ignored: "GHSA-r9hx-vwmv-q579 PYSEC-2022-43012 GHSA-j8r2-6x86-q33q" \ No newline at end of file + pipaudit_ignored: "GHSA-r9hx-vwmv-q579 PYSEC-2022-43012 GHSA-j8r2-6x86-q33q GHSA-9wx4-h78v-vm56" diff --git a/.github/workflows/install_tests.yml b/.github/workflows/install_tests.yml index 4aaabea..d40fecc 100644 --- a/.github/workflows/install_tests.yml +++ b/.github/workflows/install_tests.yml @@ -11,12 +11,12 @@ jobs: strategy: max-parallel: 2 matrix: - python-version: [ 3.7, 3.8, 3.9, "3.10" ] + python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Build Tools @@ -31,4 +31,4 @@ jobs: python setup.py bdist_wheel - name: Install package run: | - pip install .[all] \ No newline at end of file + pip install .[all] diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 9eaa17f..cd38eb0 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -4,29 +4,29 @@ on: branches: - dev paths-ignore: - - 'ovos_messagebus/version.py' - - 'examples/**' - - '.github/**' - - '.gitignore' - - 'LICENSE' - - 'CHANGELOG.md' - - 'MANIFEST.in' - - 'readme.md' - - 'scripts/**' + - "ovos_messagebus/version.py" + - "examples/**" + - ".github/**" + - ".gitignore" + - "LICENSE" + - "CHANGELOG.md" + - "MANIFEST.in" + - "readme.md" + - "scripts/**" push: branches: - master paths-ignore: - - 'ovos_messagebus/version.py' - - 'requirements/**' - - 'examples/**' - - '.github/**' - - '.gitignore' - - 'LICENSE' - - 'CHANGELOG.md' - - 'MANIFEST.in' - - 'readme.md' - - 'scripts/**' + - "ovos_messagebus/version.py" + - "requirements/**" + - "examples/**" + - ".github/**" + - ".gitignore" + - "LICENSE" + - "CHANGELOG.md" + - "MANIFEST.in" + - "readme.md" + - "scripts/**" workflow_dispatch: jobs: @@ -34,12 +34,12 @@ jobs: strategy: max-parallel: 2 matrix: - python-version: [ 3.7, 3.8, 3.9] + python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install System Dependencies @@ -50,6 +50,7 @@ jobs: - name: Install core repo run: | pip install . + # TODO: Implement unit tests # - name: Install test dependencies # run: | diff --git a/README.md b/README.md index 890cfa6..911da52 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ messagebus service, the nervous system of OpenVoiceOS ## Alternative implementations - [OVOS Bus Server](https://github.com/OpenVoiceOS/ovos-bus-server/) - Alternative C++ messagebus server implementation using WebSocket++ - +- [OVOS Rust Messagebus](https://github.com/OscillateLabsLLC/ovos-rust-messagebus) - Alternative Rust messagebus server implementation # Configuration @@ -21,8 +21,12 @@ under mycroft.conf "ssl": false, // in mycroft-core all skills share a bus, this allows malicious skills // to manipulate it and affect other skills, this option ensures each skill - // gets it's own websocket connection - "shared_connection": true + // gets its own websocket connection + "shared_connection": true, + // filter out messages of certain types from the bus logs + "filter": false, + // which messages to filter if filter is enabled + "filter_logs": ["gui.status.request", "gui.page.upload"] } } -``` \ No newline at end of file +``` diff --git a/ovos_messagebus/event_handler.py b/ovos_messagebus/event_handler.py index e54824d..3ae8031 100644 --- a/ovos_messagebus/event_handler.py +++ b/ovos_messagebus/event_handler.py @@ -35,31 +35,45 @@ def __init__(self, application, request, **kwargs): def on(self, event_name, handler): self.emitter.on(event_name, handler) + @property + def filter(self) -> bool: + return Configuration().get("websocket", {}).get("filter", False) + + @property + def filter_logs(self) -> list: + return Configuration().get("websocket", {}).get("filter_logs", ["gui.status.request", "gui.page.upload"]) + @property def max_message_size(self) -> int: return Configuration().get("websocket", {}).get("max_msg_size", 10) * 1024 * 1024 def on_message(self, message): + if not self.filter: + try: + self.emitter.emit(message) + except Exception as e: + LOG.exception(e) + traceback.print_exc(file=sys.stdout) + pass + else: + try: + deserialized_message = Message.deserialize(message) + except Exception: + return + + if deserialized_message.msg_type not in self.filter_logs: + LOG.debug(deserialized_message.msg_type + + f' source: {deserialized_message.context.get("source", [])}' + + f' destination: {deserialized_message.context.get("destination", [])}\n' + f'SESSION: {SessionManager.get(deserialized_message).serialize()}') - try: - deserialized_message = Message.deserialize(message) - except Exception: - return - - filter_ogs = ["gui.status.request", "gui.page.upload"] - if deserialized_message.msg_type not in filter_ogs: - LOG.debug(deserialized_message.msg_type + - f' source: {deserialized_message.context.get("source", [])}' + - f' destination: {deserialized_message.context.get("destination", [])}\n' - f'SESSION: {SessionManager.get(deserialized_message).serialize()}') - - try: - self.emitter.emit(deserialized_message.msg_type, - deserialized_message) - except Exception as e: - LOG.exception(e) - traceback.print_exc(file=sys.stdout) - pass + try: + self.emitter.emit(deserialized_message.msg_type, + deserialized_message) + except Exception as e: + LOG.exception(e) + traceback.print_exc(file=sys.stdout) + pass for client in client_connections: client.write_message(message)