Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Collect additional report field in an ExtensionData property (#3079)
Browse files Browse the repository at this point in the history
* Collect additional report field in an ExtensionData property

* typo fix
  • Loading branch information
chkeita authored May 4, 2023
1 parent f3ec0e5 commit d237563
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/ApiService/ApiService/OneFuzzTypes/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ public record Report(
string? OnefuzzVersion,
Uri? ReportUrl
) : IReport, ITruncatable<Report> {

[JsonExtensionData] public Dictionary<string, JsonElement>? ExtensionData { get; set; }
public Report Truncate(int maxLength) {
return this with {
Executable = Executable[..maxLength],
Expand Down
10 changes: 8 additions & 2 deletions src/ApiService/Tests/ReportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
""";

Expand Down Expand Up @@ -78,7 +80,11 @@ void TestParseReport() {
""";

var report = Reports.ParseReportOrRegression(testReport, new Uri("http://test"));
_ = Assert.IsType<Report>(report);
var reportInstance = Assert.IsType<Report>(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<RegressionReport>(regression);
Expand Down

0 comments on commit d237563

Please sign in to comment.