-
-
Notifications
You must be signed in to change notification settings - Fork 434
Next release #1770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next release #1770
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| # artifacts, e.g. "/data/config") instead of hardcoding a path — see | ||
| # docs/PLUGINS_DEV.md#persisting-plugin-data-state--config-files | ||
| # from const import dbFolderPath, configPath | ||
| from plugin_helper import Plugin_Objects # noqa: E402, E261 [flake8 lint suppression] | ||
| from plugin_helper import Plugin_Objects, decode_settings_base64 # noqa: E402, E261 [flake8 lint suppression] | ||
| from logger import mylog, Logger # noqa: E402, E261 [flake8 lint suppression] | ||
| from helper import get_setting_value # noqa: E402, E261 [flake8 lint suppression] | ||
|
|
||
|
|
@@ -48,6 +48,15 @@ def main(): | |
|
|
||
| mylog('verbose', [f'[{pluginName}] some_setting value {some_setting}']) | ||
|
|
||
| # Example: reading the nested "one or more instances" setting pattern | ||
| # (config.json's "nested_form_example") instead of a fixed hardcoded | ||
| # "primary"/"secondary" pair - see docs/PLUGINS_DEV.md#conventions-checklist. | ||
| for instance in get_configured_instances(): | ||
| mylog('verbose', [ | ||
| f"[{pluginName}] configured instance: {instance['name']} -> {instance['url']} " | ||
| f"(enabled={instance['enabled']})" | ||
| ]) | ||
|
Comment on lines
+54
to
+58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Add a
As per coding guidelines: 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| # retrieve data | ||
| device_data = get_device_data(some_setting) | ||
|
|
||
|
|
@@ -86,6 +95,33 @@ def main(): | |
| return 0 | ||
|
|
||
|
|
||
| def get_configured_instances(): | ||
| """ | ||
| Example of processing the "nested_form_example" setting from config.json - | ||
| the multi-instance settings pattern (a popup form per list entry), used | ||
| when a plugin needs to support an arbitrary number of instances instead | ||
| of a fixed "primary"/"secondary" pair. See server/plugins/rest_import for | ||
| the full-featured version this is based on. | ||
|
|
||
| Each raw entry in the setting's list is a base64-encoded JSON blob; | ||
| decode_settings_base64() turns it into a dict keyed by the popupForm's | ||
| "function" names (here: TMP_instance_name/_url/_enabled). | ||
| """ | ||
| raw_instances = get_setting_value('TMP_nested_form_example') or [] | ||
|
|
||
| instances = [] | ||
| for raw in raw_instances: | ||
| cfg = decode_settings_base64(raw) | ||
| instances.append({ | ||
| 'name': cfg.get('TMP_instance_name', ''), | ||
| 'url': cfg.get('TMP_instance_url', ''), | ||
| 'enabled': bool(cfg.get('TMP_instance_enabled', True)), | ||
| }) | ||
|
|
||
| # Skip instances the user unchecked rather than deleted. | ||
| return [instance for instance in instances if instance['enabled']] | ||
|
|
||
|
|
||
| # retrieve data | ||
| def get_device_data(some_setting): | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
Sensitive Data Exposure (CWE-532): Insertion of Sensitive Information into Log File
Reachability: External · Exploitability: Moderate
Redact credentials before logging configured URLs.
get_configured_instances()preservesTMP_instance_url, andmylogreceives it without redaction. Log the instance name and sanitized host instead.🤖 Prompt for AI Agents