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

Function infer

src/program/infer/dynamic_infer.rs:99–131  ·  view source on GitHub ↗
(static_constraint: &mut APIConstraints, deopt: &Deopt)

Source from the content-addressed store, hash-verified

97}
98
99pub fn infer(static_constraint: &mut APIConstraints, deopt: &Deopt) -> Result<()> {
100 log::info!("Dynamically infer the constraints imposed on integral.");
101
102 let mut dyn_constraints: APIConstraints = APIConstraints::new();
103 for (func, args) in find_exploitable_func(static_constraint)? {
104 log::info!("infer constraint for: {func} and args: {args:?}");
105 let mut func_constraints = Vec::new();
106 let test_programs = find_testbed_program(&func, deopt);
107 for program in test_programs {
108 log::info!("infer constraint on program: {program:?}");
109 for arg in &args {
110 let has_constraint = infer_constraint_for_func(&func, *arg, program, deopt)?;
111 if let Some(constraint) = has_constraint {
112 log::debug!("Infered! {func}, {constraint:?}");
113 func_constraints.push(constraint);
114 }
115 }
116 }
117 func_constraints = dedup_constraint(func_constraints);
118 dyn_constraints.insert(func, func_constraints);
119 }
120 for (func, cs) in dyn_constraints {
121 if cs.is_empty() {
122 continue;
123 }
124 if let Some(static_cs) = static_constraint.get_mut(&func) {
125 static_cs.extend(cs);
126 } else {
127 static_constraint.insert(func, cs);
128 }
129 }
130 Ok(())
131}
132
133pub fn infer_constraint_for_func(
134 func: &str,

Callers 1

infer_constraintsFunction · 0.85

Calls 6

find_exploitable_funcFunction · 0.85
find_testbed_programFunction · 0.85
dedup_constraintFunction · 0.85
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected