Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing build/test errors #2758

Merged
merged 7 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
## UNRELEASED
* DEP: Remove explicit versioning for `System.Memory` and `System.Runtime.CompilerServices.Unsafe`.
* DEP: Remove spurious references to `System.Collections.Immutable`.
* DEP: Update `Microsoft.Data.SqlClient` reference from 2.1.2 to 2.1.7 in `WorkItems` and `Sarif.Multitool.Library` to avoid [CVE-2024-0056](https://github.com/advisories/GHSA-98g6-xh36-x2p7) vulnerability.
yongyan-gh marked this conversation as resolved.
Show resolved Hide resolved
yongyan-gh marked this conversation as resolved.
Show resolved Hide resolved
* DEP: Update `System.Data.SqlClient` reference from 4.8.5 to 4.8.6 in `WorkItems` to avoid [CVE-2024-0056](https://github.com/advisories/GHSA-98g6-xh36-x2p7) vulnerability.
* PRF: Change default `max-file-size-in-kb` parameter to 10 megabytes.
* PRF: Add support for efficiently peeking into non-seekable streams for binary/text categorization.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.10.2" />
<PackageReference Include="Microsoft.Azure.Kusto.Data" Version="10.0.3" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.2" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.7" />
<PackageReference Include="Microsoft.Json.Pointer" Version="2.1.0" />
<PackageReference Include="Microsoft.Json.Schema" Version="2.1.0" />
<PackageReference Include="Microsoft.Json.Schema.Validation" Version="2.1.0" />
Expand Down
4 changes: 2 additions & 2 deletions src/Sarif/Core/Stack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static Stack Create(string stackTrace)

stack.Frames = new List<StackFrame>();

var regex = new Regex(StackFrame.AT + @"([^)]+\))(" + StackFrame.IN + "([^:]+:[^:]+)" + StackFrame.LINE + " (.*))?", RegexOptions.Compiled);
var regex = new Regex(StackFrame.AT + @"([^)]+\))(" + StackFrame.IN + "([^:]+:?[^:]+)" + StackFrame.LINE + " (.*))?", RegexOptions.Compiled);

foreach (string line in stackTrace.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
{
Expand Down Expand Up @@ -130,7 +130,7 @@ public static Stack Create(string stackTrace)
{
ArtifactLocation = new ArtifactLocation
{
Uri = new Uri(fileName)
Uri = new Uri(fileName, UriKind.RelativeOrAbsolute)
},
Region = new Region
{
Expand Down
2 changes: 1 addition & 1 deletion src/Sarif/Core/StackFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public override string ToString()

if (this.Location?.PhysicalLocation?.ArtifactLocation?.Uri != null)
{
string fileName = this.Location.PhysicalLocation.ArtifactLocation.Uri.LocalPath;
string fileName = this.Location.PhysicalLocation.ArtifactLocation.Uri.OriginalString;
result += IN + fileName;

if (this.Location?.PhysicalLocation?.Region != null)
Expand Down
39 changes: 39 additions & 0 deletions src/Test.UnitTests.Sarif/Core/StackTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,44 @@ public void Stack_CreateFromAggregatedExceptionWithInnerException()
}
Assert.True(caughtException);
}

[Fact]
public void Stack_CreateFromStackTraceWithRelativeSourceFileLocation()
yongyan-gh marked this conversation as resolved.
Show resolved Hide resolved
{
string stackTraceTemplate = @" at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at System.IO.File.Create(String path, Int32 bufferSize)
at Microsoft.CodeAnalysis.Test.UnitTests.Sarif.Core.StackTests.Stack_CreateFromExceptionWithInnerException()";

int relativePathLineNumber = 60;
string relativeFilePath = "/_/src/Test.UnitTests.Sarif/Core/StackTests.cs";
var sarifStackWithRelativeFileLocation = Stack.Create(stackTraceTemplate + $" in {relativeFilePath}:line {relativePathLineNumber}");

sarifStackWithRelativeFileLocation.Frames.Count.Should().Be(7);
CodeAnalysis.Sarif.StackFrame lastFrame = sarifStackWithRelativeFileLocation.Frames.Last();
lastFrame.Location.PhysicalLocation.ArtifactLocation.Uri.OriginalString.Should().Be(relativeFilePath);
lastFrame.Location.PhysicalLocation.Region.StartLine.Should().Be(relativePathLineNumber);
lastFrame.ToString().Should().EndWith($" in {relativeFilePath}:line {relativePathLineNumber}");

int absolutePathLineNumber = 33;
string absoluteFilePath = @"C:\repo\src\Test.UnitTests.Sarif\Core\StackTests.cs";
var sarifStackWithAbsoluteFileLocation = Stack.Create(stackTraceTemplate + $" in {absoluteFilePath}:line {absolutePathLineNumber}");

sarifStackWithAbsoluteFileLocation.Frames.Count.Should().Be(7);
lastFrame = sarifStackWithAbsoluteFileLocation.Frames.Last();
lastFrame.Location.PhysicalLocation.ArtifactLocation.Uri.OriginalString.Should().Be(absoluteFilePath);
lastFrame.Location.PhysicalLocation.Region.StartLine.Should().Be(absolutePathLineNumber);
lastFrame.ToString().Should().EndWith($" in {absoluteFilePath}:line {absolutePathLineNumber}");

var sarifStackWithoutFileLocation = Stack.Create(stackTraceTemplate);

sarifStackWithoutFileLocation.Frames.Count.Should().Be(7);
lastFrame = sarifStackWithoutFileLocation.Frames.Last();
lastFrame.Location.PhysicalLocation.Should().BeNull();
lastFrame.ToString().Should().EndWith("Stack_CreateFromExceptionWithInnerException()");
}
}
}
4 changes: 2 additions & 2 deletions src/WorkItems/WorkItems.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.10.2" />
<PackageReference Include="Microsoft.Azure.Kusto.Data" Version="10.0.3" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.2" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.2" />
Expand All @@ -36,7 +36,7 @@
<PackageReference Include="Microsoft.Json.Schema.Validation" Version="2.1.0" />
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.170.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="System.Text.Encodings.Web" Version="5.0.1" />

<!-- We have to ship pre-patch versions of NewtonSoft for VisualStudio SDK.
Expand Down