generated from home-assistant/addons-example
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 FIX: fixed logger to evaluate msg string
- Loading branch information
Showing
6 changed files
with
34 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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")) | ||
|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters