-
-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nuget: parse .csproj and packages.config files #3607
base: develop
Are you sure you want to change the base?
Conversation
Add support for 2 manifest files: - packages.config: XML file holding the list of package dependencies; - *.csproj: describe a project with dependencies (NuGet package references); The manifest files do not contain a lot of info, but enough to build a package-url. fixes aboutcode-org#2392 Signed-off-by: Adrien Schildknecht <adrs@fb.com>
Complex csproj files have multiple ItemGroups, make sure we check all of them. Signed-off-by: Adrien Schildknecht <adrs@fb.com>
@schischi Thanks you ++ It is much more involved and bigger than a plain parser as it uses the native NuGet and .NET libraries for better or worse. The inspector also has an extensive test suite which may come handy for the staic analysis here. |
Is there a plan to merge this into the mainline? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schischi thanks a lot! And sorry about the super late reply. 😅
Parsing of these manifests are actually supported at https://github.com/aboutcode-org/nuget-inspector (along with dependency resolution and getting package data for those), but it probably makes sense to have something minimal here too as nuget inspector would be harder to integrate in SCTK context. This is why we were not sure about merging this PR here as some efforts were ongoing and we want to avoid duplicate functionality as much as possible. But IMHO it makes sense to add this here otherwise.
Some updates are required before we merge this:
- we want to create a single package from a
.csproj
file (we get the package name from the filename:*.csproj
) and populate dependencies too if they are present - we want to create similarly a single package with no purl fields and only dependencies from
packages.config
files - If we have a
.csproj
file and apackages.config
file in the same directory we want to perform package assembly to merge the package data from these files (so we will get the name from the former and dependencies from the later for example) - If the dependencies are pinned we want to also add a skinny package_data object at the
resolved_package
attribute inside each dependency
References:
- We have lots of examples at https://github.com/aboutcode-org/nuget-inspector/blob/main/tests/data/ both individual files and pairs of these two manifests.
- See also Add handler for packages.lock.json in nuget #3825 which we added for SCIO: Detect frozen .NuGet dependencies locked with deplock scancode.io#1263, these are fully resolved dependencies, and we basically want to have the same structure here.
@eeisegn thanks for the ping!
Add support for 2 manifest files:
The manifest files do not contain a lot of info, but enough to build a package-url.
fixes #2392