From 85fe86c29ced6b3e990aafb554ef89eb79933bf2 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 4 Dec 2024 16:31:34 -0800 Subject: [PATCH] Update dependencies to address external security vulnerabilities --- src/FeedGenerator/FeedGenerator.csproj | 2 +- src/Web/Models/ErrorEntity.cs | 17 +++++++++++++---- src/Web/Models/VisitEntity.cs | 15 ++++++++++++--- src/Web/Services/StorageService.cs | 17 ++++++----------- src/Web/Web.csproj | 7 ++++--- .../XsdToMarkdownTests.csproj | 8 ++++---- 6 files changed, 40 insertions(+), 26 deletions(-) diff --git a/src/FeedGenerator/FeedGenerator.csproj b/src/FeedGenerator/FeedGenerator.csproj index 64764e94..4057bee8 100644 --- a/src/FeedGenerator/FeedGenerator.csproj +++ b/src/FeedGenerator/FeedGenerator.csproj @@ -13,6 +13,6 @@ - + diff --git a/src/Web/Models/ErrorEntity.cs b/src/Web/Models/ErrorEntity.cs index f305a4ac..450bbbf0 100644 --- a/src/Web/Models/ErrorEntity.cs +++ b/src/Web/Models/ErrorEntity.cs @@ -1,11 +1,12 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.Web.Models { using System; - using Microsoft.WindowsAzure.Storage.Table; + using Azure; + using Azure.Data.Tables; - public class ErrorEntity : TableEntity + public class ErrorEntity : ITableEntity { public ErrorEntity() { @@ -17,6 +18,14 @@ public ErrorEntity(string site, string key = null) this.RowKey = key ?? DateTime.UtcNow.ToString("yyyy-MM-ddTHH-mm-ss-ffff") + "-" + Guid.NewGuid().ToString("N"); } + public string PartitionKey { get; set; } + + public string RowKey { get; set; } + + public ETag ETag { get; set; } = ETag.All; + + public DateTimeOffset? Timestamp { get; set; } + public int StatusCode { get; set; } public string IP { get; set; } @@ -31,4 +40,4 @@ public ErrorEntity(string site, string key = null) public string Text { get; set; } } -} \ No newline at end of file +} diff --git a/src/Web/Models/VisitEntity.cs b/src/Web/Models/VisitEntity.cs index e8ce2336..366fccd0 100644 --- a/src/Web/Models/VisitEntity.cs +++ b/src/Web/Models/VisitEntity.cs @@ -1,11 +1,12 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.Web.Models { using System; - using Microsoft.WindowsAzure.Storage.Table; + using Azure; + using Azure.Data.Tables; - public class VisitEntity : TableEntity + public class VisitEntity : ITableEntity { public VisitEntity() { @@ -19,6 +20,14 @@ public VisitEntity(string site, string purpose, string key = null) this.Purpose = purpose; } + public string PartitionKey { get; set; } + + public string RowKey { get; set; } + + public ETag ETag { get; set; } = ETag.All; + + public DateTimeOffset? Timestamp { get; set; } + public string Method { get; set; } public string IP { get; set; } diff --git a/src/Web/Services/StorageService.cs b/src/Web/Services/StorageService.cs index 283c474f..7b426f7c 100644 --- a/src/Web/Services/StorageService.cs +++ b/src/Web/Services/StorageService.cs @@ -1,12 +1,11 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.Web.Services { using System; using System.Diagnostics; using System.Threading.Tasks; - using Microsoft.WindowsAzure.Storage; - using Microsoft.WindowsAzure.Storage.Table; + using Azure.Data.Tables; using WixToolset.Web.Models; public class StorageService : IStorageService @@ -18,10 +17,10 @@ public StorageService(string connectionString) throw new ArgumentNullException(nameof(connectionString)); } - this.Storage = CloudStorageAccount.Parse(connectionString); + this.Storage = new TableServiceClient(connectionString); } - private CloudStorageAccount Storage { get; } + private TableServiceClient Storage { get; } public async Task LogErrorAsync(int code, string ip, string page, string referrer, Exception exception) { @@ -47,15 +46,11 @@ public async Task WriteToTableStorage(string tableName, ITableEntity entity) { try { - var op = TableOperation.Insert(entity); - - var client = this.Storage.CreateCloudTableClient(); - - var table = client.GetTableReference(tableName); + var table = this.Storage.GetTableClient(tableName); await table.CreateIfNotExistsAsync(); - await table.ExecuteAsync(op); + await table.AddEntityAsync(entity); } catch (Exception e) { diff --git a/src/Web/Web.csproj b/src/Web/Web.csproj index ce513dc6..17db233d 100644 --- a/src/Web/Web.csproj +++ b/src/Web/Web.csproj @@ -1,14 +1,15 @@ - + net6.0 - + + - + diff --git a/src/test/XsdToMarkDownTests/XsdToMarkdownTests.csproj b/src/test/XsdToMarkDownTests/XsdToMarkdownTests.csproj index d1e2f9fa..7cbfdd15 100644 --- a/src/test/XsdToMarkDownTests/XsdToMarkdownTests.csproj +++ b/src/test/XsdToMarkDownTests/XsdToMarkdownTests.csproj @@ -14,13 +14,13 @@ - + - - - + + +