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

Method collect_fuzzable_variants

src/program/transform.rs:1365–1392  ·  view source on GitHub ↗

Analyze the AST of the program. Collect the API calls that contained the fuzzable arguments.

(
        &self,
        visitor: &Visitor,
        constraints: &APIConstraints,
    )

Source from the content-addressed store, hash-verified

1363impl Visitor {
1364 /// Analyze the AST of the program. Collect the API calls that contained the fuzzable arguments.
1365 fn collect_fuzzable_variants(
1366 &self,
1367 visitor: &Visitor,
1368 constraints: &APIConstraints,
1369 ) -> Vec<FuzzVariant> {
1370 let mut fuzz_variants = Vec::new();
1371 let calls = self.visit_library_calls();
1372 for (n_th_call, call) in calls.iter().enumerate() {
1373 // cannot locate code elements in macro expansion, skip it.
1374 if let Clang::CallExpr(ce) = &call.kind {
1375 if is_macro_stmt(&ce.range) {
1376 continue;
1377 }
1378 }
1379
1380 let call_name = call.get_call_name();
1381 // get the positions of constant array parameters of this API call.
1382 let fuzz_arrays =
1383 collect_fuzzable_array_args(&call_name, call, n_th_call, constraints, visitor);
1384 // get the positions of integer (scalar) type parameters of this API call.
1385 let fuzz_integers =
1386 collect_fuzzable_integer_args(&call_name, call, n_th_call, constraints, visitor);
1387
1388 fuzz_variants.extend(fuzz_arrays);
1389 fuzz_variants.extend(fuzz_integers);
1390 }
1391 fuzz_variants
1392 }
1393}
1394
1395/// those array args are not fuzzable arrays, they should not be transformed to receive fuzz bytes.

Callers 2

get_transform_lenMethod · 0.80

Calls 5

is_macro_stmtFunction · 0.85
visit_library_callsMethod · 0.80
get_call_nameMethod · 0.45

Tested by

no test coverage detected