feat(test-tools): device compatibility system with expected overrides#674
feat(test-tools): device compatibility system with expected overrides#674
Conversation
…ides - Extend DevicePlugin interface with ignoreMethodParams and expectedOverrides - Add param-level compatibility checks (e.g. EIP-7702 authorizationList) - Add expected result overrides for device behavioral differences - Update Classic plugin: unsupported methods, param filters, expected overrides - Update Classic 1S plugin: DNX methods, stellar/nem/sol overrides - Sync Classic Pure plugin with Classic 1S configuration - Integrate compatibility checks into Blind Signature Security Test - Add device-specific expected display in ResultView - Add device method support documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
packages/connect-examples/expo-example/src/testTools/securityCheckTest/blindSignature/index.tsx
Fixed
Show fixed
Hide fixed
| // Path format: m/44'/60'/0' -> coinType = 60 | ||
| const pathParts = item.path?.split('/') || []; | ||
| const coinTypePart = pathParts[2] || ''; // e.g., "60'" | ||
| const coinType = coinTypePart.replace("'", ''); // e.g., "60" |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding High test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 days ago
To fix the issue, ensure that all occurrences of the ' character are removed from coinTypePart, not just the first. This is done by using a regular expression with the global (g) flag instead of a string literal in replace.
Concretely, in packages/connect-examples/expo-example/src/testTools/securityCheckTest/blindSignature/index.tsx, update line 271:
- Change
coinTypePart.replace("'", '');to use a regex:coinTypePart.replace(/'/g, '');.
This preserves existing functionality for standard paths like m/44'/60'/0', while correctly handling any unexpected extra ' characters and eliminating the static analysis warning. No new imports or helper methods are needed.
| @@ -268,7 +268,7 @@ | ||
| // Path format: m/44'/60'/0' -> coinType = 60 | ||
| const pathParts = item.path?.split('/') || []; | ||
| const coinTypePart = pathParts[2] || ''; // e.g., "60'" | ||
| const coinType = coinTypePart.replace("'", ''); // e.g., "60" | ||
| const coinType = coinTypePart.replace(/'/g, ''); // e.g., "60" | ||
|
|
||
| // Use device-specific expected value (if override configured) | ||
| const expected = getDeviceExpected( |
|
|
||
| const pathParts = item.path?.split('/') || []; | ||
| const coinTypePart = pathParts[2] || ''; | ||
| const coinType = coinTypePart.replace("'", ''); |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding High test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 days ago
In general, to fix this class of problem you must ensure that all occurrences of the target substring or character are handled, not just the first. In JavaScript/TypeScript, this is commonly done by using String.prototype.replace with a global regular expression (e.g. /'/g) or by using replaceAll when available, or by choosing a more precise parsing approach if semantics are more complex than simple removal.
For this specific code, coinTypePart.replace("'", '') is clearly intended to strip apostrophes from the coin type segment of a derivation path. The minimal, behavior-preserving fix is to change it so that it removes all apostrophes, not just the first. The safest cross-environment approach that does not require any new imports is to use a global regular expression: coinTypePart.replace(/'/g, ''). This keeps the function and file behavior identical for inputs with zero or one apostrophe, while correctly normalizing any inputs with multiple apostrophes.
Only a single line in packages/connect-examples/expo-example/src/testTools/securityCheckTest/blindSignature/index.tsx needs to be changed (line 57 in the provided snippet). No new methods, imports, or type definitions are required.
| @@ -54,7 +54,7 @@ | ||
|
|
||
| const pathParts = item.path?.split('/') || []; | ||
| const coinTypePart = pathParts[2] || ''; | ||
| const coinType = coinTypePart.replace("'", ''); | ||
| const coinType = coinTypePart.replace(/'/g, ''); | ||
| const expected = getDeviceExpected( | ||
| selectedDevice?.features || {}, | ||
| item.method, |
Summary
DevicePlugininterface withignoreMethodParamsandexpectedOverridesto support param-level filtering and device-specific expected resultsgenerateRequestParams,processRequest,processResponse)ResultViewDevice Plugin Updates
Classic
Classic 1S / Classic Pure
Known Issues (TODO)
aptosSignTransactionsolSignTransactionTest plan
🤖 Generated with Claude Code