test: screen selector bounds and BLE global script handler encoding#2214
Merged
Conversation
Extend isSafeRemoteScreenSelector tests for DEL and max-length bounds. Expose encodeBleUtf8PayloadForScriptHandler for BLE notify payloads and replace the placeholder bluetooth test with encoding regression cases. Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds regression tests around recent security-sensitive definition loading and BLE notify handling. Includes a tiny
@visibleForTestinghelper so the JSON-encoding contract used byScreenController.runGlobalScriptHandlerstays explicitly covered.Related Issue
N/A (automation coverage pass).
Type of Change
What Has Changed
modules/ensemble/test/remote_definition_security_test.dart: assertisSafeRemoteScreenSelectorrejects ASCII DEL (\u007f) and strings longer than 256 characters (bounds used by local bundled and remote screen resolution).modules/ensemble_bluetooth/lib/ensemble_bluetooth.dart: introduceencodeBleUtf8PayloadForScriptHandler(samejsonEncodebehavior as before) so unit tests pin the “safe string literal argument” property for BLE payloads passed intofunctionName($inputs)construction inScreenController.modules/ensemble_bluetooth/test/ensemble_bluetooth_test.dart: replace placeholder test with deterministic encoding cases (quotes, newlines, adversarial substrings).Risky behavior now covered
rootBundle.loadString('.../screens/<screen>.yaml')paths must reject oversized and DEL-containing values, not only obvious../and slash cases. A regression in the length or control-character checks could re-open asset or CDN path abuse.library.function(<inputs>)call. JSON-encoding as a single string literal prevents delimiter injection; tests now lock that encoding step to the helper used in production.How to Test
melos bootstrap(if dependencies are not linked).cd modules/ensemble && flutter test test/remote_definition_security_test.dartcd modules/ensemble_bluetooth && flutter testEnvironment note: The automation sandbox did not have the Flutter SDK on
PATH, soflutter testwas not executed here. Please run the commands above in a normal dev/CI environment; the added tests are pure Dart (jsonEncode/jsonDecodeand string predicates) and should not be environment-dependent.Screenshots / Videos
N/A
Checklist
flutter analyzeand addressed any new warningsflutter testand all tests passWhy these tests materially reduce regression risk
They target high blast-radius security invariants that are easy to break with a small refactor: (1) selector validation is centralized and reused; missing a boundary case reintroduces traversal or unexpected IO. (2) BLE payloads are attacker-controlled once a device is paired; losing
jsonEncodesilently restores script injection into the global handler bridge.