diff --git a/syft/pkg/cataloger/dotnet/parse_csproj.go b/syft/pkg/cataloger/dotnet/parse_csproj.go
index 1e277c017..fdc83592b 100644
--- a/syft/pkg/cataloger/dotnet/parse_csproj.go
+++ b/syft/pkg/cataloger/dotnet/parse_csproj.go
@@ -98,15 +98,19 @@ func shouldSkipPackageReference(ref csprojPackageReference) bool {
// Skip packages that are commonly build-time only
lowerName := strings.ToLower(ref.Include)
- buildTimePackages := []string{
- "microsoft.net.test.sdk",
- "stylecop.analyzers",
- "microsoft.codeanalysis",
- "coverlet.collector",
- "xunit.runner.visualstudio",
+ buildTimePackages := map[string]bool{
+ "microsoft.net.test.sdk": true,
+ "stylecop.analyzers": true,
+ "microsoft.codeanalysis": true,
+ "coverlet.collector": true,
+ "xunit.runner.visualstudio": true,
+ "nunit": true,
+ "nunit3testadapter": true,
+ "mstest.testadapter": true,
+ "mstest.testframework": true,
}
- for _, buildPkg := range buildTimePackages {
+ for buildPkg := range buildTimePackages {
if strings.Contains(lowerName, buildPkg) {
return true
}
diff --git a/syft/pkg/cataloger/dotnet/parse_csproj_test.go b/syft/pkg/cataloger/dotnet/parse_csproj_test.go
index 52095882f..1b65fb166 100644
--- a/syft/pkg/cataloger/dotnet/parse_csproj_test.go
+++ b/syft/pkg/cataloger/dotnet/parse_csproj_test.go
@@ -86,6 +86,33 @@ func TestParseDotnetCsproj(t *testing.T) {
},
},
},
+ {
+ name: "complex IncludeAssets and PrivateAssets handling",
+ input: `
+
+
+
+
+
+
+`,
+ expected: []pkg.Package{
+ {
+ Name: "Newtonsoft.Json",
+ Version: "13.0.3",
+ Language: pkg.Dotnet,
+ Type: pkg.DotnetPkg,
+ PURL: "pkg:nuget/Newtonsoft.Json@13.0.3",
+ },
+ {
+ Name: "Microsoft.ChakraCore",
+ Version: "1.11.24",
+ Language: pkg.Dotnet,
+ Type: pkg.DotnetPkg,
+ PURL: "pkg:nuget/Microsoft.ChakraCore@1.11.24",
+ },
+ },
+ },
{
name: "skip build-time packages",
input: `
@@ -291,6 +318,40 @@ func TestShouldSkipPackageReference(t *testing.T) {
},
expected: true,
},
+ {
+ name: "includeAssets runtime only",
+ ref: csprojPackageReference{
+ Include: "Some.Package",
+ Version: "1.0.0",
+ IncludeAssets: "runtime",
+ },
+ expected: false,
+ },
+ {
+ name: "mixed condition with release",
+ ref: csprojPackageReference{
+ Include: "Some.Package",
+ Version: "1.0.0",
+ Condition: "'$(Configuration)' == 'Debug' OR '$(Configuration)' == 'Release'",
+ },
+ expected: false,
+ },
+ {
+ name: "nunit test package",
+ ref: csprojPackageReference{
+ Include: "NUnit",
+ Version: "3.13.3",
+ },
+ expected: true,
+ },
+ {
+ name: "mstest framework",
+ ref: csprojPackageReference{
+ Include: "MSTest.TestFramework",
+ Version: "3.1.1",
+ },
+ expected: true,
+ },
}
for _, test := range tests {