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

Method adg_precall

src/analysis/adg.rs:573–614  ·  view source on GitHub ↗

Attach the symbols of this call's args with Arg-taint summary.

(
        store_mgr: &mut StoreMgr<TaintDataVec>,
        env_mgr: &mut EnvMgr<TaintDataVec>,
        call: &ast::Node,
    )

Source from the content-addressed store, hash-verified

571
572 /// Attach the symbols of this call's args with Arg-taint summary.
573 fn adg_precall(
574 store_mgr: &mut StoreMgr<TaintDataVec>,
575 env_mgr: &mut EnvMgr<TaintDataVec>,
576 call: &ast::Node,
577 ) {
578 let call_id = call.id;
579 let name = call.get_call_name();
580 if !is_library_api(&name) {
581 return;
582 }
583 log::trace!("Visit [Precall]: {}", name);
584 for (i, arg_stmt) in call.get_call_arg_stmts().iter().enumerate() {
585 let arg = arg_stmt.get_var_name();
586 if arg.is_empty() {
587 continue;
588 }
589 // currently do not differ array and array's elements.
590 let arg = arg.get_base();
591 let data = TaintData::new(call_id, name.clone(), Taintkind::Arg(i as u8));
592 // if this arg is a callStmt.
593 if arg_stmt.is_call() {
594 Self::adg_precall(store_mgr, env_mgr, arg_stmt);
595 let mut sym = env_mgr.create_object_for_call(call).unwrap();
596 Self::adg_post_call(store_mgr, arg_stmt, &mut sym);
597 sym.get_data_mut().push(data);
598 store_mgr.ssa_bind_value(arg, sym).unwrap();
599 } else {
600 // else, get bind of var.
601 let sym = store_mgr.get_bind_mut(&arg);
602 if let Ok(sym) = sym {
603 sym.get_data_mut().push(data);
604 }
605 // if bind of var isn't existed. e.g., global var in external libraries.
606 else {
607 //log::warn!("{sym:?}");
608 let mut sym = env_mgr.create_dummy_object();
609 sym.get_data_mut().push(data.clone());
610 store_mgr.ssa_bind_value(arg, sym).unwrap();
611 }
612 }
613 }
614 }
615
616 /// Attach the symbols of this call's args with Call-taint summary.
617 fn adg_post_call(

Callers

nothing calls this directly

Calls 13

is_library_apiFunction · 0.85
get_call_arg_stmtsMethod · 0.80
get_var_nameMethod · 0.80
get_baseMethod · 0.80
is_callMethod · 0.80
get_data_mutMethod · 0.80
ssa_bind_valueMethod · 0.80
get_bind_mutMethod · 0.80
create_dummy_objectMethod · 0.80
get_call_nameMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected