Skip to content

Commit

Permalink
fix: #830 recursive project scan where a child project has multiple t…
Browse files Browse the repository at this point in the history
…argets with different dependencies.

Signed-off-by: MTsfoni <[email protected]>
  • Loading branch information
mtsfoni committed Jan 10, 2024
1 parent 7837516 commit 7375ec2
Show file tree
Hide file tree
Showing 7 changed files with 2,487 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CycloneDX.Tests/CycloneDX.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@
<None Update="FunctionalTests\Issue826-ProjectFileDoesntExist\solution1sln.text">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue830-rsMultipleFrameworks\project1csproj.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue830-rsMultipleFrameworks\project1assets.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue830-rsMultipleFrameworks\project2assets.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue830-rsMultipleFrameworks\project2csproj.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\TestcaseFiles\DevDependencies.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.IO;
using System.IO.Abstractions;
using System.IO.Abstractions.TestingHelpers;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CycloneDX.Models;
using Xunit;

namespace CycloneDX.Tests.FunctionalTests
{
public class Issue830
{
/// <summary>
/// This case is generating a flawed sbom.
/// CycloneDX can not automatically apply the target framework of
/// project1 to project2 and thus aggregating the netFramework and
/// netCore dependencies of project2
/// </summary>

readonly string testFileFolder = "Issue830-rsMultipleFrameworks";

private MockFileSystem getMockFS()
{
return new MockFileSystem(new Dictionary<string, MockFileData>
{
{
MockUnixSupport.Path("c:/ProjectPath/Project.csproj"),
new MockFileData(
File.ReadAllText(Path.Combine("FunctionalTests", testFileFolder, "project1csproj.xml")))
},{
MockUnixSupport.Path("c:/project2/project2.csproj"),
new MockFileData(
File.ReadAllText(Path.Combine("FunctionalTests", testFileFolder, "project2csproj.xml")))
},{
MockUnixSupport.Path("c:/ProjectPath/obj/project.assets.json"),
new MockFileData(
File.ReadAllText(Path.Combine("FunctionalTests",testFileFolder, "project1assets.json")))
},{
MockUnixSupport.Path("c:/project2/obj/project.assets.json"),
new MockFileData(
File.ReadAllText(Path.Combine("FunctionalTests",testFileFolder, "project2assets.json")))
}
});
}

[Fact]
public async Task NoExceptionHappens()
{
var options = new RunOptions
{
scanProjectReferences = true
};

//Just test that there is no exception
var bom = await FunctionalTestHelper.Test(options, getMockFS());
}
}
}
Loading

0 comments on commit 7375ec2

Please sign in to comment.