microsoft / onefuzz

A self-hosted Fuzzing-As-A-Service platform
MIT License
2.82k stars 198 forks source link

Add a `GetExpand` trait for initializing `Expand` objects in our tasks #3553

Closed kananb closed 10 months ago

kananb commented 11 months ago

Summary of the Pull Request

Implements a slightly more standardized way for initializing Expand objects by adding a GetExpand trait that defines a similarly named function. Each config then implements it to generate the Expand object.

Property-based unit tests are also added to ensure that all of the variables that are expected to be available for expansion, in fact, are.

A few things that could use further consideration:

  1. Expand object parameters sometimes come from the function's arguments, not always from just the config fields.
    1. target_exe in the generic coverage task.
    2. generated_inputs and input_corpus in the generator task.
    3. runtime_dir and crashes in the supervisor task.
    4. generated_inputs in the merge task.
  2. Sometimes a value is calculated asynchronously and then passed to the Expand object. I'm not sure how to accommodate this from the trait implementation when the value is calculated using only config fields.
    1. target_exe in the analysis task.
    2. target_exe in the dotnet coverage task.
    3. target_exe in the supervisor task.
    4. target_exe in the merge task.
  3. In a few places, a function argument is passed to the Expand object that overrides the value that was passed from the config.
    1. target_exe and reports_dir in the analysis task.
    2. target_exe in the dotnet coverage task.
    3. input_corpus, reports_dir, and crashdumps in the supervisor task.
  4. I'm still very new to Rust, so I might probably have done some silly things without realizing.

PR Checklist

Info on Pull Request

What does this include?

Validation Steps Performed

How does someone test & validate?

codecov-commenter commented 11 months ago

Codecov Report

Merging #3553 (d859cbb) into main (90be543) will increase coverage by 0.95%. The diff coverage is 81.30%.

@@            Coverage Diff             @@
##             main    #3553      +/-   ##
==========================================
+ Coverage   39.01%   39.96%   +0.95%     
==========================================
  Files         302      303       +1     
  Lines       36963    37635     +672     
  Branches        0     1721    +1721     
==========================================
+ Hits        14421    15042     +621     
+ Misses      22542    22274     -268     
- Partials        0      319     +319     
Files Coverage Δ
src/agent/onefuzz-task/src/local/template.rs 77.27% <100.00%> (-1.46%) :arrow_down:
src/agent/onefuzz-task/src/tasks/config.rs 36.43% <100.00%> (+28.36%) :arrow_up:
...c/agent/onefuzz-task/src/tasks/coverage/generic.rs 88.56% <100.00%> (+0.68%) :arrow_up:
src/agent/onefuzz-task/src/local/common.rs 10.95% <0.00%> (+0.47%) :arrow_up:
src/agent/onefuzz-task/src/config_test_utils.rs 99.46% <99.46%> (ø)
...nt/onefuzz-task/src/tasks/report/dotnet/generic.rs 28.03% <96.77%> (+28.03%) :arrow_up:
src/agent/onefuzz-task/src/tasks/merge/generic.rs 35.91% <94.44%> (+35.91%) :arrow_up:
...c/agent/onefuzz-task/src/tasks/analysis/generic.rs 34.76% <95.29%> (+34.76%) :arrow_up:
...rc/agent/onefuzz-task/src/tasks/coverage/dotnet.rs 8.69% <87.50%> (+8.69%) :arrow_up:
src/agent/onefuzz-task/src/tasks/fuzz/generator.rs 21.84% <44.44%> (+21.84%) :arrow_up:
... and 1 more

... and 52 files with indirect coverage changes