From 2bfb84903803d2256cf9b347db3df337fe018a48 Mon Sep 17 00:00:00 2001 From: j-brooke <6962885+j-brooke@users.noreply.github.com> Date: Fri, 8 Apr 2022 11:27:21 -0400 Subject: [PATCH 1/4] Cleaned up .gitignore --- .gitignore | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 0f50c29..8cbf755 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,9 @@ -.vs/slnx.sqlite -.vs/VSWorkspaceState.json -.vs/SMSGlobal/v16/TestStore/0/002.testlog -.vs/smsglobal-dotnet/v16/.suo -.vs/smsglobal-dotnet/v16/TestStore/0/000.testlog -.vs/smsglobal-dotnet/v16/TestStore/0/testlog.manifest -SMSGlobal/bin/Debug/SMSGlobal.api.1.0.0.nupkg -SMSGlobal/obj/Debug/SMSGlobal.api.1.0.0.nuspec -SMSGlobal/obj/Release/netstandard2.0/SMSGlobal.api.AssemblyInfo.cs -SMSGlobal/obj/Release/netstandard2.0/SMSGlobal.api.AssemblyInfoInputs.cache -SMSGlobal/obj/Release/netstandard2.0/SMSGlobal.api.assets.cache -SMSGlobalTest/obj/Release/netcoreapp3.1/SMSGlobalTest.AssemblyInfo.cs -SMSGlobalTest/obj/Release/netcoreapp3.1/SMSGlobalTest.AssemblyInfoInputs.cache -SMSGlobalTest/obj/Release/netcoreapp3.1/SMSGlobalTest.assets.cache -SMSGlobalTest/obj/Release/netcoreapp3.1/SMSGlobalTest.csprojAssemblyReference.cache +# Local IDE info .vs/ -SMSGlobalTest/obj/ -SMSGlobal/obj/ -SMSGlobalTest/bin/ -SMSGlobal/bin/ \ No newline at end of file +.idea/ +*.user + +# Build artifacts +**/obj/ +**/bin/ + From dec78c9963d31ecdf2a04b2a9e639c10aaadbd0a Mon Sep 17 00:00:00 2001 From: j-brooke <6962885+j-brooke@users.noreply.github.com> Date: Fri, 8 Apr 2022 11:36:11 -0400 Subject: [PATCH 2/4] Removed unnecessary dependencies --- SMSGlobal/OTP.cs | 1 - SMSGlobal/Response/Response.cs | 5 ++--- SMSGlobal/SMSGlobal.api.csproj | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/SMSGlobal/OTP.cs b/SMSGlobal/OTP.cs index 157dd34..d2deaa9 100644 --- a/SMSGlobal/OTP.cs +++ b/SMSGlobal/OTP.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Text; using SMSGlobal.Response; -using System.Configuration; using System.Net.Http; diff --git a/SMSGlobal/Response/Response.cs b/SMSGlobal/Response/Response.cs index 45b121e..3f22b10 100644 --- a/SMSGlobal/Response/Response.cs +++ b/SMSGlobal/Response/Response.cs @@ -1,5 +1,4 @@ -using Nancy.Json; -//using System.Web.Script.Serialization; +using Newtonsoft.Json; /// /// The response namespace. @@ -17,7 +16,7 @@ public class Response /// string public override string ToString() { - return new JavaScriptSerializer().Serialize(this); + return JsonConvert.SerializeObject(this); } } diff --git a/SMSGlobal/SMSGlobal.api.csproj b/SMSGlobal/SMSGlobal.api.csproj index 7857650..f6252af 100644 --- a/SMSGlobal/SMSGlobal.api.csproj +++ b/SMSGlobal/SMSGlobal.api.csproj @@ -16,9 +16,7 @@ - - From ef4671d759ccacbae066a1dbf4ac890f6fe062dc Mon Sep 17 00:00:00 2001 From: j-brooke <6962885+j-brooke@users.noreply.github.com> Date: Fri, 8 Apr 2022 12:07:08 -0400 Subject: [PATCH 3/4] Removed unnecessary and error-prone call to api.nuget.org before all calls to the SMSGlobal server. --- SMSGlobal/Transport/Rest.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/SMSGlobal/Transport/Rest.cs b/SMSGlobal/Transport/Rest.cs index 182b40b..aa49eb4 100644 --- a/SMSGlobal/Transport/Rest.cs +++ b/SMSGlobal/Transport/Rest.cs @@ -18,6 +18,7 @@ namespace SMSGlobal.SMS.Transport class Rest { private Uri uri; + private readonly string dotnetLibVersion; public string host { get; set; } public string port { get; set; } @@ -32,6 +33,10 @@ public Rest(Credentials _credentials) version = _credentials.version; key = _credentials.ApiKey; secret = _credentials.ApiSecret; + + // Figure out the version of this library, for use in the User-Agent header that we send. + var thisVersion = typeof(Rest).Assembly.GetName().Version; + dotnetLibVersion = $"{thisVersion.Major}.{thisVersion.Minor}.{thisVersion.Build}"; } /// @@ -338,7 +343,6 @@ public async Task deleteOptOut(string number = "") return otp; } - /// /// Requests information from the rest api. /// @@ -368,16 +372,7 @@ private async Task Request(string path, Object payload = nu client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("MAC", credentials); - - // Get latest Nuget Package version. - var packageName = "SMSGlobal"; - var url = $"https://api.nuget.org/v3-flatcontainer/{packageName}/index.json"; - var httpClient = new HttpClient(); - var responseNuget = await httpClient.GetAsync(url); - var versionsResponse = await responseNuget.Content.ReadAsAsync(); - var lastVersion = versionsResponse.Versions[^1]; //(length-1) - - client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "SMSGlobal-SDK/v2 Version/" + lastVersion + ", DotNet/" + System.Environment.Version + " (" + Environment.OSVersion + ")"); + client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "SMSGlobal-SDK/v2 Version/" + dotnetLibVersion + ", DotNet/" + System.Environment.Version + " (" + Environment.OSVersion + ")"); var json = JsonConvert.SerializeObject(payload); From ae31220c3b4f788e830f367bdc63570e3ceb3282 Mon Sep 17 00:00:00 2001 From: j-brooke <6962885+j-brooke@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:24:26 -0500 Subject: [PATCH 4/4] Updated Newtonsoft JSON version due to vulnerability. --- SMSGlobal/SMSGlobal.api.csproj | 2 +- SMSGlobalTest/SMSGlobalTest.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SMSGlobal/SMSGlobal.api.csproj b/SMSGlobal/SMSGlobal.api.csproj index f6252af..345c3b6 100644 --- a/SMSGlobal/SMSGlobal.api.csproj +++ b/SMSGlobal/SMSGlobal.api.csproj @@ -16,7 +16,7 @@ - + diff --git a/SMSGlobalTest/SMSGlobalTest.csproj b/SMSGlobalTest/SMSGlobalTest.csproj index 6064c71..6e21818 100644 --- a/SMSGlobalTest/SMSGlobalTest.csproj +++ b/SMSGlobalTest/SMSGlobalTest.csproj @@ -12,7 +12,7 @@ - +