Dev/sraroseck/draft/update tests/unit tests/dwarf attribute value#1171
Draft
Sasinkas wants to merge 16 commits into
Draft
Dev/sraroseck/draft/update tests/unit tests/dwarf attribute value#1171Sasinkas wants to merge 16 commits into
Sasinkas wants to merge 16 commits into
Conversation
… data reading behavior
…d line info extraction
…arfAttributeValue
…tails; add helper methods for DWARF line number program tests
- Created Test.IntegrationTests.BinSkim.Driver project and added to solution - Implemented BinSkimRunner to launch BinSkim as an external process - Added AnalyzeCommandIntegrationTests with 5 passing tests for self-scan and command line options
|
|
||
| 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()); |
…arfAttributeValue
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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.