Repository navigation
feat: add opt-in isolated environment path detection - #1123
EltonChang1 wants to merge 1 commit into
Conversation
Drop PYTHONPATH, PYTHONHOME, and VIRTUAL_ENV when --isolated probes the target interpreter. The default still inherits them. Fixes CycloneDX#1045 Signed-off-by: Elton Chang <80650461+Notle-eltoN@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | ✅ 6 (≤ 20 complexity) |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Documentation build overview
|
|
Thanks for the approval, @jkowalleck! I went through #1123 and left a review there. In short, I proposed that we keep CI: I pushed a commit that fixes the lint failure (the new test name tripped flake8 N802). The macOS py3.11–3.14 failures look unrelated: pipenv's testbed init picks up Homebrew's Python 3.15 and crashes in |
|
@EltonChang1 following up on my note above, here's the actual review of #1123:
Since @jkowalleck already approved #1106, my proposal is to land #1106 and then add your no-target handling as a small follow-up (or as a commit on #1106, with you as co-author, whichever you like). How does that sound? |
Description
Add an opt-in
--isolatedflag tocyclonedx-py environment. When it is set, the interpreter path probe does not inheritPYTHONPATH,PYTHONHOME, orVIRTUAL_ENV, including mixed-case names on Windows. A parent process can no longer inject packages into an SBOM for a target environment. The flag is off by default, so workflows that intentionally pass those variables keep the current behavior.The probe builds a fresh environment mapping and drops those names case-insensitively, because
os.environ.copy()is case-sensitive even where Windows environment lookup is not. With no interpreter argument,--isolatedprobes the current executable under that same cleaned environment instead of reusing the already-importedsys.path.Resolves or fixes issue: #1045
AI Tool Disclosure
--isolatedflag from issue 1045. DropPYTHONPATH,PYTHONHOME, andVIRTUAL_ENVonly when the flag is set, keep the default inheritance behavior, and add regression tests plus the environment help text.Affirmation