Skip to content

Commit

Permalink
🐛 FIX: fixed logger to evaluate msg string
Browse files Browse the repository at this point in the history
  • Loading branch information
unl0ck committed Jul 15, 2024
1 parent 0bf9224 commit 315ff49
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .bumpversion-edge.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "2.8.2"
current_version = "2.8.3"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
Expand Down
18 changes: 16 additions & 2 deletions GridboxConnectorAddon-edge/GridboxConnector/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def load_gridbox_config():
data = json.load(json_file)
return data


if __name__ == '__main__':
def run_addon():
gridbox_config = load_gridbox_config()
options_file = ''
WAIT = int(os.getenv('WAITTIME', "60"))
Expand Down Expand Up @@ -67,3 +66,18 @@ def load_gridbox_config():
logger.warning("No data received")
gridboxConnector.init_auth()
time.sleep(WAIT)

def run_test_log():

logging_test = "{'grant_type': 'http://auth0.com/oauth/grant-type/password-realm', 'username': '[email protected]', 'password': 'Simon1991!', 'audience': 'my.gridx', 'client_id': 'oZpr934Ikn8OZOHTJEcrgXkjio0I0Q7b', 'scope': 'email openid', 'realm': 'viessmann-authentication-db'}"
try:
json_msg = json.loads(logging_test)
except json.JSONDecodeError:
# Wenn die Nachricht kein JSON ist, nichts tun
logging.error('Could not parse message as JSON')
logger.info(logging_test)


if __name__ == '__main__':
#run_addon()
run_test_log()
26 changes: 14 additions & 12 deletions GridboxConnectorAddon-edge/GridboxConnector/utils.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import json
import logging

import ast
class SensitiveDataFilter(logging.Filter):
def filter(self, record):
message = record.getMessage()
try:
# Versuchen, die Nachricht als JSON zu parsen
data = json.loads(message)
literal_msg = ast.literal_eval(message)
# Sensible Daten filtern, falls vorhanden
if 'username' in data:
data['username'] = '***'
if 'password' in data:
data['password'] = '***'
if 'id_token' in data:
data['id_token'] = '***'
if 'access_token' in data:
data['access_token'] = '***'
if 'username' in literal_msg:
literal_msg['username'] = '***'
if 'password' in literal_msg:
literal_msg['password'] = '***'
if 'id_token' in literal_msg:
literal_msg['id_token'] = '***'
if 'access_token' in literal_msg:
literal_msg['access_token'] = '***'
if 'client_id' in literal_msg:
literal_msg['client_id'] = '***'
# Das modifizierte Dictionary zurück in einen String konvertieren
record.msg = json.dumps(data)
record.msg = json.dumps(literal_msg)
except json.JSONDecodeError:
# Wenn die Nachricht kein JSON ist, nichts tun
logging.error('Could not parse message as JSON')
pass
return True
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-edge/cloudSettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.8.2",
"version": "2.8.3",
"urls": {
"login": "https://gridx.eu.auth0.com/oauth/token",
"gateways": "https://api.gridx.de/gateways",
Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-edge/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
---
name: Viessmann Gridbox Connector (edge)
version: "2.8.2"
version: "2.8.3"
slug: "gridbox_connector_edge"
description: "Viessmann Gridbox Connector (edge)"
url: "https://github.com/unl0ck/homeassistant-addon-viessmann-gridbox/tree/main/GridboxConnectorAddon-edge"
Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-edge/rootfs/share/cloudSettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.8.2",
"version": "2.8.3",
"urls": {
"login": "https://gridx.eu.auth0.com/oauth/token",
"gateways": "https://api.gridx.de/gateways",
Expand Down

0 comments on commit 315ff49

Please sign in to comment.