Skip to content

Conversation

prabhu
Copy link
Collaborator

@prabhu prabhu commented Aug 13, 2025

Fixes #2156

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
@prabhu prabhu added lang:dotnet test Enhancements to test coverage or quality AI-assisted breaking labels Aug 13, 2025
@prabhu prabhu marked this pull request as ready for review August 13, 2025 11:33
@@ -0,0 +1,132 @@
/**
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These functions were vibe-coded using qwen3-coder. I first gave a simple test case to generate some logic. Then I repeatedly kept asking for more complex test cases and refactoring till we reached a point where we both concluded that the regexes and tests were good enough. It took around two hours of chat!

@@ -0,0 +1,413 @@
import { expect, test } from "@jest/globals";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I hope we have covered many test cases here. Please review and suggest if there is anything missing.

// Assembly name is different to package name
if (packageInfo.name && pkg.name !== packageInfo.name) {
assemblyName = pkg.name;
pkg.name = packageInfo.name;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a breaking change (> 11.0.10). There are instances where the assembly name and package names are different.

Example (Thanks, @chadwjames):

<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.Razor.3.0.0\lib\net45\System.Web.Razor.dll</HintPath>
    </Reference>

The package name here Microsoft.AspNet.Razor is matching the nuget name and the entry in packages.config. In older versions of cdxgen <= v11.0.10, csproj files were never parsed when packages.config was present, so we got an accurate URL but incorrect evidence since the .csproj was not tracked (therefore SCA tools wouldn't know what file to update!).

Why track assembly name and version?

Tracking the assembly name and version is important, since this is what will be present in GAC and in using statements in the code. So, when we invoke dosai to find all the occurrences (and one day call stack) for given packages, we can take the module name from the using statements and match it with the assembly name (or the DLL) to figure out which PURL offers what module.

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
@@ -10423,23 +10466,18 @@ export function parseCsProjData(csProjData, projFile, pkgNameVersions = {}) {
pkg.evidence = {
identity: {
field: "purl",
confidence: 0.7,
confidence: hintVersion ? 0.7 : 0.3,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Confidence is lowered when there is no hint version.

@prabhu
Copy link
Collaborator Author

prabhu commented Aug 13, 2025

Please test on master.

@prabhu prabhu merged commit cd0b068 into master Aug 13, 2025
125 of 128 checks passed
@prabhu prabhu deleted the fix/issue-2156 branch August 13, 2025 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.NET Framework - Incorrect version detection (AssemblyVersion instead of NuGet package version)
1 participant