Skip to content

Conversation

@DmitriyLewen
Copy link
Contributor

Description

This PR implements case-insensitive storage for NuGet packages in the vulnerability database while maintaining backward compatibility. The changes include:

  • NuGet Package Normalization: Modified NormalizePkgName in pkg/vulnsrc/vulnerability/vulnerability.go:261 to convert NuGet package names to lowercase, making them case-insensitive as per NuGet specification
  • Duplicate Advisory Storage: Enhanced TransformAdvisories in pkg/vulnsrc/ghsa/ghsa.go:143 to store both lowercase and original-case versions of NuGet advisories for backward compatibility
  • Comprehensive Test Coverage: Added test case in pkg/vulnsrc/ghsa/ghsa_test.go:446 with example NuGet advisory data to verify the dual storage functionality

The implementation stores duplicate entries during a transition period - one with the normalized (lowercase) package name and another with the original case to ensure existing downstream consumers continue to work.

Reasons for Change

  1. NuGet Case-Insensitivity Compliance: NuGet package names are case-insensitive by design, but the current implementation was storing them with their original case, leading to potential inconsistencies and missed vulnerability matches
  2. Backward Compatibility Requirements: Existing downstream tools and integrations may rely on the original case format, so we need to maintain both versions during a migration period
  3. Standardization: This change aligns the vulnerability database with NuGet's official case-insensitive behavior, improving accuracy and consistency of vulnerability detection
  4. Future Migration Path: The TODO comment indicates this is a transitional approach, with plans to eventually remove the original-case entries once downstream consumers migrate to the lowercase format

DB changes

buckets:

  • before:
    изображение
  • after:
    изображение

sizes:

  • before:
     ➜  du -sh ./assets-original/trivy.db 
     715M    ./assets-original/trivy.db
  • after:
     ➜  du -sh ./assets/trivy.db
     716M    ./assets/trivy.db

- save duplicate nuget advisories with package name in lower case
- update tests
- NormalizePkgName saves nuget packages in lower case
- update TransformAdvisories logic (detect origin pkg name and save this duplicate)
@DmitriyLewen DmitriyLewen changed the title Feat/nuget/add duplicate advs in lower case feat(ghsa): use nuget advisories in lower case Sep 9, 2025
@DmitriyLewen DmitriyLewen marked this pull request as ready for review September 9, 2025 13:57
// NuGet is case-insensitive, so we store advisories in lowercase.
// However, for backward compatibility, we also keep advisories with the original package name.
// TODO: drop storing the original-case entry and keep only the lowercase key once downstream users have migrated.
if adv.Ecosystem == vulnerability.NuGet {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: We may want to use switch here.

switch adv.Ecosystem { 
  case vulnerability.Swift:
  case vulnerability.Go:
  case vulnerability.NuGet:

}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense. Updated in 5bc3cdf

@DmitriyLewen DmitriyLewen added this pull request to the merge queue Sep 12, 2025
Merged via the queue into aquasecurity:main with commit 990a652 Sep 12, 2025
2 checks passed
@DmitriyLewen DmitriyLewen deleted the feat/nuget/add-duplicate-advs-in-lower-case branch September 12, 2025 08:53
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