Skip to content

Dev/sraroseck/draft/update tests/unit tests/dwarf attribute value#1171

Draft
Sasinkas wants to merge 16 commits into
mainfrom
dev/sraroseck/draft/UpdateTests/UnitTests/DwarfAttributeValue
Draft

Dev/sraroseck/draft/update tests/unit tests/dwarf attribute value#1171
Sasinkas wants to merge 16 commits into
mainfrom
dev/sraroseck/draft/UpdateTests/UnitTests/DwarfAttributeValue

Conversation

@Sasinkas
Copy link
Copy Markdown
Contributor

No description provided.


public AnalyzeCommandIntegrationTests()
{
_tempDir = Path.Combine(Path.GetTempPath(), "BinSkimIntegration", Guid.NewGuid().ToString("N"));

public void Dispose()
{
try { Directory.Delete(_tempDir, recursive: true); } catch { /* best-effort cleanup */ }
{
// BinSkim analyzing its own DLL — PDB is co-located so symbol loading should succeed.
string targetBinary = BinSkimRunner.GetBinSkimDllPath();
string sarifOutput = Path.Combine(_tempDir, "output.sarif");
public async Task Analyze_SelfScan_ProducesValidSarif()
{
string targetBinary = BinSkimRunner.GetBinSkimDllPath();
string sarifOutput = Path.Combine(_tempDir, "output.sarif");
[Fact]
public async Task Analyze_NoValidTargets_ExitsWithNonZero()
{
string nonExistentTarget = Path.Combine(_tempDir, "does_not_exist.dll");
public async Task Analyze_NoValidTargets_ExitsWithNonZero()
{
string nonExistentTarget = Path.Combine(_tempDir, "does_not_exist.dll");
string sarifOutput = Path.Combine(_tempDir, "output.sarif");
{
string assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string binSkimDll = Path.GetFullPath(
Path.Combine(assemblyDir, "..", "..", "BinSkim.Driver", "release", "BinSkim.dll"));
}
catch (OperationCanceledException)
{
try { process.Kill(entireProcessTree: true); } catch { /* best-effort cleanup */ }
{
string failBinary = GetFunctionalTestDataPath(
"BA2016.MarkImageAsNXCompatible", "Fail", "ManagedFail.dll");
string sarifOutput = Path.Combine(_tempDir, "fail-output.sarif");
public async Task Analyze_RunOnlyRules_FiltersToSpecifiedRule()
{
string targetBinary = BinSkimRunner.GetBinSkimDllPath();
string sarifOutput = Path.Combine(_tempDir, "filtered.sarif");
[Fact]
public async Task ExportRules_ProducesValidSarifOutput()
{
string outputPath = Path.Combine(_tempDir, "rules.sarif");
[Fact]
public async Task ExportConfig_ProducesValidJsonOutput()
{
string outputPath = Path.Combine(_tempDir, "config.json");
Comment on lines +289 to +290
Path.Combine(assemblyDir, "..", "..", "..", "..", "src",
"Test.FunctionalTests.BinSkim.Rules", "FunctionalTestData"));
string testDataRoot = Path.GetFullPath(
Path.Combine(assemblyDir, "..", "..", "..", "..", "src",
"Test.FunctionalTests.BinSkim.Rules", "FunctionalTestData"));
string fullPath = Path.Combine(new[] { testDataRoot }.Concat(relativeParts).ToArray());
Comment on lines +309 to +310
Path.Combine(assemblyDir, "..", "..", "..", "..", "src",
"Test.UnitTests.BinaryParsers", "TestData"));
string testDataRoot = Path.GetFullPath(
Path.Combine(assemblyDir, "..", "..", "..", "..", "src",
"Test.UnitTests.BinaryParsers", "TestData"));
string fullPath = Path.Combine(new[] { testDataRoot }.Concat(relativeParts).ToArray());
{
string elfBinary = GetFunctionalTestDataPath(
"BA3006.EnableNonExecutableStack", "Pass", "gcc.helloworld.noexecstack.5.o");
string sarifOutput = Path.Combine(_tempDir, "elf-output.sarif");
{
string elfBinary = GetFunctionalTestDataPath(
"BA3001.EnablePositionIndependentExecutable", "Pass", "gcc.pie_executable");
string sarifOutput = Path.Combine(_tempDir, "elf-sarif.sarif");
{
string failBinary = GetFunctionalTestDataPath(
"BA3006.EnableNonExecutableStack", "Fail", "gcc.helloworld.execstack.5.o");
string sarifOutput = Path.Combine(_tempDir, "elf-fail.sarif");
File.Copy(source, copy1);
File.Copy(source, copy2);

string sarifOutput = Path.Combine(_tempDir, "recurse.sarif");
BinSkimRunResult result = await BinSkimRunner.RunAsync(new[]
{
"analyze",
Path.Combine(_tempDir, "*.dll"),
[Fact]
public async Task Analyze_RichReturnCode_InvalidTarget_ReturnsRuntimeConditions()
{
string nonExistentTarget = Path.Combine(_tempDir, "does_not_exist.dll");
public async Task Analyze_LocalSymbolDirectories_AcceptsOption()
{
string elfBinary = GetBinaryParsersTestDataPath("Dwarf", "hello-dwarf4-o2");
string sarifOutput = Path.Combine(_tempDir, "symdir.sarif");
public async Task Analyze_TraceTargetsScanned_ProducesTraceOutput()
{
string targetBinary = BinSkimRunner.GetBinSkimDllPath();
string sarifOutput = Path.Combine(_tempDir, "trace.sarif");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants