diff --git a/.github/workflows/Steeltoe.All.yml b/.github/workflows/Steeltoe.All.yml index 6fcf039cbb..3c2d8cb055 100644 --- a/.github/workflows/Steeltoe.All.yml +++ b/.github/workflows/Steeltoe.All.yml @@ -6,7 +6,6 @@ on: branches: - main - '[0-9]+.x' - - 'release/*' pull_request: concurrency: diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index b3d455524a..ae6913fc2a 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -6,7 +6,6 @@ on: branches: - main - '[0-9]+.x' - - 'release/*' pull_request: release: types: diff --git a/.github/workflows/scan-vulnerable-dependencies.yml b/.github/workflows/scan-vulnerable-dependencies.yml new file mode 100644 index 0000000000..0aa7454f2a --- /dev/null +++ b/.github/workflows/scan-vulnerable-dependencies.yml @@ -0,0 +1,41 @@ +name: Scan vulnerable dependencies + +on: + workflow_dispatch: + push: + branches: + - main + - '[0-9]+.x' + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_NOLOGO: true + SOLUTION_FILE: 'src/Steeltoe.All.sln' + +jobs: + scan: + name: Scan + timeout-minutes: 15 + runs-on: ubuntu-latest + + steps: + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 8.0.* + 9.0.* + + - name: Git checkout + uses: actions/checkout@v4 + + - name: Report vulnerable dependencies + run: dotnet restore ${{ env.SOLUTION_FILE }} --verbosity minimal /p:NuGetAudit=true /p:NuGetAuditMode=all /p:NuGetAuditLevel=low /p:TreatWarningsAsErrors=True diff --git a/.github/workflows/sonarcube.yml b/.github/workflows/sonarcube.yml index 16fd24aae3..7b0f100ae4 100644 --- a/.github/workflows/sonarcube.yml +++ b/.github/workflows/sonarcube.yml @@ -6,7 +6,6 @@ on: branches: - main - '[0-9]+.x' - - 'release/*' pull_request: types: [opened, synchronize, reopened] diff --git a/.github/workflows/verify-code-style.yml b/.github/workflows/verify-code-style.yml index d156a08ebf..97b0534be7 100644 --- a/.github/workflows/verify-code-style.yml +++ b/.github/workflows/verify-code-style.yml @@ -6,7 +6,6 @@ on: branches: - main - '[0-9]+.x' - - 'release/*' pull_request: concurrency: diff --git a/src/Discovery/src/Consul/ConsulDiscoveryClient.cs b/src/Discovery/src/Consul/ConsulDiscoveryClient.cs index f62bff78aa..22d3df0ef3 100644 --- a/src/Discovery/src/Consul/ConsulDiscoveryClient.cs +++ b/src/Discovery/src/Consul/ConsulDiscoveryClient.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using Consul; +using Consul.Filtering; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; @@ -130,7 +131,7 @@ public async Task> GetAllInstancesAsync(QueryOptions que if (options.Enabled) { - ISet serviceIds = await GetServiceIdsAsync(queryOptions, cancellationToken); + ISet serviceIds = await GetServiceIdsAsync(null, null, queryOptions, cancellationToken); foreach (string serviceId in serviceIds) { @@ -144,14 +145,20 @@ public async Task> GetAllInstancesAsync(QueryOptions que /// public Task> GetServiceIdsAsync(CancellationToken cancellationToken) { - return GetServiceIdsAsync(QueryOptions.Default, cancellationToken); + return GetServiceIdsAsync(null, null, QueryOptions.Default, cancellationToken); } /// /// Gets all registered service IDs from the Consul catalog. /// + /// + /// Specifies the datacenter to query. + /// + /// + /// Specifies the expression used to filter the queries results prior to returning the data. + /// /// - /// Any Consul query options to use. + /// Options to parameterize the Consul query. /// /// /// The token to monitor for cancellation requests. @@ -159,7 +166,7 @@ public Task> GetServiceIdsAsync(CancellationToken cancellationToken /// /// The list of service IDs. /// - public async Task> GetServiceIdsAsync(QueryOptions queryOptions, CancellationToken cancellationToken) + public async Task> GetServiceIdsAsync(string? dataCenter, Filter? filter, QueryOptions queryOptions, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(queryOptions); @@ -170,7 +177,7 @@ public async Task> GetServiceIdsAsync(QueryOptions queryOptions, Ca return new HashSet(); } - QueryResult> result = await _client.Catalog.Services(queryOptions, cancellationToken); + QueryResult> result = await _client.Catalog.Services(dataCenter, filter, queryOptions, cancellationToken); return result.Response.Keys.ToHashSet(); } diff --git a/src/Discovery/src/Consul/ConsulHealthContributor.cs b/src/Discovery/src/Consul/ConsulHealthContributor.cs index b8724456d4..6e9bacbabc 100644 --- a/src/Discovery/src/Consul/ConsulHealthContributor.cs +++ b/src/Discovery/src/Consul/ConsulHealthContributor.cs @@ -67,7 +67,7 @@ internal Task GetLeaderStatusAsync(CancellationToken cancellationToken) internal async Task> GetCatalogServicesAsync(CancellationToken cancellationToken) { - QueryResult> result = await _client.Catalog.Services(QueryOptions.Default, cancellationToken); + QueryResult> result = await _client.Catalog.Services(cancellationToken); return result.Response; } } diff --git a/src/Discovery/src/Consul/PublicAPI.Unshipped.txt b/src/Discovery/src/Consul/PublicAPI.Unshipped.txt index 1d3eedb1c4..9c94915e9a 100644 --- a/src/Discovery/src/Consul/PublicAPI.Unshipped.txt +++ b/src/Discovery/src/Consul/PublicAPI.Unshipped.txt @@ -104,7 +104,7 @@ Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetAllInstancesAsync(Consul.Quer Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetInstancesAsync(string! serviceId, Consul.QueryOptions! queryOptions, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!>! Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetInstancesAsync(string! serviceId, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!>! Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetLocalServiceInstance() -> Steeltoe.Common.Discovery.IServiceInstance? -Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetServiceIdsAsync(Consul.QueryOptions! queryOptions, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!>! +Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetServiceIdsAsync(string? dataCenter, Consul.Filtering.Filter? filter, Consul.QueryOptions! queryOptions, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!>! Steeltoe.Discovery.Consul.ConsulDiscoveryClient.GetServiceIdsAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!>! Steeltoe.Discovery.Consul.ConsulDiscoveryClient.ShutdownAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! Steeltoe.Discovery.Consul.ConsulServiceCollectionExtensions diff --git a/src/Discovery/test/Consul.Test/Discovery/ConsulDiscoveryClientTest.cs b/src/Discovery/test/Consul.Test/Discovery/ConsulDiscoveryClientTest.cs index 8069bc054d..88caae557d 100644 --- a/src/Discovery/test/Consul.Test/Discovery/ConsulDiscoveryClientTest.cs +++ b/src/Discovery/test/Consul.Test/Discovery/ConsulDiscoveryClientTest.cs @@ -124,14 +124,14 @@ public async Task GetServicesAsync_ReturnsExpected() }; var catalogMoq = new Mock(); - catalogMoq.Setup(endpoint => endpoint.Services(QueryOptions.Default, It.IsAny())).Returns(Task.FromResult(queryResult)); + catalogMoq.Setup(endpoint => endpoint.Services(null, null, QueryOptions.Default, It.IsAny())).Returns(Task.FromResult(queryResult)); var clientMoq = new Mock(); clientMoq.Setup(client => client.Catalog).Returns(catalogMoq.Object); TestOptionsMonitor optionsMonitor = TestOptionsMonitor.Create(options); var discoveryClient = new ConsulDiscoveryClient(clientMoq.Object, optionsMonitor, NullLoggerFactory.Instance); - ISet serviceIds = await discoveryClient.GetServiceIdsAsync(QueryOptions.Default, TestContext.Current.CancellationToken); + ISet serviceIds = await discoveryClient.GetServiceIdsAsync(TestContext.Current.CancellationToken); serviceIds.Should().HaveCount(2); serviceIds.Should().Contain("foo"); @@ -196,7 +196,7 @@ public async Task GetAllInstances_ReturnsExpected() }; var catalogMoq = new Mock(); - catalogMoq.Setup(endpoint => endpoint.Services(QueryOptions.Default, It.IsAny())).Returns(Task.FromResult(queryResult1)); + catalogMoq.Setup(endpoint => endpoint.Services(null, null, QueryOptions.Default, It.IsAny())).Returns(Task.FromResult(queryResult1)); var clientMoq = new Mock(); clientMoq.Setup(client => client.Catalog).Returns(catalogMoq.Object); diff --git a/src/Discovery/test/Consul.Test/Discovery/ConsulHealthContributorTest.cs b/src/Discovery/test/Consul.Test/Discovery/ConsulHealthContributorTest.cs index d1d8fce6dc..686dadb5c4 100644 --- a/src/Discovery/test/Consul.Test/Discovery/ConsulHealthContributorTest.cs +++ b/src/Discovery/test/Consul.Test/Discovery/ConsulHealthContributorTest.cs @@ -50,7 +50,7 @@ public async Task GetCatalogServicesAsync_ReturnsExpected() }; var catalogMoq = new Mock(); - catalogMoq.Setup(endpoint => endpoint.Services(QueryOptions.Default, It.IsAny())).Returns(Task.FromResult(queryResult)); + catalogMoq.Setup(endpoint => endpoint.Services(It.IsAny())).Returns(Task.FromResult(queryResult)); var clientMoq = new Mock(); clientMoq.Setup(client => client.Catalog).Returns(catalogMoq.Object); @@ -89,7 +89,7 @@ public async Task Health_ReturnsExpected() statusMoq.Setup(endpoint => endpoint.Leader(It.IsAny())).Returns(Task.FromResult("the-status")); var catalogMoq = new Mock(); - catalogMoq.Setup(endpoint => endpoint.Services(QueryOptions.Default, It.IsAny())).Returns(Task.FromResult(queryResult)); + catalogMoq.Setup(endpoint => endpoint.Services(It.IsAny())).Returns(Task.FromResult(queryResult)); var clientMoq = new Mock(); clientMoq.Setup(client => client.Status).Returns(statusMoq.Object);