Repository navigation
fix: mask typed text in child-process errors - #70
Draft
cryptotavares wants to merge 2 commits into
Draft
cryptotavares wants to merge 2 commits into
cryptotavares wants to merge 2 commits into
Conversation
Mark the text sent by the iOS and Android typeText and by the Android clipboard instrumentation as a secret, so a failed child process cannot echo it through the command line or stderr.
This branch has not been deployed
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.
Problem
execStrictbuilds its error from the command line and stderr. iOS sendsidb ui text <text>and Android sendsadb shell input text <text>through it. When the command fails, the error contains the typed text. That error reaches the CLI JSON, the agent transcript and the daemon log.Solution
Callers mark the text as a secret with
execStrict(cmd, args, { secret }).execStrictreplaces each secret, and every form the caller passes for it, in the failure message.flowchart TD A["typeText(text) or setClipboard(text)"] --> B["execStrict with secret: raw text and argv forms"] B --> C{"child exit 0?"} C -->|yes| D["Return stdout. Typing is unchanged."] C -->|no| E["maskSecrets: replace each form in the command line and stderr"] E --> F["Throw. The text never appears in the error."] classDef new fill:#fff3cd,stroke:#d39e00 classDef stop fill:#f8d7da,stroke:#c82333 class B,E new class F stopYellow boxes are new. Red boxes stop the call.
What changes
The masked forms are the raw text, the escaped Android argv element and the base64 clipboard argument.
typeTextfailsui text hunter2 xin the errorui text •••typeTextfailsinput text hunter2%sxin the errorinput text •••textB64 <base64>in the errortextB64 •••Decisions for reviewers
secretaccepts a string or a list of stringsexecFilekeeps arguments separate, but the error joins argv into one line. Android escapes spaces and metacharacters, and the clipboard argument is base64. The caller passes each form that appears on argv.exec.tsand let each backend mark the valuesetClipboardunchangedxcrun simctl pbcopyreads the text from stdin. The text never reaches argv or the error.Review guide
Read the files in this order:
src/utils/exec.tsExecOptions.secret,maskSecrets, and the failure message inexecStrictsrc/backends/idb-backend.ts#execStrictforwards the secret; iOStypeTextpasses the raw textsrc/backends/adb-backend.ts#adbforwards the secret; AndroidtypeTextpasses raw and escaped text;setClipboardpasses raw and base64src/backends/android-instrumentation/clipboard.tsencodeClipboardTextis the only base64 encoder*.test.tstypeTexttests use the realexecStrictwith a fakeexecFileTesting
yarn build,yarn lintandyarn testpass.yarn test: 38 files, 996 passed, 6 skipped, no type errors. Coverage is above the floors.typeText('hunter2 x')through the realexecStrictand a fakeexecFilewhose stderr echoes the text. They assert that nohunter2remains and that•••is present.maskSecretsmakes both masking tests fail.Known gap
device_typesuccess response still echoes the text (Typed "<text>" (...)). This PR only changes failure paths.