Update packageurl-dotnet to 2.0.0-rc.2#1730
Conversation
dc95d69 to
0bac78d
Compare
f1d09c6 to
8d70be1
Compare
packageurl-dotnet v2 enforces that golang purls have a namespace. GoComponent was passing null for namespace and the full module path as the name. Now splits on the last "/" so e.g. "github.com/gorilla/context" becomes namespace="github.com/gorilla", name="context". Also updates test data to use realistic Go module paths, fixes CocoaPod purl assertions for v2 qualifier encoding, and removes an obsolete CA1308 suppression in CppSdkComponentTests.
There was a problem hiding this comment.
Pull request overview
Updates the repository to use packageurl-dotnet v2.0.0-rc.2 and aligns Contracts + tests with the renamed PackageUrl type, ensuring typed components continue to produce valid PURLs.
Changes:
- Bump
packageurl-dotnetto2.0.0-rc.2and migrate fromPackageURL→PackageUrl. - Update multiple
TypedComponentimplementations to constructPackageUrlinstances with the new API/normalization behavior. - Adjust unit tests and documentation examples to match the new PURL object model and string formatting.
Reviewed changes
Copilot reviewed 20 out of 21 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Directory.Packages.props | Updates packageurl-dotnet dependency version to rc.2. |
| src/Microsoft.ComponentDetection.Contracts/TypedComponent/TypedComponent.cs | Switches base PackageUrl property type to PackageUrl. |
| src/Microsoft.ComponentDetection.Contracts/TypedComponent/*.cs | Updates typed components to return PackageUrl (including updated Go PURL namespace/name handling). |
| test/Microsoft.ComponentDetection.Contracts.Tests/PurlGenerationTests.cs | Updates PURL expectations (casing/encoding) for updated library behavior. |
| test/Microsoft.ComponentDetection.Contracts.Tests/TypedComponentSerializationTests.cs | Updates Go component serialization test data to include module-path names. |
| test/Microsoft.ComponentDetection.Contracts.Tests/CppSdkComponentTests.cs | Updates assertions to match new PackageUrl name behavior. |
| test/Microsoft.ComponentDetection.Detectors.Tests/SwiftComponentTests.cs | Updates Swift PURL tests to construct PackageUrl. |
| docs/creating-a-new-detector.md | Updates documentation sample to use PackageUrl. |
| docs/schema/manifest.schema.json | Formatting-only change. |
Comments suppressed due to low confidence (1)
src/Microsoft.ComponentDetection.Contracts/TypedComponent/GoComponent.cs:63
GetNamespaceAndName()callsthis.Name.LastIndexOf('/')without validatingName. SinceGoComponent()exists for deserialization, this can throw aNullReferenceExceptionifPackageUrlis accessed beforeNameis populated (or if deserialization input is malformed). Consider validating required fields in thePackageUrlgetter (e.g., viaValidateRequiredInput) so failures are deterministic and throw anArgumentNullExceptionwith the existing standardized message.
private (string Namespace, string Name) GetNamespaceAndName()
{
var lastSlash = this.Name.LastIndexOf('/');
if (lastSlash > 0)
{
return (this.Name.Substring(0, lastSlash), this.Name.Substring(lastSlash + 1));
}
src/Microsoft.ComponentDetection.Contracts/TypedComponent/GoComponent.cs
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1730 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
👋 Hi! It looks like you modified some files in the
If none of the above scenarios apply, feel free to ignore this comment 🙂 |
Bumps
packageurl-dotnetfrom 1.0.0 to 2.0.0-rc.2.What changed
PackageURLtoPackageUrlacross all TypedComponent classes (the library renamed the type).GoComponent.PackageUrlnow splits the module path into namespace + name, since v2 enforces the purl spec requirement that golang purls have a namespace. E.g.github.com/gorilla/contextbecomes namespace=github.com/gorilla, name=context."test". CocoaPod purl assertions updated for v2's qualifier URL-encoding. Removed a staleCA1308suppression in CppSdkComponentTests.Links