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

Function get_fuzzer_shim_range

src/ast/loc.rs:251–265  ·  view source on GitHub ↗

Get the source file range of the fuzzer shim

(src_file: &Path)

Source from the content-addressed store, hash-verified

249
250/// Get the source file range of the fuzzer shim
251pub fn get_fuzzer_shim_range(src_file: &Path) -> Result<(usize, usize)> {
252 let mut f = std::fs::OpenOptions::new().read(true).open(src_file)?;
253 let mut buffer = String::new();
254 f.read_to_string(&mut buffer)?;
255 let shim_begin = "//fuzzer vars shim";
256 let shim_end = "//fuzzer shim end}";
257 let begin_loc = buffer
258 .find(shim_begin)
259 .ok_or_else(|| eyre::eyre!("cannot find `fuzzer vars shim`"))?;
260 let end_loc = buffer
261 .find(shim_end)
262 .ok_or_else(|| eyre::eyre!("cannot find `fuzzer shim end`"))?;
263 let end_loc = end_loc + shim_end.len();
264 Ok((begin_loc, end_loc))
265}
266
267pub fn is_valid_range(range: &SourceRange) -> bool {
268 if range.begin.spelling_loc.is_some() {

Callers 1

update_fuzzer_shimMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected