refactor: migrate all subprocess call sites to the shared subprocess module - #1849
Open
iankhou wants to merge 8 commits into
Open
refactor: migrate all subprocess call sites to the shared subprocess module#1849iankhou wants to merge 8 commits into
iankhou wants to merge 8 commits into
Conversation
…tions # Conflicts: # yarn.lock
Contributor
Dependency ReviewThe following issues were found:
License Issuespackages/@aws-cdk/cdk-assets-lib/package.json
packages/@aws-cdk/toolkit-lib/package.json
packages/aws-cdk/package.json
OpenSSF Scorecard
Scanned Files
|
Since the revert, @aws-cdk/private-tools is a build-time-only devDependency consumed through the per-package generated shim (lib/private/tools.ts). Register the subprocess tool for the CLI project and switch all direct imports to the shim.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1849 +/- ##
=======================================
Coverage 90.90% 90.90%
=======================================
Files 80 80
Lines 12250 12177 -73
Branches 1754 1741 -13
=======================================
- Hits 11136 11070 -66
+ Misses 1077 1069 -8
- Partials 37 38 +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:
|
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.
This re-submits changes from #1758, which was merged and then reverted in #1774 because we weren't able to run Windows integ tests on it yet.
Tested in workflow: https://github.com/aws/aws-cdk-cli/actions/runs/32169009705, which ran the changes through the integ tests on both Linux and Windows using throwaway branch https://github.com/aws/aws-cdk-cli/tree/refs/heads/iankhou-windows-x-shell-interactions.
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 that pattern.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).Follow-ups include
cdk-build-tools/integ-runner/cli-integmigrations.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license