refactor: migrate all subprocess call sites to the shared subprocess module - #1758
refactor: migrate all subprocess call sites to the shared subprocess module#1758iankhou wants to merge 3 commits into
Conversation
Dependency ReviewThe following issues were found:
License Issuespackages/@aws-cdk/cdk-assets-lib/package.json
packages/@aws-cdk/toolkit-lib/package.json
OpenSSF Scorecard
Scanned Files
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1758 +/- ##
==========================================
- Coverage 89.99% 89.99% -0.01%
==========================================
Files 78 78
Lines 12026 11951 -75
Branches 1692 1679 -13
==========================================
- Hits 10823 10755 -68
+ Misses 1174 1166 -8
- Partials 29 30 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 32 out of 33 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
packages/@aws-cdk/cdk-assets-lib/lib/private/shell.ts:55
- When the subprocess exits non-zero but produces no stderr, the ProcessFailed message ends up with a trailing ":" (because it unconditionally appends
: ${e.stderr.trim()}).
throw new ProcessFailed(
e.exitCode,
e.signal,
`${e.message}: ${e.stderr.trim()}`,
);
|
Total lines changed 1086 is greater than 1000. Please consider breaking this PR down. |
New change is smaller. |
Does this mean we still can't run tests on windows? Are customers affected by this at all or is this just testing infra? |
| shellEventType: ShellEventType, | ||
| ): void { | ||
| function handleShellOutput(props: HandleShellOutputProps): void { | ||
| const { chunk, options, shellEventType } = props; |
There was a problem hiding this comment.
if we're just going to expand the options back out again, what's the point of making HandleShellOutputProps?
There was a problem hiding this comment.
Good point, will remove the property bag here
| * | ||
| * Wrapping in single quotes and escaping single quotes inside will do it for us. | ||
| */ | ||
| function posixEscape(x: string) { |
There was a problem hiding this comment.
You made note of removing the windowsEscape, is posixEscape no longer needed because of the refactor?
There was a problem hiding this comment.
It is also unneeded, since we use renderForDisplay in this change to subsume it. renderForDisplay uses similar logic, except it uses an allowlist for characters instead of a denylist (previous logic), which is safer.
Both windowsEscape and posixEscape are made obsolete from this PR, but windowsEscape was also buggy, which is why I mentioned it. The "logic" for both is still used in renderForDisplay.
It's not really related to being able to test on Windows. The original escaping bug allowed special characters like We still don't have CI in Windows in this PR, but I can add it as a follow-up. I'm not certain why we don't already have it. |
In terms of customer impact:
|
Summary
Follow-up to #1763, which adds the
@aws-cdk/private-tools/lib/subprocessmodule.This PR migrates every
child_processcall site in the shipped packages onto the shared module, so that no code path both escapes and executes:init/os.ts,init/init.tsspawn(argv, {shell: true})+ broken hand-rolled escapingrun()— no shell,inherit-stderrkeeps npm/pip progress barstelemetry/library-version.tsexec()stringrun()argvec2-detection.tsexecSyncwith2>nulrunSync(), stderr discarded via stdiocloud-assembly/exec.ts(synthapp)spawn(str, {shell: true})+ split2runUserCommandLine(), line-buffered,collect: falsecommands/docs.ts(--browser)exec()runUserCommandLine()shell.tsrun(); spawn failures rethrow the OS error so docker's ENOENT → 'please install docker' guidance is preservedenvironment.tsquoteSpaces()(space-only quoting)quoteShellPart()The deleted
windowsEscapehelpers carried an escaping bug (shellMeta.has(x)instead ofhas(c)) that made Windows escaping a silent no-op — this PR removes the pattern rather than fixing it.grep -rn runUserCommandLinenow returns exactly the two sinks where a shell is the documented contract (synthapp,--browser) — the complete trust-model surface.Drops
split2from toolkit-lib (replaced by the module's line buffering).Not in scope (follow-ups):
cdk-build-tools/integ-runner/cli-integmigration, the eslintno-restricted-importsban onchild_process, and a Windows CI leg for the module.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license