Skip to content

feat: add opt-in isolated environment path detection - #1123

Draft
EltonChang1 wants to merge 1 commit into
CycloneDX:mainfrom
EltonChang1:feat/environment-isolated
Draft

EltonChang1 wants to merge 1 commit into
CycloneDX:mainfrom
EltonChang1:feat/environment-isolated

Conversation

@EltonChang1

Copy link
Copy Markdown

Description

Add an opt-in --isolated flag to cyclonedx-py environment. When it is set, the interpreter path probe does not inherit PYTHONPATH, PYTHONHOME, or VIRTUAL_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, --isolated probes the current executable under that same cleaned environment instead of reusing the already-imported sys.path.

Resolves or fixes issue: #1045

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: Cursor coding agent
    • LLMs and versions: Grok 4.7
    • Prompts: Implement the maintainer-requested --isolated flag from issue 1045. Drop PYTHONPATH, PYTHONHOME, and VIRTUAL_ENV only when the flag is set, keep the default inheritance behavior, and add regression tests plus the environment help text.

Affirmation

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>
@EltonChang1
EltonChang1 requested a review from a team as a code owner October 17, 2026 01:11
Copilot AI balanced review requested due to automatic review settings October 17, 2026 01:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 6 complexity · 0 duplication

Metric Results
Complexity ✅ 6 (≤ 20 complexity)
Duplication 0

View in Codacy

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.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 CycloneDX Python SBOM Tool | 🛠️ Build #35203841 | 📁 Comparing ca0272f against latest (fc11987)

  🔍 Preview build  

1 file changed
± usage.html

@EltonChang1
EltonChang1 marked this pull request as draft October 17, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants