Skip to content

Commit

Permalink
🐛 FIX: fixed sensitive data
Browse files Browse the repository at this point in the history
  • Loading branch information
unl0ck committed Dec 26, 2024
1 parent e7041c5 commit 5f1961e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 30 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.11.26"
current_version = "2.11.27"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,7 @@ jobs:
--target /data/${{ matrix.addon }} \
--image "${{ steps.check.outputs.image }}" \
--docker-hub "ghcr.io/${{ github.repository_owner }}" \
--cosign \
--addon
env:
LOGFIRE_TOKEN: ${{ secrets.LOGFIRE_TOKEN }}
6 changes: 6 additions & 0 deletions GridboxConnectorAddon-edge/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->

## 2.11.27

### 🔨 Fixed

- sensitive filter fixed

## 2.11.26

### 🚀 Added
Expand Down
39 changes: 13 additions & 26 deletions GridboxConnectorAddon-edge/GridboxConnector/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,19 @@
class SensitiveDataFilter(logging.Filter):
def filter(self, record):
message = record.getMessage()
# try:
# literal_msg = ast.literal_eval(message)
# # Sensible Daten filtern, falls vorhanden
# 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(literal_msg)
# except Exception as e:
# logging.error(f"Error filtering sensitive data: {e}")
# pass
message = record.getMessage()
# Sensible Daten filtern, falls vorhanden
message = re.sub(r'username=[\'"].+?[\'"]', 'username="***"', message)
message = re.sub(r'password=[\'"].+?[\'"]', 'password="***"', message)
message = re.sub(r'id_token=[\'"].+?[\'"]', 'id_token="***"', message)
message = re.sub(r'access_token=[\'"].+?[\'"]', 'access_token="***"', message)
message = re.sub(r'client_id=[\'"].+?[\'"]', 'client_id="***"', message)
record.msg = message
try:
message_json = json.loads(message)
# Sensible Daten filtern, falls vorhanden
sensitive_keys = ['username', 'password', 'id_token', 'access_token', 'client_id']
for key in sensitive_keys:
if key in message_json:
message_json[key] = '***'
# Das modifizierte JSON-Objekt zurück in einen String konvertieren
record.msg = json.dumps(message_json)
except json.JSONDecodeError:
logging.error("Error decoding JSON message")
except Exception as e:
logging.error(f"Error filtering sensitive data: {e}")
return True

def get_bool_env(var, default=False):
Expand Down
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.11.26",
"version": "2.11.27",
"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.11.26"
version: "2.11.27"
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.11.26",
"version": "2.11.27",
"urls": {
"login": "https://gridx.eu.auth0.com/oauth/token",
"gateways": "https://api.gridx.de/gateways",
Expand Down

0 comments on commit 5f1961e

Please sign in to comment.