diff --git a/syft/pkg/cataloger/dotnet/cataloger_csproj_test.go b/syft/pkg/cataloger/dotnet/cataloger_csproj_test.go index b653f2d1f..8393374ec 100644 --- a/syft/pkg/cataloger/dotnet/cataloger_csproj_test.go +++ b/syft/pkg/cataloger/dotnet/cataloger_csproj_test.go @@ -9,111 +9,56 @@ import ( ) func TestDotnetCsprojCataloger(t *testing.T) { - fixture := "test-fixtures/steeltoe-sample/WeatherForecast.csproj" - fixtureLocationSet := file.NewLocationSet(file.NewLocation(fixture)) + fixture := "test-fixtures/weatherforecast-steeltoe" + + expectedLocation := file.NewLocation("Sample.csproj") + fixtureLocationSet := file.NewLocationSet(expectedLocation) expected := []pkg.Package{ { - Name: "Steeltoe.Discovery.Eureka", - Version: "3.2.0", + Name: "Steeltoe.Common.Hosting", + Version: "3.2.*", + FoundBy: "dotnet-csproj-cataloger", Language: pkg.Dotnet, Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Steeltoe.Discovery.Eureka@3.2.0", + PURL: "pkg:nuget/Steeltoe.Common.Hosting@3.2.%2A", Locations: fixtureLocationSet, Metadata: pkg.DotnetDepsEntry{ - Name: "Steeltoe.Discovery.Eureka", - Version: "3.2.0", - Path: "test-fixtures/steeltoe-sample", + Name: "Steeltoe.Common.Hosting", + Version: "3.2.*", + Path: ".", Sha512: "", HashPath: "", }, }, { - Name: "Steeltoe.Extensions.Configuration.CloudFoundry", - Version: "3.2.0", + Name: "Steeltoe.Management.EndpointCore", + Version: "3.2.*", + FoundBy: "dotnet-csproj-cataloger", Language: pkg.Dotnet, Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Steeltoe.Extensions.Configuration.CloudFoundry@3.2.0", + PURL: "pkg:nuget/Steeltoe.Management.EndpointCore@3.2.%2A", Locations: fixtureLocationSet, Metadata: pkg.DotnetDepsEntry{ - Name: "Steeltoe.Extensions.Configuration.CloudFoundry", - Version: "3.2.0", - Path: "test-fixtures/steeltoe-sample", - Sha512: "", - HashPath: "", - }, - }, - { - Name: "Steeltoe.Management.Endpoint", - Version: "3.2.0", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Steeltoe.Management.Endpoint@3.2.0", - Locations: fixtureLocationSet, - Metadata: pkg.DotnetDepsEntry{ - Name: "Steeltoe.Management.Endpoint", - Version: "3.2.0", - Path: "test-fixtures/steeltoe-sample", - Sha512: "", - HashPath: "", - }, - }, - { - Name: "Microsoft.AspNetCore.OpenApi", - Version: "8.0.0", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Microsoft.AspNetCore.OpenApi@8.0.0", - Locations: fixtureLocationSet, - Metadata: pkg.DotnetDepsEntry{ - Name: "Microsoft.AspNetCore.OpenApi", - Version: "8.0.0", - Path: "test-fixtures/steeltoe-sample", + Name: "Steeltoe.Management.EndpointCore", + Version: "3.2.*", + Path: ".", Sha512: "", HashPath: "", }, }, { Name: "Swashbuckle.AspNetCore", - Version: "6.5.0", + Version: "6.2.*", + FoundBy: "dotnet-csproj-cataloger", Language: pkg.Dotnet, Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Swashbuckle.AspNetCore@6.5.0", + PURL: "pkg:nuget/Swashbuckle.AspNetCore@6.2.%2A", Locations: fixtureLocationSet, Metadata: pkg.DotnetDepsEntry{ Name: "Swashbuckle.AspNetCore", - Version: "6.5.0", - Path: "test-fixtures/steeltoe-sample", - Sha512: "", - HashPath: "", - }, - }, - { - Name: "Serilog.AspNetCore", - Version: "8.0.0", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Serilog.AspNetCore@8.0.0", - Locations: fixtureLocationSet, - Metadata: pkg.DotnetDepsEntry{ - Name: "Serilog.AspNetCore", - Version: "8.0.0", - Path: "test-fixtures/steeltoe-sample", - Sha512: "", - HashPath: "", - }, - }, - { - Name: "Serilog.Sinks.Console", - Version: "5.0.0", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Serilog.Sinks.Console@5.0.0", - Locations: fixtureLocationSet, - Metadata: pkg.DotnetDepsEntry{ - Name: "Serilog.Sinks.Console", - Version: "5.0.0", - Path: "test-fixtures/steeltoe-sample", + Version: "6.2.*", + Path: ".", Sha512: "", HashPath: "", }, @@ -126,86 +71,57 @@ func TestDotnetCsprojCataloger(t *testing.T) { func TestDotnetCsprojCataloger_GlopsMatch(t *testing.T) { expectedPackages := []pkg.Package{ { - Name: "Serilog", - Version: "2.10.0", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Serilog@2.10.0", + Name: "Steeltoe.Common.Hosting", + Version: "3.2.*", + FoundBy: "dotnet-csproj-cataloger", + Language: pkg.Dotnet, + Type: pkg.DotnetPkg, + PURL: "pkg:nuget/Steeltoe.Common.Hosting@3.2.%2A", + Locations: file.NewLocationSet(file.NewLocation("Sample.csproj")), + Metadata: pkg.DotnetDepsEntry{ + Name: "Steeltoe.Common.Hosting", + Version: "3.2.*", + Path: ".", + Sha512: "", + HashPath: "", + }, }, { - Name: "Serilog.Sinks.Console", - Version: "4.0.1", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Serilog.Sinks.Console@4.0.1", + Name: "Steeltoe.Management.EndpointCore", + Version: "3.2.*", + FoundBy: "dotnet-csproj-cataloger", + Language: pkg.Dotnet, + Type: pkg.DotnetPkg, + PURL: "pkg:nuget/Steeltoe.Management.EndpointCore@3.2.%2A", + Locations: file.NewLocationSet(file.NewLocation("Sample.csproj")), + Metadata: pkg.DotnetDepsEntry{ + Name: "Steeltoe.Management.EndpointCore", + Version: "3.2.*", + Path: ".", + Sha512: "", + HashPath: "", + }, }, { - Name: "Newtonsoft.Json", - Version: "13.0.3", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Newtonsoft.Json@13.0.3", - }, - { - Name: "Humanizer", - Version: "2.14.1", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Humanizer@2.14.1", - }, - { - Name: "Microsoft.Web.LibraryManager.Build", - Version: "2.1.175", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Microsoft.Web.LibraryManager.Build@2.1.175", - }, - { - Name: "Steeltoe.Discovery.Eureka", - Version: "3.2.0", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Steeltoe.Discovery.Eureka@3.2.0", - }, - { - Name: "Steeltoe.Extensions.Configuration.CloudFoundry", - Version: "3.2.0", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Steeltoe.Extensions.Configuration.CloudFoundry@3.2.0", - }, - { - Name: "Steeltoe.Management.Endpoint", - Version: "3.2.0", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Steeltoe.Management.Endpoint@3.2.0", - }, - { - Name: "Microsoft.AspNetCore.OpenApi", - Version: "8.0.0", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Microsoft.AspNetCore.OpenApi@8.0.0", - }, - { - Name: "Swashbuckle.AspNetCore", - Version: "6.5.0", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Swashbuckle.AspNetCore@6.5.0", - }, - { - Name: "Serilog.AspNetCore", - Version: "8.0.0", - Language: pkg.Dotnet, - Type: pkg.DotnetPkg, - PURL: "pkg:nuget/Serilog.AspNetCore@8.0.0", + Name: "Swashbuckle.AspNetCore", + Version: "6.2.*", + FoundBy: "dotnet-csproj-cataloger", + Language: pkg.Dotnet, + Type: pkg.DotnetPkg, + PURL: "pkg:nuget/Swashbuckle.AspNetCore@6.2.%2A", + Locations: file.NewLocationSet(file.NewLocation("Sample.csproj")), + Metadata: pkg.DotnetDepsEntry{ + Name: "Swashbuckle.AspNetCore", + Version: "6.2.*", + Path: ".", + Sha512: "", + HashPath: "", + }, }, } pkgtest.NewCatalogTester(). - FromDirectory(t, "test-fixtures"). + FromDirectory(t, "test-fixtures/weatherforecast-steeltoe"). Expects(expectedPackages, nil). TestCataloger(t, NewDotnetCsprojCataloger()) } diff --git a/syft/pkg/cataloger/dotnet/test-fixtures/steeltoe-sample/WeatherForecast.csproj b/syft/pkg/cataloger/dotnet/test-fixtures/steeltoe-sample/WeatherForecast.csproj deleted file mode 100644 index 67d36529f..000000000 --- a/syft/pkg/cataloger/dotnet/test-fixtures/steeltoe-sample/WeatherForecast.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file