Skip to content

Commit

Permalink
Merge branch 'dev' into serilog4-update
Browse files Browse the repository at this point in the history
  • Loading branch information
ckadluba authored Aug 29, 2024
2 parents 2930b38 + 413542d commit 89a0cf4
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 61 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr-analysis-codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: 'csharp'

- name: Run build
run: ./Build.ps1 -SkipTests

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:csharp"
12 changes: 12 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 6.7.1
* Fixed issue #552 by downgrading SqlClient dependency to 5.1.6 which is LTS and fixed the vulnerabilities referenced in issue #544
* Fixed vulnerabilities by removing all System.* 4 versions as recommended by Microsoft (https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/#system-net-http-and-system-text-regularexpressions, issue #544)
* Fixed vulnerability by updating xunit to 2.9.0 (issue #544)
* Fixed vulnerability by directly referencing transitive dependency System.Formats.Asn1 (https://github.com/advisories/GHSA-447r-wph3-92pm, issue #544)
* Fixed vulnerability by directly referencing transitive dependency System.Private.Uri (https://github.com/advisories/GHSA-xhfc-gr8f-ffwc, issue #544)
* Activated NuGet Audit for high and critical vulnerabilities in direct and transitive dependencies for all projects (https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/)

# 6.7.0
* Fixed some of the vulnerabilities referenced in issue #544 by updating SqlClient dependency to 5.2.1
* Update codeql-action to v3 before deprecation

# 6.6.1
* Fixed issue #515: Cannot use .AuditTo with SpanId or TraceId (thanks to @Kolthor and @vui611)
* Fixed issue #530: Document default value of AllowNull
Expand Down
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<NuGetAuditMode>all</NuGetAuditMode>
<NuGetAuditLevel>high</NuGetAuditLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>
54 changes: 25 additions & 29 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
<PackageVersion Include="System.Collections" Version="4.3.0" />
<PackageVersion Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageVersion Include="System.Resources.ResourceManager" Version="4.3.0" />
<PackageVersion Include="System.Runtime.Extensions" Version="4.3.1" />
<PackageVersion Include="System.Runtime.InteropServices" Version="4.3.0" />
<PackageVersion Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="coverlet.collector" Version="3.2.0" />
<PackageVersion Include="FluentAssertions" Version="6.7.0" />
<PackageVersion Include="Dapper.StrongName" Version="2.0.123" />
<PackageVersion Include="Moq" Version="4.18.2" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="Serilog" Version="4.0.0" />
<PackageVersion Include="Serilog.Extensions.Hosting" Version="5.0.1" />
<PackageVersion Include="Serilog.Settings.Configuration" Version="3.4.0" />
</ItemGroup>
</Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
<PackageVersion Include="System.Formats.Asn1" Version="8.0.1" />
<PackageVersion Include="System.Private.Uri" Version="4.3.2" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.1.6" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="coverlet.collector" Version="3.2.0" />
<PackageVersion Include="FluentAssertions" Version="6.7.0" />
<PackageVersion Include="Dapper.StrongName" Version="2.0.123" />
<PackageVersion Include="Moq" Version="4.18.2" />
<PackageVersion Include="xunit" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="Serilog" Version="4.0.0" />
<PackageVersion Include="Serilog.Extensions.Hosting" Version="5.0.1" />
<PackageVersion Include="Serilog.Settings.Configuration" Version="3.4.0" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions serilog-sinks-mssqlserver.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
Build.ps1 = Build.ps1
CHANGES.md = CHANGES.md
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
.github\ISSUE_TEMPLATE.md = .github\ISSUE_TEMPLATE.md
.github\workflows\pr-analysis-codeql.yml = .github\workflows\pr-analysis-codeql.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>A Serilog sink that writes events to Microsoft SQL Server and Azure SQL</Description>
<VersionPrefix>6.6.2</VersionPrefix>
<VersionPrefix>6.7.1</VersionPrefix>
<Authors>Michiel van Oudheusden;Christian Kadluba;Serilog Contributors</Authors>
<TargetFrameworks>netstandard2.0;net462;net472;net6.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down Expand Up @@ -37,6 +37,8 @@
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
<PackageReference Include="Serilog" />
<PackageReference Include="System.Formats.Asn1" />
<PackageReference Include="System.Private.Uri" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,13 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net472' Or '$(TargetFramework)' == 'net462' ">
<Reference Include="System" />
<Reference Include="System.Transactions" />
<Reference Include="Microsoft.CSharp" />
<Compile Include="Configuration\Extensions\Hybrid\**\*.cs" />
<Compile Include="Configuration\Implementations\Microsoft.Extensions.Configuration\**\*.cs" />
<Compile Include="Configuration\Implementations\System.Configuration\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="System.Collections" />
<PackageReference Include="System.Runtime.InteropServices" />
<PackageReference Include="System.Runtime.Extensions" />
<PackageReference Include="System.IO.FileSystem.Primitives" />
<PackageReference Include="System.Resources.ResourceManager" />
<PackageReference Include="System.Text.Encoding.Extensions" />
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public async Task EmitBatchAsyncCallsSqlLogEventWriter()
});

// Act
await _sut.EmitBatchAsync(logEvents).ConfigureAwait(false);
await _sut.EmitBatchAsync(logEvents);

// Assert
_sqlBulkBatchWriter.Verify(w => w.WriteBatch(It.IsAny<IEnumerable<LogEvent>>(), _dataTable), Times.Once);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async Task WriteBatchCallsLogEventDataGeneratorGetColumnsAndValuesForEach
var logEvents = CreateLogEvents();

// Act
await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
await _sut.WriteBatch(logEvents, _dataTable);

// Assert
_logEventDataGeneratorMock.Verify(c => c.GetColumnsAndValues(logEvents[0]), Times.Once);
Expand All @@ -86,7 +86,7 @@ public async Task WriteBatchCallsSqlConnectionFactoryCreate()
var logEvents = CreateLogEvents();

// Act
await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
await _sut.WriteBatch(logEvents, _dataTable);

// Assert
_sqlConnectionFactoryMock.Verify(f => f.Create(), Times.Once);
Expand All @@ -99,7 +99,7 @@ public async Task WriteBatchCallsSqlConnectionWrapperOpenAsync()
var logEvents = CreateLogEvents();

// Act
await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
await _sut.WriteBatch(logEvents, _dataTable);

// Assert
_sqlConnectionWrapperMock.Verify(c => c.OpenAsync(), Times.Once);
Expand All @@ -113,7 +113,7 @@ public async Task WriteBatchCallsSqlConnectionWrappeCreateSqlBulkCopy()
var expectedDestinationTableName = string.Format(CultureInfo.InvariantCulture, "[{0}].[{1}]", _schemaName, _tableName);

// Act
await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
await _sut.WriteBatch(logEvents, _dataTable);

// Assert
_sqlConnectionWrapperMock.Verify(c => c.CreateSqlBulkCopy(false, expectedDestinationTableName), Times.Once);
Expand All @@ -128,7 +128,7 @@ public async Task WriteBatchCallsSqlConnectionWrappeCreateSqlBulkCopyWithDisable
var sut = new SqlBulkBatchWriter(_tableName, _schemaName, true, _sqlConnectionFactoryMock.Object, _logEventDataGeneratorMock.Object);

// Act
await sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
await sut.WriteBatch(logEvents, _dataTable);

// Assert
_sqlConnectionWrapperMock.Verify(c => c.CreateSqlBulkCopy(true, expectedDestinationTableName), Times.Once);
Expand All @@ -145,7 +145,7 @@ public async Task WriteBatchCallsSqlBulkCopyWrapperAddSqlBulkCopyColumnMappingFo
_dataTable.Columns.Add(new DataColumn(column2Name));

// Act
await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
await _sut.WriteBatch(logEvents, _dataTable);

// Assert
_sqlBulkCopyWrapper.Verify(c => c.AddSqlBulkCopyColumnMapping(column1Name, column1Name), Times.Once);
Expand All @@ -159,7 +159,7 @@ public async Task WriteBatchCallsSqlBulkCopyWrapperWriteToServerAsync()
var logEvents = CreateLogEvents();

// Act
await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
await _sut.WriteBatch(logEvents, _dataTable);

// Assert
_sqlBulkCopyWrapper.Verify(c => c.WriteToServerAsync(_dataTable), Times.Once);
Expand All @@ -172,48 +172,48 @@ public async Task WriteBatchClearsDataTable()
var logEvents = CreateLogEvents();

// Act
await _sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false);
await _sut.WriteBatch(logEvents, _dataTable);

// Assert
Assert.Empty(_dataTable.Rows);
}

