From 60641161d5c384d77fe1385d1dd70aa228ee7db6 Mon Sep 17 00:00:00 2001 From: cproudlock Date: Fri, 26 Jun 2026 20:18:01 -0400 Subject: [PATCH] Second-pass review fixes: kill last hardcoded creds, wire get_services, dedup Verification audit (re-run of the 6 skill lenses) confirmed the prior fixes hold and surfaced a few misses: Security (HIGH): - search.py _check_smart_redirect still opened a raw pymysql connection with root/rootpassword (reachable on any 9-digit SSO query). Now uses the shared env-backed employee_connection helper. - Deleted dead shopdb/core/services/employee_service.py (zero importers; carried another root/rootpassword literal). No hardcoded credentials remain in app logic; config.py dev defaults stay gated by ProductionConfig.validate. Dead hook: - get_services was implemented by the printers plugin but had no consumer (docs claimed otherwise). Added PluginManager.get_service(name) that resolves a service from enabled plugins; updated PLUGIN-HOOKS.md. Tests: - search disabled-plugin exclusion (the high-value gap): enabled plugin's hostname appears, disabled plugin's hostname drops out (searched by a hostname distinct from assetnumber so only the gated domain can match). - get_service consumer test (unknown name -> None). Simplify: - Extract the triplicated GE_LOGO_SVG + loadLogo + drawLogoOverlay into shared frontend/src/views/print/qrLogo.js (renderQrDataUrl); both QR views use it. - applications.py: lift the misplaced pagination import to the top; drop unused Computer unpacking in the 3 endpoints that only touch ComputerInstalledApp. 154 tests pass, naming/style green, app boots, QR render verified. Co-Authored-By: Claude Opus 4.8 --- docs/PLUGIN-HOOKS.md | 4 +- frontend/src/views/print/PrinterQRBatch.vue | 48 +- frontend/src/views/print/PrinterQRSingle.vue | 46 +- frontend/src/views/print/qrLogo.js | 51 + shopdb/core/api/applications.py | 1031 +++++++++--------- shopdb/core/api/search.py | 11 +- shopdb/core/services/employee_service.py | 104 -- shopdb/plugins/__init__.py | 19 + tests/test_core/test_search_disabled.py | 43 + tests/test_plugin_contract.py | 9 + 10 files changed, 648 insertions(+), 718 deletions(-) create mode 100644 frontend/src/views/print/qrLogo.js delete mode 100644 shopdb/core/services/employee_service.py create mode 100644 tests/test_core/test_search_disabled.py diff --git a/docs/PLUGIN-HOOKS.md b/docs/PLUGIN-HOOKS.md index 5eb16d0..9d14be7 100644 --- a/docs/PLUGIN-HOOKS.md +++ b/docs/PLUGIN-HOOKS.md @@ -140,7 +140,9 @@ class ComputersPlugin(BasePlugin): ### `get_services() -> Dict[str, Type]` -Returns a dict of service-name to service-class. Other plugins can request services via the plugin manager. +Returns a dict of service-name to service-class. Another plugin obtains one via +`plugin_manager.get_service('')`, which searches enabled plugins and +returns the registered class/factory (or None). ```python from .services import ZabbixService diff --git a/frontend/src/views/print/PrinterQRBatch.vue b/frontend/src/views/print/PrinterQRBatch.vue index 284008c..a4ac8a5 100644 --- a/frontend/src/views/print/PrinterQRBatch.vue +++ b/frontend/src/views/print/PrinterQRBatch.vue @@ -65,7 +65,7 @@