Repository navigation
Commit d688926
authored
fix(device-shell): one typed device-shell boundary for adb, exec-out, and hdc (#2611)
* fix(device-shell): one typed device-shell boundary for adb, exec-out, and hdc
`adb shell`, `adb exec-out`, and `hdc shell` join the words after the subcommand into one
string the device's `sh` re-parses — adb escapes nothing on purpose, "just like ssh(1)". The
host never runs a shell, so the injection surface is purely device-side, and it was covered by
hand at a few Android sites and not at all on HarmonyOS.
`deviceShellArgv` is now the only way a device-shell command exists. It quotes every word for
the device shell — a bare safe word renders byte-identical, so only a value that would have
been an injection vector changes — and hands back a frozen command the funnel remembers by
identity. Every boundary that dispatches a device command refuses a `shell`/`exec-out` command
it did not build, checking the value rather than a call convention, so a variable-built command
is caught as fast as a literal one and a copy is refused instead of trusted. The one rebuild a
transport is allowed is to take its own addressing out of a minted command — the `-s <serial>`
pair a provider scope adopts, the option run `parseAndroidAdbArgv` moves into a typed target —
which is `relayDeviceShellArgvWithoutOptions`, and it mints only while the removal stays inside
that command's own option run.
Addressing stays where #2632 put it: an Android device command is minted as the payload and
travels in `AndroidAdbInvocation.command`, and the root adb host checks it before lowering. A
command that must carry addressing in the same argv — an `hdc` command over the generic host
command port, an adb route spelling `-s`/`-P`/`wait-for-*` inline — mints it with the prefix.
Android's funnels are the bridge-facing way to compose a device command: `runAdbShell` /
`runAdbExecOut` over an executor and `runAndroidShell` / `runAndroidExecOut` over a device, all
exported from `agent-device/android-adb`; HarmonyOS gets `runHarmonyShell`. To keep the array a
port checked the same array a transport dispatches — a copy would no longer be the one the guard
recognizes — a host command's argv is `readonly` from `runCmd` down. Limrun's install path now
asks the runtime adapter to stop the app rather than spelling `am force-stop` itself, which also
keeps the kernel funnel out of the provider's eager closure.
Refs #2026
* fix(device-shell): render device-shell words for the transport that carries them
adb forwards words verbatim, so POSIX single-quoting is what the device shell needs. hdc wraps every element it forwards in double quotes, where a single quote is inert while $, a backquote, and " stay live: text containing $(id) was replaced by the device's own id output and a " escaped its argument, while our quotes arrived as data. A mint now names its transport and derives quoting from it, refuses a fragment on hdc (it can only arrive as literal text), and refuses an empty word on hdc, which drops it on the way to the device.1 parent 057dfb7 commit d688926
172 files changed
Lines changed: 1812 additions & 958 deletions
File tree
- packages
- capture-kit/src/recording
- host-kit/src
- internal
- kernel
- src
- platform-android/src
- __tests__
- test-utils
- deployment
- logs
- network
- readiness
- platform-apple/src
- core
- __tests__
- runner
- platform-harmonyos/src
- __tests__
- deployment
- logs
- platform-web/src
- provider-limrun/src
- src
- __tests__
- test-utils
- cli/commands
- daemon-client
- __tests__
- daemon
- sdk
- test/integration/provider-scenarios
- website/docs/docs
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
156 | 180 | | |
157 | 181 | | |
158 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
313 | 317 | | |
314 | 318 | | |
315 | 319 | | |
| |||
366 | 370 | | |
367 | 371 | | |
368 | 372 | | |
369 | | - | |
| 373 | + | |
370 | 374 | | |
371 | 375 | | |
372 | 376 | | |
373 | 377 | | |
374 | 378 | | |
375 | 379 | | |
376 | 380 | | |
377 | | - | |
| 381 | + | |
378 | 382 | | |
379 | 383 | | |
380 | 384 | | |
| |||
405 | 409 | | |
406 | 410 | | |
407 | 411 | | |
408 | | - | |
| 412 | + | |
409 | 413 | | |
410 | 414 | | |
411 | 415 | | |
| |||
481 | 485 | | |
482 | 486 | | |
483 | 487 | | |
484 | | - | |
485 | | - | |
486 | | - | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
487 | 491 | | |
488 | 492 | | |
489 | 493 | | |
| |||
538 | 542 | | |
539 | 543 | | |
540 | 544 | | |
541 | | - | |
| 545 | + | |
542 | 546 | | |
543 | 547 | | |
544 | 548 | | |
| |||
570 | 574 | | |
571 | 575 | | |
572 | 576 | | |
573 | | - | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
574 | 583 | | |
575 | 584 | | |
576 | 585 | | |
| |||
585 | 594 | | |
586 | 595 | | |
587 | 596 | | |
588 | | - | |
| 597 | + | |
589 | 598 | | |
590 | 599 | | |
591 | 600 | | |
| |||
594 | 603 | | |
595 | 604 | | |
596 | 605 | | |
597 | | - | |
| 606 | + | |
598 | 607 | | |
599 | 608 | | |
600 | 609 | | |
| |||
605 | 614 | | |
606 | 615 | | |
607 | 616 | | |
608 | | - | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
609 | 622 | | |
610 | 623 | | |
611 | 624 | | |
612 | 625 | | |
613 | 626 | | |
614 | 627 | | |
615 | | - | |
| 628 | + | |
616 | 629 | | |
617 | 630 | | |
618 | 631 | | |
| |||
646 | 659 | | |
647 | 660 | | |
648 | 661 | | |
649 | | - | |
| 662 | + | |
650 | 663 | | |
651 | 664 | | |
652 | 665 | | |
| |||
707 | 720 | | |
708 | 721 | | |
709 | 722 | | |
710 | | - | |
| 723 | + | |
711 | 724 | | |
712 | 725 | | |
713 | 726 | | |
| |||
721 | 734 | | |
722 | 735 | | |
723 | 736 | | |
724 | | - | |
| 737 | + | |
725 | 738 | | |
726 | 739 | | |
727 | 740 | | |
| |||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| |||
0 commit comments