From d23756398891d5dd8fbf0151661a79e6451ac968 Mon Sep 17 00:00:00 2001 From: Cheick Keita Date: Thu, 4 May 2023 12:14:23 -0700 Subject: [PATCH] Collect additional report field in an ExtensionData property (#3079) * Collect additional report field in an ExtensionData property * typo fix --- src/ApiService/ApiService/OneFuzzTypes/Model.cs | 2 ++ src/ApiService/Tests/ReportTests.cs | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ApiService/ApiService/OneFuzzTypes/Model.cs b/src/ApiService/ApiService/OneFuzzTypes/Model.cs index 6ebd0bea8a..9b0594a4e1 100644 --- a/src/ApiService/ApiService/OneFuzzTypes/Model.cs +++ b/src/ApiService/ApiService/OneFuzzTypes/Model.cs @@ -461,6 +461,8 @@ public record Report( string? OnefuzzVersion, Uri? ReportUrl ) : IReport, ITruncatable { + + [JsonExtensionData] public Dictionary? ExtensionData { get; set; } public Report Truncate(int maxLength) { return this with { Executable = Executable[..maxLength], diff --git a/src/ApiService/Tests/ReportTests.cs b/src/ApiService/Tests/ReportTests.cs index 9e838ff561..aaa453318e 100644 --- a/src/ApiService/Tests/ReportTests.cs +++ b/src/ApiService/Tests/ReportTests.cs @@ -36,7 +36,9 @@ void TestParseReport() { }, "tool_name": "libfuzzer", "tool_version": "1.2.3", - "onefuzz_version": "1.2.3" + "onefuzz_version": "1.2.3", + "extra_property1": "test", + "extra_property2": 5 } """; @@ -78,7 +80,11 @@ void TestParseReport() { """; var report = Reports.ParseReportOrRegression(testReport, new Uri("http://test")); - _ = Assert.IsType(report); + var reportInstance = Assert.IsType(report); + + Assert.Equal("test", reportInstance?.ExtensionData?["extra_property1"].GetString()); + Assert.Equal(5, reportInstance?.ExtensionData?["extra_property2"].GetInt32()); + var regression = Reports.ParseReportOrRegression(testRegresion, new Uri("http://test")); _ = Assert.IsType(regression);