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

Function find_exploitable_func

src/program/infer/dynamic_infer.rs:208–230  ·  view source on GitHub ↗

Find the api functions that contains an fuzzable integeral parameter.

(static_constraint: &APIConstraints)

Source from the content-addressed store, hash-verified

206
207/// Find the api functions that contains an fuzzable integeral parameter.
208fn find_exploitable_func(static_constraint: &APIConstraints) -> Result<Vec<(String, Vec<usize>)>> {
209 let mut funcs = Vec::new();
210 for gadget in get_func_gadgets() {
211 let api_name = gadget.get_func_name();
212 let mut int_pos = gadget.get_integer_params_pos();
213 // remove the param that constrainted by ArrayLen and ArrayIndex and FileDesc
214 if let Some(constraints) = static_constraint.get(api_name) {
215 for constraint in constraints {
216 if let Some((_, arg_pos)) = constraint.get_arg_tuple() {
217 int_pos.retain(|x| x != arg_pos);
218 }
219 if let Constraint::FileDesc(arg_pos) = constraint {
220 int_pos.retain(|x| x != arg_pos);
221 }
222 }
223 }
224 if int_pos.is_empty() {
225 continue;
226 }
227 funcs.push((api_name.to_string(), int_pos));
228 }
229 Ok(funcs)
230}
231
232/// Ranked API coverage for API in each programs.
233type APICovRank = HashMap<String, Vec<(f32, usize)>>;

Callers 1

inferFunction · 0.85

Calls 6

get_func_gadgetsFunction · 0.85
get_func_nameMethod · 0.80
get_arg_tupleMethod · 0.80
is_emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected