Compare commits

...
2 Commits
Author SHA1 Message Date
MrBlakeandClaude Opus 5.5 d8fce752d2 chore: release 4.24.1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 09:59:14 +01:00
MrBlakeandClaude Opus 5.5 7f04944343 fix: strip NUL characters from scans, add last user to the report and refresh it on changes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 09:59:13 +01:00
5 changed files with 27 additions and 4 deletions

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
#define AppName "NetBox Synchronizer"
#ifndef AppVersion
#define AppVersion "4.24.0"
#define AppVersion "4.24.1"
#endif
#define AppPublisher "Louis-Alexander Kerst"
#define AppExeName "NetBoxSynchronizer.exe"
+1 -1
View File
@@ -1,7 +1,7 @@
"""NetBox Synchronizer – VMs, switches and clients from the field into NetBox."""
APP_NAME = "NetBox Synchronizer"
APP_VERSION = "4.24.0"
APP_VERSION = "4.24.1"
APP_PUBLISHER = "Louis-Alexander Kerst"
APP_USER_MODEL_ID = "Louis-AlexanderKerst.NetBoxSynchronizer"
+3 -2
View File
@@ -30,6 +30,7 @@ def inventory_report(client):
else "") if part)),
("CPU", f"{client['cpu']} ({client.get('cores') or '?'} Kerne)" if client.get("cpu") else ""),
("RAM", f"{client['memory'] / 1024 ** 3:.0f} GB" if client.get("memory") else ""),
("Zuletzt angemeldet", (client.get("user") or "").strip()),
("Erfasst", client.get("scanned_at") and time.strftime("%d.%m.%Y %H:%M", time.localtime(client["scanned_at"]))),
):
if value:
@@ -302,7 +303,7 @@ class ClientSyncEngine:
if (client.get("uuid") or client.get("user")) and (getattr(asset, "description", "") or "") != description:
updates["description"] = description
current = getattr(asset, "comments", "") or ""
if report_text and _without_timestamp(_report_body(current)) != _without_timestamp(report_text):
if report_text and (updates or _without_timestamp(_report_body(current)) != _without_timestamp(report_text)):
updates["comments"] = merge_report(current, report_text)
if not updates:
return []
@@ -411,7 +412,7 @@ class ClientSyncEngine:
changes.append(f"Beschreibung → {description}")
report_text = inventory_report(client)
current = getattr(device, "comments", "") or ""
if report_text and _without_timestamp(_report_body(current)) != _without_timestamp(report_text):
if report_text and (updates or _without_timestamp(_report_body(current)) != _without_timestamp(report_text)):
updates["comments"] = merge_report(current, report_text)
changes.append(f"Inventarbericht aktualisieren ({len(client.get('software') or [])} Programme)")
if updates:
+12
View File
@@ -241,9 +241,21 @@ def chassis_name(types):
return ""
def _strip_nul(value):
"""Drop NUL characters (some installers pad registry strings with them; NetBox rejects them)."""
if isinstance(value, str):
return value.replace("\x00", "").strip() if "\x00" in value else value
if isinstance(value, dict):
return {key: _strip_nul(item) for key, item in value.items()}
if isinstance(value, list):
return [_strip_nul(item) for item in value]
return value
def apply_scan(row, raw, now=None):
"""Merge the raw WinRM result into a result row."""
row = dict(row)
raw = _strip_nul(raw)
row["scanned_at"] = now or time.time()
if not raw.get("ok"):
row["status"] = "error"
+10
View File
@@ -338,3 +338,13 @@ def test_asset_gets_the_tenant_of_the_transfer_or_the_device():
again.load_targets()
report = again.sync([client2], 1, 2, dry_run=False)
assert report["errors"] == [] and assets2.records[0].tenant == 9 and assets2.records[0].device == 300
def test_nul_characters_are_stripped_and_user_is_in_the_report():
from netbox_sync.core.client_sync import inventory_report
from netbox_sync.core.clients import apply_scan
raw = {"ok": True, "source": "agent", "name": "pc01", "user": "FIRMA\max",
"software": [{"name": "Office", "version": "16", "publisher": "Microsoft\x00"}]}
row = apply_scan({"name": "PC01"}, raw, now=0)
assert row["software"][0]["publisher"] == "Microsoft"
assert "- **Zuletzt angemeldet:** FIRMA\max" in inventory_report(row)