Skip to content

Update parse_filter_hosts.rs #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ZeroHack01
Copy link

@ZeroHack01 ZeroHack01 commented Jun 21, 2025

🎯 Enhanced Fuzzing Target for Adblock Parser

What Changed

Improved the fuzzing target to provide better code coverage and robustness for finding edge cases in the adblock filter parser.

Key Improvements

  • Multiple FilterFormats: Tests Standard, Hosts, and AdblockPlus (was only Hosts)
  • Input Validation: Added bounds checking to prevent hangs on large inputs
  • Panic Safety: Added catch_unwind protection
  • Better Coverage: Tests common filter prefixes (||, @@, ###, etc.)
  • Proper Error Handling: Processes parse results instead of ignoring them

Before

// Only tested FilterFormat::Hosts, no input validation
fuzz_target!(|data: &[u8]| {
    if let Ok(filter) = std::str::from_utf8(data) {
        parse_filter(filter, true, ParseOptions {
            format: FilterFormat::Hosts,
            ..Default::default()
        }); // Result ignored
    }
});

@ZeroHack01 ZeroHack01 requested a review from antonok-edm as a code owner June 21, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant