Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -3,11 +3,14 @@ using StellaOps.Scanner.Analyzers.Native;
|
||||
using StellaOps.Scanner.Analyzers.Native.Tests.Fixtures;
|
||||
using StellaOps.Scanner.Analyzers.Native.Tests.TestUtilities;
|
||||
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Scanner.Analyzers.Native.Tests;
|
||||
|
||||
public class ElfDynamicSectionParserTests : NativeTestBase
|
||||
{
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ParsesMinimalElfWithNoDynamicSection()
|
||||
{
|
||||
// Minimal ELF64 with no dependencies (static binary scenario)
|
||||
@@ -21,7 +24,8 @@ public class ElfDynamicSectionParserTests : NativeTestBase
|
||||
info.Runpath.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ParsesElfWithDtNeeded()
|
||||
{
|
||||
// Build ELF with DT_NEEDED entries using the builder
|
||||
@@ -38,7 +42,8 @@ public class ElfDynamicSectionParserTests : NativeTestBase
|
||||
info.Dependencies[2].Soname.Should().Be("libpthread.so.0");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ParsesElfWithRpathAndRunpath()
|
||||
{
|
||||
// Build ELF with rpath and runpath using the builder
|
||||
@@ -53,7 +58,8 @@ public class ElfDynamicSectionParserTests : NativeTestBase
|
||||
info.Runpath.Should().BeEquivalentTo(["$ORIGIN/../lib"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ParsesElfWithInterpreterAndBuildId()
|
||||
{
|
||||
// Build ELF with interpreter and build ID using the builder
|
||||
@@ -67,7 +73,8 @@ public class ElfDynamicSectionParserTests : NativeTestBase
|
||||
info.BinaryId.Should().Be("deadbeef0102030405060708090a0b0c");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void DeduplicatesDtNeededEntries()
|
||||
{
|
||||
// ElfBuilder deduplicates internally, so add "duplicates" via builder
|
||||
@@ -85,7 +92,8 @@ public class ElfDynamicSectionParserTests : NativeTestBase
|
||||
info.Dependencies[0].Soname.Should().Be("libc.so.6");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ReturnsFalseForNonElfData()
|
||||
{
|
||||
var buffer = new byte[] { 0x00, 0x01, 0x02, 0x03 };
|
||||
@@ -96,7 +104,8 @@ public class ElfDynamicSectionParserTests : NativeTestBase
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ReturnsFalseForPeFile()
|
||||
{
|
||||
var buffer = new byte[256];
|
||||
@@ -109,7 +118,8 @@ public class ElfDynamicSectionParserTests : NativeTestBase
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ParsesElfWithVersionNeeds()
|
||||
{
|
||||
// Test that version needs (GLIBC_2.17, etc.) are properly extracted
|
||||
@@ -128,7 +138,8 @@ public class ElfDynamicSectionParserTests : NativeTestBase
|
||||
info.Dependencies[0].VersionNeeds.Should().Contain(v => v.Version == "GLIBC_2.28");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ParsesElfWithWeakVersionNeeds()
|
||||
{
|
||||
// Test that weak version requirements (VER_FLG_WEAK) are properly detected
|
||||
|
||||
Reference in New Issue
Block a user