[Fact]
public void WriteBatchRethrowsIfLogEventDataGeneratorMockGetColumnsAndValuesThrows()
public async Task WriteBatchRethrowsIfLogEventDataGeneratorMockGetColumnsAndValuesThrows()
{
// Arrange
_logEventDataGeneratorMock.Setup(d => d.GetColumnsAndValues(It.IsAny<LogEvent>()))
.Callback(() => throw new InvalidOperationException());
var logEvents = CreateLogEvents();

// Act + assert
Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
await Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
}

[Fact]
public void WriteBatchRethrowsIfSqlConnectionFactoryCreateThrows()
public async Task WriteBatchRethrowsIfSqlConnectionFactoryCreateThrows()
{
// Arrange
_sqlConnectionFactoryMock.Setup(f => f.Create()).Callback(() => throw new InvalidOperationException());
var logEvents = CreateLogEvents();

// Act + assert
Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
await Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
}

[Fact]
public void WriteBatchRethrowsIfSqlConnectionOpenAsyncThrows()
public async Task WriteBatchRethrowsIfSqlConnectionOpenAsyncThrows()
{
// Arrange
_sqlConnectionWrapperMock.Setup(c => c.OpenAsync()).Callback(() => throw new InvalidOperationException());
var logEvents = CreateLogEvents();

// Act + assert
Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
await Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
}

[Fact]
public void WriteBatchRethrowsIfSqlBulkCopyWriterAddSqlBulkCopyColumnMappingThrows()
public async Task WriteBatchRethrowsIfSqlBulkCopyWriterAddSqlBulkCopyColumnMappingThrows()
{
// Arrange
_sqlBulkCopyWrapper.Setup(c => c.AddSqlBulkCopyColumnMapping(It.IsAny<string>(), It.IsAny<string>()))
Expand All @@ -222,19 +222,19 @@ public void WriteBatchRethrowsIfSqlBulkCopyWriterAddSqlBulkCopyColumnMappingThro
_dataTable.Columns.Add(new DataColumn("ColumnName"));

// Act + assert
Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
await Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
}

[Fact]
public void WriteBatchRethrowsIfSqlBulkCopyWriterWriteToServerAsyncThrows()
public async Task WriteBatchRethrowsIfSqlBulkCopyWriterWriteToServerAsyncThrows()
{
// Arrange
_sqlBulkCopyWrapper.Setup(c => c.WriteToServerAsync(It.IsAny<DataTable>()))
.Callback(() => throw new InvalidOperationException());
var logEvents = CreateLogEvents();

// Act + assert
Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
await Assert.ThrowsAsync<InvalidOperationException>(() => _sut.WriteBatch(logEvents, _dataTable));
}

private static List<LogEvent> CreateLogEvents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public async Task WriteBatchCallsLogEventDataGeneratorGetColumnsAndValuesForEach
var logEvents = CreateLogEvents();

// Act
await _sut.WriteBatch(logEvents).ConfigureAwait(false);
await _sut.WriteBatch(logEvents);

// Assert
_logEventDataGeneratorMock.Verify(c => c.GetColumnsAndValues(logEvents[0]), Times.Once);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void StoresPropertyName()

// Assert
Assert.Equal(propertyName, sut.PropertyName);
Assert.Equal(1, sut.PropertyNameHierarchy.Count);
Assert.Single(sut.PropertyNameHierarchy);
Assert.Equal(propertyName, sut.PropertyNameHierarchy[0]);
Assert.False(sut.HasHierarchicalPropertyName);
}
Expand Down

0 comments on commit 89a0cf4

Please sign in to comment.