| 135 | } |
| 136 | |
| 137 | pub fn transform_with_execution_check( |
| 138 | &mut self, |
| 139 | constraints: &APIConstraints, |
| 140 | corpora: &Path, |
| 141 | ) -> Result<Vec<usize>> { |
| 142 | let transform_len: usize = self.get_transform_len(constraints)?; |
| 143 | let mut changable_args = Vec::new(); |
| 144 | let mut executor = Executor::new(self.deopt)?; |
| 145 | for nth in 0..transform_len { |
| 146 | let mut transformer = Self::new(&self.src_file, self.deopt)?.without_self_change(); |
| 147 | if let Err(_) = transformer.transform_to_fuzzer(constraints, vec![nth]) { |
| 148 | // change this arg will cause syntax error: see https://github.com/FuzzAnything/PromptFuzz/issues/41 |
| 149 | continue; |
| 150 | } |
| 151 | let out_driver: &Path = transformer.get_output_file(); |
| 152 | if let Some(err) = executor.transform_check(out_driver, corpora)? { |
| 153 | let err_msg = err.get_err_msg(); |
| 154 | log::warn!( |
| 155 | "program: {:?} at nth_fuzzable_arg: {nth} cannot be fuzzable.\n {err_msg}", |
| 156 | self.src_file |
| 157 | ); |
| 158 | } else { |
| 159 | changable_args.push(nth); |
| 160 | } |
| 161 | } |
| 162 | Ok(changable_args) |
| 163 | } |
| 164 | |
| 165 | /// get the number of fuzzable arguments wait to be transformed to receive fuzzer's bytes in this program. |
| 166 | pub fn get_transform_len(&mut self, constraints: &APIConstraints) -> Result<usize> { |