MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / transform_to_fuzzer

Method transform_to_fuzzer

src/program/transform.rs:111–135  ·  view source on GitHub ↗

Given the sequence numbers of fuzzable arguments, transform those arguments to receive fuzzer engine's bytes. The transformation satisfies th passed constraints. nths: the sequence numbers of the arguments you want to transform.

(
        &mut self,
        constraints: &APIConstraints,
        nths: Vec<usize>,
    )

Source from the content-addressed store, hash-verified

109 /// The transformation satisfies th passed constraints.
110 /// nths: the sequence numbers of the arguments you want to transform.
111 pub fn transform_to_fuzzer(
112 &mut self,
113 constraints: &APIConstraints,
114 nths: Vec<usize>,
115 ) -> Result<()> {
116 log::debug!("Change {:?} to fuzzer, {nths:?}", self.src_file.file_name());
117 // change to fuzzer function declaration
118 let fuzzer_ty = "int";
119 let fuzzer_name = "LLVMFuzzerTestOneInput".to_string();
120
121 let fuzzer_params = "const uint8_t* f_data, size_t f_size";
122 self.change_fd_to_fuzzer(fuzzer_ty, &fuzzer_name, fuzzer_params)?;
123 self.change_input_data_fuzzable()?;
124
125 // change fuzzable args of calls to receive fuzzer input
126 self.change_calls_to_fuzzer(constraints, nths)?;
127 // ignore to change vardecl, because it is useless as all fuzzable args are already changed.
128
129 self.write_fuzzer_seeds()?;
130 self.add_fd_sanitizer()?;
131 self.handle_file_constraint("data", "size")?;
132 self.add_fuzzer_size_constraint("f_size")?;
133
134 Ok(())
135 }
136
137 pub fn transform_with_execution_check(
138 &mut self,

Callers 4

transformFunction · 0.80

Calls 7

change_fd_to_fuzzerMethod · 0.80
write_fuzzer_seedsMethod · 0.80
add_fd_sanitizerMethod · 0.80

Tested by 2