Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MutatedTransform to the input type for tmin & push mutational stage #1251

Open
tokatoka opened this issue May 3, 2023 · 3 comments
Open
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@tokatoka
Copy link
Member

tokatoka commented May 3, 2023

like this

I: MutatedTransform<Self::Input, Self::State> + Clone,

in mutational stage

@tokatoka tokatoka added help wanted Extra attention is needed good first issue Good for newcomers labels May 3, 2023
@tejas012321011
Copy link

I would like to contribute to it. Can you please explain to me in some detail, what you need me to do, and provide any starting references/resources that can help in contributing, if any?

@gerceboss
Copy link

Sorry , But I could not find Input types in the files you mentioned , instead I found the other types which were not generics as it is in the file you mentioned.
<Self::State as UsesInput>::Input: HasLen + Hash how do I add MutatedTransform here ?
@tokatoka

@am009
Copy link
Contributor

am009 commented Mar 25, 2024

I have been investigating this issue and reading related codes these days.

The MutatedTransform is introduced in this commit along with the Grimoire. Grimoire is a new fuzzing technique that can efficiently fuzz programs that require highly structured inputs (e.g., a programming language).

The modifications to the mutational stage in the commit serves as a good reference. Previously, you get the testcase from the corpus, then convert it into input, mutate it using mutators, and execute it. Now with MutatedTransform, you use try_transform_from to convert from testcase to MutatedTransform<Input, State>, then pass it to mutators (mutators now mutate over a brand new type), and convert back to input using try_transform_into before execution. try_transform_into also returns a MutatedTransformPost callback that is called after new testcase is inserted into the corpus.

For example, type UnicodeInput = (BytesInput, StringIdentificationMetadata) implemented MutatedTransform<BytesInput, S>. Besides byte array, it also contains additional metadata (StringIdentificationMetadata). When it is transformed from a Testcase (using try_transform_from), the metadata is fetched from the testcase and UnicodeInput is constructed. Then UnicodeInput is passed to mutators. Mutators can leverage the metadata to perform better mutations. After mutation and before execution, UnicodeInput is transformed back into BytesInput (using try_transform_into), and StringIdentificationMetadata is returned as MutatedTransformPost. When the new mutated input is interesting and is inserted into the corpus as a testcase, the post-callback is called to insert the corresponding metadata for the testcase.

For any other types that do not need such a mechanism, there is a reflexive definition that implements MutatedTransform<I, S> for I. It makes try_transform_into a no-operation, and mutators still mutate over I because now I is doubled as MutatedTransform<I, S>.

tokatoka pushed a commit that referenced this issue Mar 27, 2024
) (#1971)

* Support `MutatedTransform` in `TMinMutationalStage`.

* Run `MutatedTransformPost` for the replaced testcase.

* Add clone trait bound for `MutatedTransformPost`.

* Return an error instead of using unwrap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants