|
| 1 | +namespace Tests; |
| 2 | +using System; |
| 3 | +using Microsoft.OneFuzz.Service; |
| 4 | +using Xunit; |
| 5 | + |
| 6 | +public class ReportTests { |
| 7 | + |
| 8 | + [Fact] |
| 9 | + void TestParseReport() { |
| 10 | + |
| 11 | + var testReport = """ |
| 12 | +{ |
| 13 | + "call_stack_sha256": "972a371a291ed5668a77576368ead0c46c2bac9f9a16b7fa7c0b48aec5b059b1", |
| 14 | + "input_url": "https://fuzzxkbh6uhuuke4m.blob.core.windows.net/oft-asan-crashes/crash", |
| 15 | + "executable": "setup/fuzz.exe", |
| 16 | + "crash_type": "double-free", |
| 17 | + "crash_site": "double-free (/onefuzz/setup/fuzz.exe+0x4f72e2)", |
| 18 | + "call_stack": [ |
| 19 | + "#0 0x4f72e2 (/onefuzz/setup/fuzz.exe+0x4f72e2)", |
| 20 | + "#1 0x5273f0 (/onefuzz/setup/fuzz.exe+0x5273f0)", |
| 21 | + "#2 0x42fb3a (/onefuzz/setup/fuzz.exe+0x42fb3a)", |
| 22 | + "#3 0x41ef87 (/onefuzz/setup/fuzz.exe+0x41ef87)", |
| 23 | + "#4 0x424ba1 (/onefuzz/setup/fuzz.exe+0x424ba1)", |
| 24 | + "#5 0x44bd72 (/onefuzz/setup/fuzz.exe+0x44bd72)", |
| 25 | + "#6 0x7ffff6a9bb96 (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)", |
| 26 | + "#7 0x41d879 (/onefuzz/setup/fuzz.exe+0x41d879)" |
| 27 | + ], |
| 28 | + "asan_log": "INFO: Seed: 1720627312\nINFO: Loaded 1 modules (21 inline 8-bit counters): 21 [0x766ef0, 0x766f05), \nINFO: Loaded 1 PC tables (21 PCs): 21 [0x542fd0,0x543120), \nsetup/fuzz.exe: Running 1 inputs 1 time(s) each.\nRunning: ./tmp/crash-66e9fe527ddb160d75f8c2cc373479e841f7999c\n=================================================================\n==16771==ERROR: AddressSanitizer: attempting double-free on 0x602000000050 in thread T0:\n==16771==WARNING: invalid path to external symbolizer!\n==16771==WARNING: Failed to use and restart external symbolizer!\n #0 0x4f72e2 (/onefuzz/setup/fuzz.exe+0x4f72e2)\n #1 0x5273f0 (/onefuzz/setup/fuzz.exe+0x5273f0)\n #2 0x42fb3a (/onefuzz/setup/fuzz.exe+0x42fb3a)\n #3 0x41ef87 (/onefuzz/setup/fuzz.exe+0x41ef87)\n #4 0x424ba1 (/onefuzz/setup/fuzz.exe+0x424ba1)\n #5 0x44bd72 (/onefuzz/setup/fuzz.exe+0x44bd72)\n #6 0x7ffff6a9bb96 (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)\n #7 0x41d879 (/onefuzz/setup/fuzz.exe+0x41d879)\n\n0x602000000050 is located 0 bytes inside of 4-byte region [0x602000000050,0x602000000054)\nfreed by thread T0 here:\n #0 0x4f72e2 (/onefuzz/setup/fuzz.exe+0x4f72e2)\n #1 0x5273e1 (/onefuzz/setup/fuzz.exe+0x5273e1)\n #2 0x42fb3a (/onefuzz/setup/fuzz.exe+0x42fb3a)\n #3 0x41ef87 (/onefuzz/setup/fuzz.exe+0x41ef87)\n #4 0x424ba1 (/onefuzz/setup/fuzz.exe+0x424ba1)\n #5 0x44bd72 (/onefuzz/setup/fuzz.exe+0x44bd72)\n #6 0x7ffff6a9bb96 (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)\n\npreviously allocated by thread T0 here:\n #0 0x4f7663 (/onefuzz/setup/fuzz.exe+0x4f7663)\n #1 0x5273cb (/onefuzz/setup/fuzz.exe+0x5273cb)\n #2 0x42fb3a (/onefuzz/setup/fuzz.exe+0x42fb3a)\n #3 0x41ef87 (/onefuzz/setup/fuzz.exe+0x41ef87)\n #4 0x424ba1 (/onefuzz/setup/fuzz.exe+0x424ba1)\n #5 0x44bd72 (/onefuzz/setup/fuzz.exe+0x44bd72)\n #6 0x7ffff6a9bb96 (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)\n\nSUMMARY: AddressSanitizer: double-free (/onefuzz/setup/fuzz.exe+0x4f72e2) \n==16771==ABORTING\n", |
| 29 | + "task_id": "218e1cdb-529a-45dd-b45b-1966d42b652c", |
| 30 | + "job_id": "218e1cdb-529a-45dd-b45b-1966d42b652c", |
| 31 | + "input_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", |
| 32 | + "input_blob": { |
| 33 | + "account": "fuzzxkbh6uhuuke4m", |
| 34 | + "container": "oft-asn-crashes", |
| 35 | + "name": "crash" |
| 36 | + }, |
| 37 | + "tool_name": "libfuzzer", |
| 38 | + "tool_version": "1.2.3", |
| 39 | + "onefuzz_version": "1.2.3" |
| 40 | +} |
| 41 | +"""; |
| 42 | + |
| 43 | + var testRegresion = """ |
| 44 | +{ |
| 45 | + "crash_test_result": { |
| 46 | + "no_repro": { |
| 47 | + "input_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", |
| 48 | + "executable": "/onefuzz/blob-containers/fuzzdn52wmq2aaxny/fuzz.exe", |
| 49 | + "task_id": "f032970b-3de2-4d52-897f-4c83715f840d", |
| 50 | + "job_id": "f3d4821e-3fd8-47a1-aecb-97d2418555d5", |
| 51 | + "tries": 1 |
| 52 | + } |
| 53 | + }, |
| 54 | + "original_crash_test_result": { |
| 55 | + "crash_report": { |
| 56 | + "input_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", |
| 57 | + "input_blob": { |
| 58 | + "account": "fuzzdn52wmq2aaxny", |
| 59 | + "container": "oft-crashes-cc3ebdad463e52c1a540b8efb631c1ed", |
| 60 | + "name": "fake-crash-sample" |
| 61 | + }, |
| 62 | + "executable": "fuzz.exe", |
| 63 | + "crash_type": "fake crash report", |
| 64 | + "crash_site": "fake crash site", |
| 65 | + "call_stack": ["#0 fake", "#1 call", "#2 stack"], |
| 66 | + "call_stack_sha256": "0000000000000000000000000000000000000000000000000000000000000000", |
| 67 | + "minimized_stack": [], |
| 68 | + "minimized_stack_function_names": [], |
| 69 | + "asan_log": "fake asan log", |
| 70 | + "task_id": "3e345aa4-8399-45fd-8e10-8d953f1802b0", |
| 71 | + "job_id": "f3d4821e-3fd8-47a1-aecb-97d2418555d5", |
| 72 | + "onefuzz_version": "1.2.3", |
| 73 | + "tool_name": "libfuzzer", |
| 74 | + "tool_version": "1.2.3" |
| 75 | + } |
| 76 | + } |
| 77 | +} |
| 78 | +"""; |
| 79 | + |
| 80 | + var report = Reports.ParseReportOrRegression(testReport, new Uri("http://test")); |
| 81 | + _ = Assert.IsType<Report>(report); |
| 82 | + |
| 83 | + var regression = Reports.ParseReportOrRegression(testRegresion, new Uri("http://test")); |
| 84 | + _ = Assert.IsType<RegressionReport>(regression); |
| 85 | + |
| 86 | + var noReport = Reports.ParseReportOrRegression("{}", new Uri("http://test")); |
| 87 | + Assert.Null(noReport); |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + } |
| 92 | + |
| 93 | +} |
0 commit comments