Skip to content

DwarfCompilationUnit.GetDebugDataDescription() throws NotImplementedException for .so files compiled on Alpine #1136

Description

@martincostello

I ran BinSkim on some binaries compiled on Alpine (opentelemetry-dotnet-instrumentation-linux-musl-arm64.zip and opentelemetry-dotnet-instrumentation-linux-musl-x64.zip from open-telemetry/opentelemetry-dotnet-instrumentation@v1.13.0), and received an exception from here:

throw new NotImplementedException();

For example:

> .\binskim.exe analyze opentelemetry-dotnet-instrumentation-linux-musl-arm64\*.so --recurse true --kind "Fail"
opentelemetry-dotnet-instrumentation-linux-musl-arm64\linux-musl-arm64\OpenTelemetry.AutoInstrumentation.Native.so : error ERR998.ExceptionInCanAnalyze : BA3001 : An exception was raised attempting to determine whether 'OpenTelemetry.AutoInstrumentation.Native.so' is a valid analysis target for check 'EnablePositionIndependentExecutable' (which has been disabled). The exception may have resulted from a problem related to parsing the analysis target and not specific to the rule, however.
NotImplementedException: The method or operation is not implemented.
   at Microsoft.CodeAnalysis.BinaryParsers.Dwarf.DwarfCompilationUnit.DataDescriptionReader.GetDebugDataDescription(UInt64 findCode) in D:\a\r1\a\_microsoft_binskim\src\BinaryParsers\ElfBinary\Dwarf\DwarfCompilationUnit.cs:line 690
   at Microsoft.CodeAnalysis.BinaryParsers.Dwarf.DwarfCompilationUnit.ReadData(IDwarfBinary dwarfBinary, DwarfMemoryReader debugData, DwarfMemoryReader debugDataDescription, DwarfMemoryReader debugStrings, DwarfMemoryReader debugLineStrings, IList`1 debugStringOffsets, NormalizeAddressDelegate addressNormalizer) in D:\a\r1\a\_microsoft_binskim\src\BinaryParsers\ElfBinary\Dwarf\DwarfCompilationUnit.cs:line 134
   at Microsoft.CodeAnalysis.BinaryParsers.Dwarf.DwarfCompilationUnit..ctor(IDwarfBinary dwarfBinary, DwarfMemoryReader debugData, DwarfMemoryReader debugDataDescription, DwarfMemoryReader debugStrings, DwarfMemoryReader debugLineStrings, IList`1 debugStringOffsets, NormalizeAddressDelegate addressNormalizer) in D:\a\r1\a\_microsoft_binskim\src\BinaryParsers\ElfBinary\Dwarf\DwarfCompilationUnit.cs:line 41
   at Microsoft.CodeAnalysis.BinaryParsers.Dwarf.DwarfSymbolProvider.ParseOneCompilationUnitByOffset(IDwarfBinary dwarfBinary, Byte[] debugData, Byte[] debugDataDescription, Byte[] debugStrings, Byte[] debugLineStrings, Byte[] debugStringOffsets, NormalizeAddressDelegate addressNormalizer, UInt32 offset) in D:\a\r1\a\_microsoft_binskim\src\BinaryParsers\ElfBinary\Dwarf\DwarfSymbolProvider.cs:line 96
   at Microsoft.CodeAnalysis.BinaryParsers.Dwarf.DwarfSymbolProvider.ParseAllCompilationUnits(IDwarfBinary dwarfBinary, Byte[] debugData, Byte[] debugDataDescription, Byte[] debugStrings, Byte[] debugLineStrings, Byte[] debugStringOffsets, NormalizeAddressDelegate addressNormalizer) in D:\a\r1\a\_microsoft_binskim\src\BinaryParsers\ElfBinary\Dwarf\DwarfSymbolProvider.cs:line 42
   at Microsoft.CodeAnalysis.BinaryParsers.ElfBinary.<>c__DisplayClass0_0.<.ctor>b__3() in D:\a\r1\a\_microsoft_binskim\src\BinaryParsers\ElfBinary\ElfBinary.cs:line 60
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Microsoft.CodeAnalysis.BinaryParsers.ElfBinary.get_DebugFileType() in D:\a\r1\a\_microsoft_binskim\src\BinaryParsers\ElfBinary\ElfBinary.cs:line 212
   at Microsoft.CodeAnalysis.BinaryParsers.ElfBinary.get_IsDebugOnlyFile() in D:\a\r1\a\_microsoft_binskim\src\BinaryParsers\ElfBinary\ElfBinary.cs:line 253
   at Microsoft.CodeAnalysis.IL.Rules.ElfBinarySkimmer.CanAnalyze(BinaryAnalyzerContext context, String& reasonForNotAnalyzing) in D:\a\r1\a\_microsoft_binskim\src\BinSkim.Rules\ElfRules\ElfBinarySkimmer.cs:line 18
   at Microsoft.CodeAnalysis.Sarif.Driver.MultithreadedAnalyzeCommandBase`2.DetermineApplicabilityForTargetHelper(TContext context, IEnumerable`1 skimmers, ISet`1 disabledSkimmers)

I would expect that the tool either:

  1. Parses the file correctly
  2. Gracefully handles the unsupported format

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions