diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000..51f6558aac --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,94 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL Advanced" + +on: + push: + branches: [ "release/5.1" ] + pull_request: + branches: [ "release/5.1" ] + schedule: + - cron: '33 23 * * 6' + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: csharp + build-mode: manual + # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET Core SDK + uses: actions/setup-dotnet@v5.0.1 + with: + global-json-file: global.json + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + - name: Run manual build steps + if: matrix.build-mode == 'manual' + shell: bash + run: | + mkdir packages + dotnet build src/Microsoft.Data.SqlClient.sln + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v4 + with: + category: "/language:${{matrix.language}}" diff --git a/global.json b/global.json new file mode 100644 index 0000000000..68bd8fe2d3 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "8.0.416" + } +} diff --git a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj index d68e3ee661..319716a669 100644 --- a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj +++ b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj @@ -32,7 +32,6 @@ - diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj index 7ef9ff4f78..8a8390db69 100644 --- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj @@ -42,18 +42,12 @@ - - - - - - - - diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DBConnectionString.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DbConnectionString.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DBConnectionString.cs rename to src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DbConnectionString.cs diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs index 04acfcb612..af2099e6d0 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -2998,7 +2998,7 @@ internal byte[] GetBytes(object o, out Format format, out int maxSize) // You must not change the guid for this coclass // or the iid for the ISQLDebug interface // - /// + /// [ ComVisible(true), ClassInterface(ClassInterfaceType.None), diff --git a/src/Microsoft.Data.SqlClient/netfx/tools/targets/GenerateResourceStringsSource.targets b/src/Microsoft.Data.SqlClient/netfx/tools/targets/GenerateResourceStringsSource.targets index eb2be2ae9d..1c8bf89865 100644 --- a/src/Microsoft.Data.SqlClient/netfx/tools/targets/GenerateResourceStringsSource.targets +++ b/src/Microsoft.Data.SqlClient/netfx/tools/targets/GenerateResourceStringsSource.targets @@ -1,10 +1,15 @@ - - - - - - + + pwsh + powershell.exe + + + + + + + + diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetaDataFactory.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetaDataFactory.cs diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj index 2336768391..68cf3cedfd 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj @@ -85,11 +85,8 @@ - - - @@ -114,7 +111,6 @@ - diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj index 95a4dd8723..ea59717ef3 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj @@ -323,13 +323,11 @@ - - @@ -338,7 +336,6 @@ - diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Address/Address.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Address/Address.csproj index e525bdeda3..4bd155fafe 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Address/Address.csproj +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Address/Address.csproj @@ -12,7 +12,6 @@ - diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Circle/Circle.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Circle/Circle.csproj index 750ae10973..f18edeec5e 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Circle/Circle.csproj +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Circle/Circle.csproj @@ -12,7 +12,6 @@ - diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Shapes/Shapes.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Shapes/Shapes.csproj index d2b894a83d..4e321166ff 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Shapes/Shapes.csproj +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Shapes/Shapes.csproj @@ -12,7 +12,6 @@ - diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.csproj index 4b520c0286..4c9c790bbb 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.csproj +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.csproj @@ -12,7 +12,6 @@ - diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.ExtUtilities/Microsoft.Data.SqlClient.ExtUtilities.csproj b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.ExtUtilities/Microsoft.Data.SqlClient.ExtUtilities.csproj index 7219ca2c8b..5306ece191 100644 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.ExtUtilities/Microsoft.Data.SqlClient.ExtUtilities.csproj +++ b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.ExtUtilities/Microsoft.Data.SqlClient.ExtUtilities.csproj @@ -7,7 +7,13 @@ - + + diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj index 1ca32f6754..7929f589a1 100644 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj +++ b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj @@ -14,8 +14,6 @@ PreserveNewest - - diff --git a/src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDSServerEndPoint.cs b/src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDSServerEndPoint.cs index e81139c63a..48e2a46d89 100644 --- a/src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDSServerEndPoint.cs +++ b/src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDSServerEndPoint.cs @@ -100,7 +100,7 @@ public void Start() // Update ServerEndpoint with the actual address/port, e.g. if port=0 was given ServerEndPoint = (IPEndPoint)ListenerSocket.LocalEndpoint; - Log($"{GetType().Name} {EndpointName} Is Server Socket Bound: {ListenerSocket.Server.IsBound} Testing connectivity to the endpoint created for the server."); + Log($"Is Server Socket Bound: {ListenerSocket.Server.IsBound} Testing connectivity to the endpoint created for the server."); using (TcpClient client = new TcpClient()) { try @@ -109,18 +109,18 @@ public void Start() } catch (Exception e) { - Log($"{GetType().Name} {EndpointName} Error occurred while testing server endpoint {e.Message}"); + Log($"Error occurred while testing server endpoint {e.Message}"); throw; } } - Log($"{GetType().Name} {EndpointName} Endpoint test successful."); + Log("Endpoint test successful."); // Initialize the listener ListenerThread = new Thread(new ThreadStart(_RequestListener)) { IsBackground = true }; ListenerThread.Name = "TDS Server EndPoint Listener"; ListenerThread.Start(); - Log($"{GetType().Name} {EndpointName} Listener Thread Started "); + Log("Listener Thread Started "); } /// @@ -203,6 +203,8 @@ private void _RequestListener() // Register a new connection Connections.Add(connection); } + + Log($"New connection accepted: {connection.RemoteEndPoint} Total connections: {Connections.Count} "); } catch (Exception ex) { @@ -232,23 +234,34 @@ private void _RequestListener() /// private void _OnConnectionClosed(object sender, EventArgs e) { + T clientConnection = sender as T; + bool removed = false; + // Synchronize access to connection collection lock (Connections) { // Remove the existing connection from the list - Connections.Remove(sender as T); - Log($"{GetType().Name} {EndpointName} Connection Closed"); + removed = Connections.Remove(clientConnection); + } + + if (removed) + { + Log($"Connection closed and removed: {clientConnection.RemoteEndPoint}"); + } + else + { + Log($"Connection closed but NOT removed (not found): {clientConnection.RemoteEndPoint}"); } } /// /// Write a string to the log /// - internal void Log(string text, params object[] args) + internal void Log(string text) { if (EventLog != null) { - EventLog.WriteLine(text, args); + EventLog.WriteLine($"{GetType().Name} {EndpointName} {ServerEndPoint} {text}"); } } } diff --git a/src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDSServerEndPointConnection.cs b/src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDSServerEndPointConnection.cs index 6327189691..cd8a1c49d6 100644 --- a/src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDSServerEndPointConnection.cs +++ b/src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDSServerEndPointConnection.cs @@ -74,7 +74,13 @@ public abstract class ServerEndPointConnection /// /// Connection itself /// - protected TcpClient Connection { get; set; } + public TcpClient Connection { get; set; } + + /// + /// We copy the remote endpoint so it can be used _after_ the connection + /// is closed. + /// + public System.Net.EndPoint RemoteEndPoint { get; } /// /// The flag indicates whether server is being stopped @@ -89,8 +95,9 @@ public ServerEndPointConnection(ITDSServer server, TcpClient connection) // Save server Server = server; - // Save TCP connection + // Save TCP connection and its remote endpoint. Connection = connection; + RemoteEndPoint = connection.Client.RemoteEndPoint; // Configure timeouts Connection.ReceiveTimeout = 1000; diff --git a/tools/props/Versions.props b/tools/props/Versions.props index b8a6172ba7..b73c99bfa7 100644 --- a/tools/props/Versions.props +++ b/tools/props/Versions.props @@ -1,5 +1,7 @@ + + 5.1.8 0 @@ -12,6 +14,8 @@ $(MdsVersionDefault)-dev $(NugetPackageVersion) + + @@ -21,68 +25,68 @@ 1.0.0-dev $(SqlServerPackageVersion) - + + - 5.1.2 + $(NugetPackageVersion) + $(NugetPackageVersion) - + + + 1.41.0 1.12.1 4.76.0 - 6.35.0 6.35.0 - 4.5.1 - 6.0.1 - 6.0.11 + 6.35.0 + 4.6.1 + 6.35.0 - + + + + 5.1.2 + + + - 5.0.0 5.1.2 - 6.0.1 1.0.0 - 6.0.1 - 6.0.1 + 6.0.1 6.0.0 - 5.0.0 6.0.0 5.0.0 6.0.0 - + + + 5.0.0 4.3.0 + 5.0.0 + - 1.41.0 4.6.0 6.0.3 4.3.2 - + + - 3.1.6 17.12.0 - 13.0.1 - 4.3.0 - 6.0.1 - 6.0.1 - 5.0.0 + 13.0.4 + 6.0.2 2.9.3 2.8.2 8.0.0-beta.25555.2 11.0.0-beta.25476.3 - 2.0.8 172.52.0 10.50.1600.1 - 0.13.2 + 0.14.0 6.0.0 - 6.0.1 + 8.0.1 1.0.3 - - $(NugetPackageVersion) - $(NugetPackageVersion) - diff --git a/tools/specs/Microsoft.Data.SqlClient.nuspec b/tools/specs/Microsoft.Data.SqlClient.nuspec index 274ae7b225..ca48e4d915 100644 --- a/tools/specs/Microsoft.Data.SqlClient.nuspec +++ b/tools/specs/Microsoft.Data.SqlClient.nuspec @@ -38,9 +38,8 @@ When using NuGet 3.x this package requires at least version 3.4. - - - + +