Add a target per RPC command, and also keep ("rpc", {}) to allow for cross-pollination, or unlimited search
(targets, src_dir)
| 221 | |
| 222 | |
| 223 | def transform_rpc_target(targets, src_dir): |
| 224 | """Add a target per RPC command, and also keep ("rpc", {}) to allow for cross-pollination, |
| 225 | or unlimited search""" |
| 226 | |
| 227 | rpc_target = "rpc" |
| 228 | if (rpc_target, {}) in targets: |
| 229 | lines = subprocess.run( |
| 230 | ["git", "grep", "--function-context", "RPC_COMMANDS_SAFE_FOR_FUZZING{", "src/test/fuzz/rpc.cpp"], |
| 231 | check=True, |
| 232 | stdout=subprocess.PIPE, |
| 233 | text=True, |
| 234 | cwd=src_dir, |
| 235 | ).stdout.splitlines() |
| 236 | lines = [l.split("\"", 1)[1].split("\"")[0] for l in lines if l.startswith("src/test/fuzz/rpc.cpp- \"")] |
| 237 | assert len(lines) |
| 238 | targets += [(rpc_target, {"LIMIT_TO_RPC_COMMAND": r}) for r in lines] |
| 239 | return targets |
| 240 | |
| 241 | |
| 242 | def generate_corpus(*, fuzz_pool, src_dir, fuzz_bin, corpus_dir, targets): |