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

Method match_string_pattern

src/ast/visitor.rs:355–377  ·  view source on GitHub ↗
(&self, patten: regex::Regex)

Source from the content-addressed store, hash-verified

353 }
354
355 pub fn match_string_pattern(&self, patten: regex::Regex) -> Option<String> {
356 let mut work_list = WorkList::new();
357 work_list.push(&self.ast);
358 while !work_list.empty() {
359 let curr = work_list.pop();
360 if let Clang::CallExpr(ce) = &curr.kind {
361 let call_name = ce.get_name_as_string(curr);
362 if call_name == "fopen" {
363 continue;
364 }
365 }
366 if let Clang::StringLiteral(sl) = &curr.kind {
367 let value = sl.get_eval_value();
368 if patten.is_match(&value) {
369 return Some(value);
370 }
371 }
372 for child in &curr.inner {
373 work_list.push(child);
374 }
375 }
376 None
377 }
378
379 pub fn find_nested_call(&self, nested: &[&str]) -> Option<(&CallExpr, &CallExpr, String)> {
380 let mut worklist = WorkList::new();

Callers 1

Calls 5

emptyMethod · 0.80
popMethod · 0.80
get_name_as_stringMethod · 0.80
get_eval_valueMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected