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
191 stars 90 forks source link

Fix error in Linux `ERR999.UnhandledEngineException` : `System.InvalidOperationException`: This operation is not supported for a relative URI. #2664

Closed shaopeng-gh closed 1 year ago

shaopeng-gh commented 1 year ago

Test:

have added the test in BinSkim after this is merged in and sub-module update, the failing test that repro the issue (https://github.com/microsoft/binskim/pull/884) will pass see below:

image

image

image

Reason:

Below code will output false in Linux, means not absolute Uri. But I think it is wrong, I don't know if it is .NET bug or not. The url should be a absolute uri.

string path = "/home/__w/1/s/src/build/_deps/cxx-src/WORKSPACE";
Uri uri = new Uri(path, UriKind.RelativeOrAbsolute);
Console.WriteLine("uri.IsAbsoluteUri:" + uri.IsAbsoluteUri);

The place fix is made, if you look at the code above, it is always a Absolute uri before reaching the line. So we don't leave .NET to do the guessing, we just create a Absolute uri.