Skip to content

Capture additional data from conda-lock files - #1861

Merged
Ryan Brandenburg (ryanbrandenburg) merged 3 commits into
mainfrom
users/rybrande/conda_lock_enrichment
Sep 2, 2026
Merged

Capture additional data from conda-lock files#1861
Ryan Brandenburg (ryanbrandenburg) merged 3 commits into
mainfrom
users/rybrande/conda_lock_enrichment

Conversation

@ryanbrandenburg

Copy link
Copy Markdown
Contributor

On reflection there was more data that we could have been consuming or inferring within the conda-lock files. Some of that data is needed to make a conda-valid PURL, so let's make sure it gets reported.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

CondaDependencyResolver.IsPythonPackage can still throw on null package.Manager, which should be handled safely for external YAML input.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity src/​Microsoft.ComponentDetection.Detectors/​conda/​CondaDependencyResolver.csIsPythonPackage can throw a NullReferenceException if package.Manager is missing/null in the…
What changed in this PR

This PR enhances Conda lockfile processing so more Conda package metadata (build/channel/subdir/URL + hashes) is captured and reported, enabling generation of conda-valid PURLs and improving cross-platform identity handling.

Changes:

  • Populate CondaComponent with build/channel/subdir/URL plus MD5 and SHA256, and update identity logic to exclude mirror/provenance URLs while still distinguishing platform artifacts.
  • Extend Conda lock parsing to read build, infer missing build/channel/subdir from package URLs, and record SHA256 alongside MD5.
  • Expand unit tests to validate metadata extraction, cross-platform/noarch deduplication behavior, and typed-component serialization.
File Description
test/​Microsoft.ComponentDetection.Detectors.Tests/​CondaLockComponentDetectorTests.cs Adds assertions and new tests for build/channel/subdir/URL/hashes plus platform/noarch identity behavior.
test/​Microsoft.ComponentDetection.Detectors.Tests/​ArtifactComponentFactoryTests.cs Verifies CondaComponentFactory carries SHA256 into CondaComponent.
test/​Microsoft.ComponentDetection.Contracts.Tests/​TypedComponentSerializationTests.cs Adds serialization/identity tests ensuring Conda identity excludes URL and hashes.
src/​Microsoft.ComponentDetection.Detectors/​linux/​Factories/​CondaComponentFactory.cs Plumbs Syft-provided SHA256 into CondaComponent.
src/​Microsoft.ComponentDetection.Detectors/​conda/​Contracts/​CondaPackage.cs Adds YAML-mapped build field for Conda lock packages.
src/​Microsoft.ComponentDetection.Detectors/​conda/​CondaDependencyResolver.cs Extracts channel/subdir/build from URL/fields and records MD5/SHA256; adds null-safe dependency check in python detection (partial).
src/​Microsoft.ComponentDetection.Contracts/​TypedComponent/​CondaComponent.cs Adds SHA256 + download URL parsing and updates base/extended identity semantics for Conda coordinates.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 1, 2026 22:46
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

👋 Hi! It looks like you modified some files in the Detectors folder.
You may need to bump the detector versions if any of the following scenarios apply:

  • The detector detects more or fewer components than before
  • The detector generates different parent/child graph relationships than before
  • The detector generates different devDependencies values than before

If none of the above scenarios apply, feel free to ignore this comment 🙂

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

There are correctness gaps relative to the stated goal (conda-valid PURL emission is still missing) and a small build-selection bug that can record an empty build instead of falling back to filename parsing.

Review tier: Lite
Findings: None

Issues resolved since last review (1)
Severity Finding
Medium severity src/​Microsoft.ComponentDetection.Detectors/​conda/​CondaDependencyResolver.csIsPythonPackage can throw a NullReferenceException if package.Manager is missing/null in the… View resolved comment
Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

src/Microsoft.ComponentDetection.Contracts/TypedComponent/CondaComponent.cs:63

  • The PR description calls out producing a conda-valid PURL, but CondaComponent still doesn’t override PackageUrl, so packageUrl will remain null in output. Since this PR now captures build, channel, and subdir, consider emitting a pkg:conda PURL with these values as qualifiers (namespace is prohibited for conda PURLs).
    src/Microsoft.ComponentDetection.Detectors/conda/CondaDependencyResolver.cs:152
  • package.Build is used verbatim when present, which means a lock entry with build: set to an empty/whitespace value will suppress the filename-derived build and end up recording an empty build string. Treat blank build as missing so the fallback extraction still runs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

It introduces a binary-breaking public API change by modifying the existing CondaComponent constructor signature rather than preserving the previous overload.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 High severity

New issues introduced by this change (1)
Severity Finding
High severity src/​Microsoft.ComponentDetection.Contracts/​TypedComponent/​CondaComponent.cs — Changing the public CondaComponent constructor signature by adding the new sha256 parameter (even…

@ryanbrandenburg
Ryan Brandenburg (ryanbrandenburg) merged commit 9453fec into main Sep 2, 2026
16 checks passed
@ryanbrandenburg
Ryan Brandenburg (ryanbrandenburg) deleted the users/rybrande/conda_lock_enrichment branch September 2, 2026 18:24
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.

3 participants