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

Function get_func_gadgets

src/program/gadget.rs:27–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27pub fn get_func_gadgets() -> &'static Vec<FuncGadget> {
28 static GADGETS: OnceCell<Vec<FuncGadget>> = OnceCell::new();
29 GADGETS.get_or_init(|| {
30 let deopt = Deopt::new(config::get_library_name()).unwrap();
31 if let Ok(gadgets) = load_func_gadgets(&deopt) {
32 return gadgets;
33 }
34 let mut gadgets = parse_func_gadgets(&deopt).unwrap();
35 if let Some(ban_funcs) = &deopt.config.ban {
36 gadgets.retain(|x| {
37 for ban_func in ban_funcs {
38 let re = Regex::new(ban_func)
39 .unwrap_or_else(|_| panic!("Error regex in config.yaml: {ban_func}"));
40 if re.is_match(x.get_func_name()) {
41 return false;
42 }
43 }
44 true
45 })
46 }
47 func_gadget::dump_func_gadgets(&gadgets, &deopt).unwrap();
48 log::debug!("Parsed {} function gadgets.", gadgets.len());
49 if gadgets.is_empty() {
50 panic!("Cannot extract function gadgets! Please check whether your library building was sucessful!")
51 }
52 gadgets
53 })
54}
55
56#[derive(Eq, PartialEq, Hash, Clone, serde::Deserialize, serde::Serialize)]
57pub struct TypeGadget {

Callers 8

update_energiesMethod · 0.85
rand_choose_combinationFunction · 0.85
get_func_gadgetFunction · 0.85
dump_func_gadgets_tostrFunction · 0.85
get_fuzzable_funcsFunction · 0.85
test_parse_func_gadgetsFunction · 0.85
find_exploitable_funcFunction · 0.85

Calls 6

get_library_nameFunction · 0.85
load_func_gadgetsFunction · 0.85
parse_func_gadgetsFunction · 0.85
dump_func_gadgetsFunction · 0.85
get_func_nameMethod · 0.80
is_emptyMethod · 0.45

Tested by 1

test_parse_func_gadgetsFunction · 0.68