microsoft / sarif-sdk

.NET code and supporting files for working with the 'Static Analysis Results Interchange Format' (SARIF, see https://github.com/oasis-tcs/sarif-spec)
Other
192 stars 90 forks source link

Exception retrieving zip archive length #2686

Closed michaelcfanning closed 1 year ago

michaelcfanning commented 1 year ago

+many other corollary changes. This issue is .net 48 only and so we now invoke additional testing for that platform. This resulted in provoking some of the differences between net4.8 and later frameworks.

michaelcfanning commented 1 year ago

The primary driver for this PR is an exception enumerating zip archive streams for analysis. On .NET 4.8 (and earlier versions of the framework), zip archive entries raise an exception trying to obtain the stream length. Zip archive entries actually have a property for the uncompressed stream length and apparently later versions of .NET successfully obtain it. This PR first converts some test binaries to compile/test .net 4.8, and reproduces the issue. The fix is very simple, to prefer the length value directly published by the zip entry. Converting some tests to .NET 4.8 has revealed some subtle issues that also disrupt this change:

yongyan-gh commented 1 year ago
                    : null;

nit: can be entry?.Open(); this is not belong to this PR pls ignore #Resolved


Refers to: src/Sarif/ArtifactProvider.cs:93 in 6d05717. [](commit_id = 6d0571796e7e229a3acdc9fbc9222eb2d4d61f4a, deletion_comment = False)

shaopeng-gh commented 1 year ago

Build and test failed, please check, I see the new tests and some old tests are failing.