Compare commits

..

7 Commits
1.6.7 ... 1.6.8

Author SHA1 Message Date
Stef Heyenrath
4b3e9feca0 1.6.8 2024-11-24 16:22:32 +01:00
Stef Heyenrath
4aaed2a6ca Fix HandlebarsContext ParseAndEvaluate method (#1213)
* Fix HandlebarsContext ParseAndEvaluate method

* test

* xxx
2024-11-22 07:58:23 +01:00
Stef Heyenrath
6f73dfe360 Use GraphQL 8.2.1 (#1211) 2024-11-18 10:23:00 +01:00
Stef Heyenrath
f4103b47aa Fix security issues (#1206)
* .

* .

* x
2024-11-17 17:25:21 +01:00
Stef Heyenrath
edab3ad7e5 WireMockLogger 2024-11-01 10:31:23 +01:00
Stef Heyenrath
38c2131472 IWireMockLogger.Error(string, Exception) 2024-10-29 19:55:02 +01:00
Stef Heyenrath
3693d6a676 Log exception when (static) mapping file cannot be read (#1202) 2024-10-29 19:52:31 +01:00
28 changed files with 134 additions and 71 deletions

View File

@@ -1,3 +1,12 @@
# 1.6.8 (23 November 2024)
- [#1202](https://github.com/WireMock-Net/WireMock.Net/pull/1202) - Log exception when (static) mapping file cannot be read [feature] contributed by [StefH](https://github.com/StefH)
- [#1206](https://github.com/WireMock-Net/WireMock.Net/pull/1206) - Fix security issues [bug] contributed by [StefH](https://github.com/StefH)
- [#1211](https://github.com/WireMock-Net/WireMock.Net/pull/1211) - Use GraphQL 8.2.1 [feature] contributed by [StefH](https://github.com/StefH)
- [#1213](https://github.com/WireMock-Net/WireMock.Net/pull/1213) - Fix HandlebarsContext ParseAndEvaluate method [bug] contributed by [StefH](https://github.com/StefH)
- [#1201](https://github.com/WireMock-Net/WireMock.Net/issues/1201) - Mapping file parse errors are not logged to the console [feature]
- [#1209](https://github.com/WireMock-Net/WireMock.Net/issues/1209) - Upgrade of GraphQL libs to the latest [feature]
- [#1212](https://github.com/WireMock-Net/WireMock.Net/issues/1212) - Response Body Does Not Include Text After Path Segment [bug]
# 1.6.7 (17 October 2024)
- [#1161](https://github.com/WireMock-Net/WireMock.Net/pull/1161) - Use latest ProtoBufJsonConverter to support WellKnownTypes [bug] contributed by [StefH](https://github.com/StefH)
- [#1190](https://github.com/WireMock-Net/WireMock.Net/pull/1190) - Bump System.Text.Json from 8.0.4 to 8.0.5 in /examples/WireMock.Net.Console.Net472.Classic [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)

View File

@@ -4,7 +4,7 @@
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>1.6.7</VersionPrefix>
<VersionPrefix>1.6.8</VersionPrefix>
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
@@ -43,11 +43,17 @@
</When>
</Choose>
<PropertyGroup>
<NuGetAudit>true</NuGetAudit>
<!--<NuGetAuditLevel>low</NuGetAuditLevel>-->
<NuGetAuditMode>all</NuGetAuditMode>
</PropertyGroup>
<ItemGroup>
<!-- CVE-2019-0820 -->
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="JetBrains.Annotations" Version="2024.2.0" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

View File

@@ -1,6 +1,6 @@
rem https://github.com/StefH/GitHubReleaseNotes
SET version=1.6.7
SET version=1.6.8
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels test question invalid doc duplicate example environment --version %version% --token %GH_TOKEN%

View File

@@ -1,11 +1,10 @@
# 1.6.7 (17 October 2024)
- #1161 Use latest ProtoBufJsonConverter to support WellKnownTypes [bug]
- #1190 Bump System.Text.Json from 8.0.4 to 8.0.5 in /examples/WireMock.Net.Console.Net472.Classic [dependencies]
- #1194 Upgrade System.Text.RegularExpressions to 4.3.1 to solve CVE-2019-0820 [bug]
- #1197 Bump System.Text.Json from 8.0.4 to 8.0.5 in /src/dotnet-WireMock.Net [dependencies]
- #1198 Fix Google.Protobuf.WellKnownTypes.Value [bug]
- #1144 Using google.protobuf.Empty as response results in a bad gRPC response [bug]
- #1153 Grpc support for multiple proto files [feature]
- #1193 Snyk issue : Regular Expression Denial of Service [bug]
# 1.6.8 (23 November 2024)
- #1202 Log exception when (static) mapping file cannot be read [feature]
- #1206 Fix security issues [bug]
- #1211 Use GraphQL 8.2.1 [feature]
- #1213 Fix HandlebarsContext ParseAndEvaluate method [bug]
- #1201 Mapping file parse errors are not logged to the console [feature]
- #1209 Upgrade of GraphQL libs to the latest [feature]
- #1212 Response Body Does Not Include Text After Path Segment [bug]
The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md

View File

@@ -6,6 +6,9 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8F890C6F-9ACC-438D-928A-AD61CDA862F2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0BB8B634-407A-4610-A91F-11586990767A}"
ProjectSection(SolutionItems) = preProject
test\Directory.Build.props = test\Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net", "src\WireMock.Net\WireMock.Net.csproj", "{D3804228-91F4-4502-9595-39584E5A01AD}"
EndProject

View File

@@ -51,10 +51,10 @@ public interface IWireMockLogger
/// <summary>
/// Writes the message at the Error level using the specified exception.
/// </summary>
/// <param name="formatString">The format string.</param>
/// <param name="message">The message.</param>
/// <param name="exception">The exception.</param>
[PublicAPI]
void Error(string formatString, Exception exception);
void Error(string message, Exception exception);
/// <summary>
/// Writes the LogEntryModel (LogRequestModel, LogResponseModel and more).

View File

@@ -4,7 +4,7 @@
<Description>Commonly used models, enumerations and types.</Description>
<AssemblyTitle>WireMock.Net.Abstractions</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>net45;net451;net461;netstandard1.0;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net45;net451;net461;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591;8603</NoWarn>
<AssemblyName>WireMock.Net.Abstractions</AssemblyName>
@@ -36,15 +36,18 @@
<ItemGroup>
<!-- See also https://mstack.nl/blog/20210801-source-generators -->
<PackageReference Include="FluentBuilder" Version="0.9.0">
<PackageReference Include="FluentBuilder" Version="0.10.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PolySharp" Version="1.14.0">
<PackageReference Include="PolySharp" Version="1.14.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<!-- CVE-2018-8292 -->
<PackageReference Include="System.Net.Http " Version="4.3.4" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard')) and '$(TargetFramework)' != 'netstandard1.0'">

View File

@@ -35,7 +35,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting" Version="8.2.0" />
<PackageReference Include="Aspire.Hosting" Version="8.2.2" />
</ItemGroup>
<ItemGroup>

View File

@@ -26,7 +26,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="RamlToOpenApiConverter" Version="0.6.1" />
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.17" />
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.18" />
<PackageReference Include="Stef.Validation" Version="0.1.1" />
</ItemGroup>

View File

@@ -4,7 +4,7 @@
<Description>A RestClient using RestEase to access the admin interface.</Description>
<AssemblyTitle>WireMock.Net.RestClient</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>net45;netstandard1.1;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net45;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net.RestClient</AssemblyName>
<PackageId>WireMock.Net.RestClient</PackageId>
@@ -30,8 +30,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JsonConverter.Newtonsoft.Json" Version="0.3.0" />
<PackageReference Include="RestEase" Version="1.5.7" />
<PackageReference Include="JsonConverter.Newtonsoft.Json" Version="0.7.0" />
<PackageReference Include="RestEase" Version="1.6.4" />
<PackageReference Include="Stef.Validation" Version="0.1.1" />
</ItemGroup>

View File

@@ -28,7 +28,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Stef.Validation" Version="0.1.1" />
<PackageReference Include="TUnit.Core" Version="0.1.817" />
<PackageReference Include="TUnit.Core" Version="0.2.195" />
</ItemGroup>
<ItemGroup>

View File

@@ -28,7 +28,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Stef.Validation" Version="0.1.1" />
<PackageReference Include="Testcontainers" Version="3.10.0" />
<PackageReference Include="Testcontainers" Version="4.0.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -3,7 +3,7 @@
<Description>Some extensions for xUnit (ITestOutputHelper)</Description>
<AssemblyTitle>WireMock.Net.xUnit</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>net45;net451;netstandard1.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net45;net451;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net.xUnit</AssemblyName>
<RootNamespace>WireMock.Net.Xunit</RootNamespace>

View File

@@ -52,15 +52,15 @@ public class WireMockConsoleLogger : IWireMockLogger
}
/// <see cref="IWireMockLogger.Error(string, Exception)"/>
public void Error(string formatString, Exception exception)
public void Error(string message, Exception exception)
{
Console.WriteLine(Format("Error", formatString, exception.Message));
Console.WriteLine(Format("Error", $"{message} {{0}}", exception));
if (exception is AggregateException ae)
{
ae.Handle(ex =>
{
Console.WriteLine(Format("Error", "Exception {0}", ex.Message));
Console.WriteLine(Format("Error", "Exception {0}", ex));
return true;
});
}

View File

@@ -36,7 +36,7 @@ public class WireMockNullLogger : IWireMockLogger
}
/// <see cref="IWireMockLogger.Error(string, Exception)"/>
public void Error(string formatString, Exception exception)
public void Error(string message, Exception exception)
{
// Log nothing
}

View File

@@ -113,16 +113,16 @@ public class GraphQLMatcher : IStringMatcher
{
try
{
var executionResult = new DocumentExecuter().ExecuteAsync(_ =>
var executionResult = new DocumentExecuter().ExecuteAsync(eo =>
{
_.ThrowOnUnhandledException = true;
eo.ThrowOnUnhandledException = true;
_.Schema = _schema;
_.Query = graphQLRequest.Query;
eo.Schema = _schema;
eo.Query = graphQLRequest.Query;
if (graphQLRequest.Variables != null)
{
_.Variables = new Inputs(graphQLRequest.Variables);
eo.Variables = new Inputs(graphQLRequest.Variables);
}
}).GetAwaiter().GetResult();

View File

@@ -178,9 +178,9 @@ public partial class WireMockServer
{
ReadStaticMappingAndAddOrUpdate(filename);
}
catch
catch (Exception exception)
{
_settings.Logger.Error("Static MappingFile : '{0}' could not be read. This file will be skipped.", filename);
_settings.Logger.Error($"Static MappingFile : '{filename}' could not be read. This file will be skipped.", exception);
}
}
}

View File

@@ -27,7 +27,9 @@ internal class HandlebarsContext : IHandlebarsContext
public object? ParseAndEvaluate(string text, object model)
{
if (Handlebars.TryEvaluate(text, model, out var result) && result is not UndefinedBindingResult)
if (text.StartsWith("{{") && text.EndsWith("}}") &&
Handlebars.TryEvaluate(text, model, out var result) &&
result is not UndefinedBindingResult)
{
return result;
}

View File

@@ -59,13 +59,13 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JsonConverter.Abstractions" Version="0.5.0" />
<PackageReference Include="JsonConverter.Abstractions" Version="0.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NJsonSchema.Extensions" Version="0.1.0" />
<PackageReference Include="NSwag.Core" Version="13.16.1" />
<PackageReference Include="SimMetrics.Net" Version="1.0.5" />
<PackageReference Include="JmesPath.Net" Version="1.0.125" />
<PackageReference Include="AnyOf" Version="0.3.0" />
<PackageReference Include="JmesPath.Net" Version="1.0.330" />
<PackageReference Include="AnyOf" Version="0.4.0" />
<PackageReference Include="TinyMapper" Version="3.0.3" />
</ItemGroup>
@@ -108,9 +108,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<!-- https://github.com/WireMock-Net/WireMock.Net/issues/697 -->
<PackageReference Include="System.Text.Encodings.Web" Version="4.7.2" />
<!-- https://github.com/WireMock-Net/WireMock.Net/issues/507 -->
<PackageReference Include="Microsoft.AspNetCore.Server.IIS" Version="2.2.6" />
</ItemGroup>
@@ -147,8 +144,7 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard1.3' and '$(TargetFramework)' != 'net451' and '$(TargetFramework)' != 'net452' and '$(TargetFramework)' != 'net46' and '$(TargetFramework)' != 'net461'">
<PackageReference Include="GraphQL" Version="7.5.0" />
<PackageReference Include="GraphQL.NewtonsoftJson" Version="7.5.0" />
<PackageReference Include="GraphQL.NewtonsoftJson" Version="8.2.1" />
<PackageReference Include="MimeKitLite" Version="4.1.0.1" />
<PackageReference Include="ProtoBufJsonConverter" Version="0.5.0" />
</ItemGroup>
@@ -192,6 +188,11 @@
<PackageReference Include="Handlebars.Net.Helpers.Xslt" Version="2.4.6" />
</ItemGroup>
<ItemGroup>
<!-- CVE-2021-26701 and https://github.com/WireMock-Net/WireMock.Net/issues/697 -->
<PackageReference Include="System.Text.Encodings.Web" Version="4.7.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
<ProjectReference Include="..\WireMock.Org.Abstractions\WireMock.Org.Abstractions.csproj" />

View File

@@ -30,8 +30,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AnyOf" Version="0.3.0" />
<PackageReference Include="RestEase" Version="1.5.7" />
<PackageReference Include="AnyOf" Version="0.4.0" />
<PackageReference Include="RestEase" Version="1.6.4" />
</ItemGroup>
<ItemGroup>

View File

@@ -47,9 +47,9 @@ public class WireMockLogger : IWireMockLogger
}
/// <see cref="IWireMockLogger.Error(string, Exception)"/>
public void Error(string formatString, Exception exception)
public void Error(string message, Exception exception)
{
_logger.LogError(exception, formatString);
_logger.LogError(exception, message);
}
/// <see cref="IWireMockLogger.DebugRequestResponse"/>

View File

@@ -0,0 +1,8 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<ItemGroup Condition=" '$(TargetFramework)' != 'net45' and '$(TargetFramework)' != 'net452' and '$(TargetFramework)' != 'net461' ">
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" />
</ItemGroup>
</Project>

View File

@@ -18,7 +18,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.2.0" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.2.2" />
</ItemGroup>
<ItemGroup>

View File

@@ -13,7 +13,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.Testing" Version="8.2.0" />
<PackageReference Include="Aspire.Hosting.Testing" Version="8.2.2" />
<PackageReference Include="Codecov" Version="1.13.0" />
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>

View File

@@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TUnit" Version="0.1.817" />
<PackageReference Include="TUnit" Version="0.2.195" />
</ItemGroup>
<ItemGroup>

View File

@@ -107,22 +107,32 @@ public class GraphQLMatcherTests
public void GraphQLMatcher_For_ValidSchema_And_CorrectGraphQL_UsingCustomType_Mutation_IsMatch()
{
// Arrange
const string testSchema = @"
scalar DateTime
scalar MyCustomScalar
// Query is provided here: https://stackoverflow.com/questions/59608833/apollo-graphql-error-query-root-type-must-be-provided
const string testSchema =
"""
scalar DateTime
scalar MyCustomScalar
type Query {
_empty: String
}
type Message {
id: ID!
}
type Mutation {
createMessage(x: MyCustomScalar, dt: DateTime): Message
}
""";
type Message {
id: ID!
}
type Mutation {
createMessage(x: MyCustomScalar, dt: DateTime): Message
}";
var input = @"{
""query"": ""mutation CreateMessage($x: MyCustomScalar!, $dt: DateTime!) { createMessage(x: $x, dt: $dt) { id } }"",
""variables"": { ""x"": 100, ""dt"": ""2007-12-03T10:15:30Z"" }
}";
const string input =
"""
{
"query": "mutation CreateMessage($x: MyCustomScalar!, $dt: DateTime!) { createMessage(x: $x, dt: $dt) { id } }",
"variables": { "x": 100, "dt": "2007-12-03T10:15:30Z" }
}
""";
var customScalars = new Dictionary<string, Type> { { "MyCustomScalar", typeof(int) } };

View File

@@ -130,6 +130,29 @@ public class ResponseWithTransformerTests
Check.That(response.Message.BodyData!.BodyAsString).Equals("a wiremock");
}
[Theory]
[InlineData("{{request.PathSegments.[0]}}", "a")]
[InlineData("prefix_{{request.PathSegments.[0]}}", "prefix_a")]
[InlineData("{{request.PathSegments.[0]}}_postfix", "a_postfix")]
[InlineData("prefix_{{request.PathSegments.[0]}}_postfix", "prefix_a_postfix")]
public async Task Response_ProvideResponse_Handlebars_BodyAsJson_PathSegments(string field, string expected)
{
// Assign
var urlDetails = UrlUtils.Parse(new Uri("http://localhost/wiremock/a/b"), new PathString("/wiremock"));
var request = new RequestMessage(urlDetails, "POST", ClientIp);
var responseBuilder = Response.Create()
.WithBodyAsJson(new { field })
.WithTransformer();
// Act
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
// Assert
var json = (JObject)response.Message.BodyData!.BodyAsJson!;
Check.That(json["field"]!.Value<string>()).Equals(expected);
}
[Theory(Skip = "Invalid token `OpenBracket`")]
[InlineData(TransformerType.Scriban)]
[InlineData(TransformerType.ScribanDotLiquid)]

View File

@@ -72,10 +72,10 @@
</PackageReference>
<PackageReference Include="Moq" Version="4.17.2" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="RestEase" Version="1.5.7" />
<PackageReference Include="RestEase" Version="1.6.4" />
<PackageReference Include="NFluent" Version="2.8.0" />
<PackageReference Include="SimMetrics.Net" Version="1.0.5" />
<PackageReference Include="AnyOf" Version="0.3.0" />
<PackageReference Include="AnyOf" Version="0.4.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
</ItemGroup>
@@ -104,8 +104,7 @@
<ItemGroup Condition="'$(TargetFramework)' != 'net452'">
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
<PackageReference Include="JsonConverter.System.Text.Json" Version="0.5.0" />
<PackageReference Include="JsonConverter.System.Text.Json" Version="0.7.0" />
<PackageReference Include="Google.Protobuf" Version="3.25.1" />
<PackageReference Include="Grpc.Net.Client" Version="2.60.0" />
<PackageReference Include="Grpc.Tools" Version="2.60.0">