Skip to content

Commit

Permalink
Add xgettext fuzz target
Browse files Browse the repository at this point in the history
  • Loading branch information
kdarkhan committed Dec 8, 2023
1 parent 4af87a9 commit cb0ce49
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ jobs:
run: |
cd i18n-helpers
cargo fuzz run gettext -- -only_ascii=1 -max_total_time=30
cargo fuzz cmin normalize
cargo fuzz cmin gettext
- name: Run xgettext fuzzer and minimize corpus
run: |
cd i18n-helpers
cargo fuzz run xgettext -- -only_ascii=1 -max_total_time=30
cargo fuzz cmin xgettext
clippy:
name: Clippy
Expand Down
6 changes: 6 additions & 0 deletions i18n-helpers/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ name = "gettext"
path = "fuzz_targets/gettext.rs"
test = false
doc = false

[[bin]]
name = "xgettext"
path = "fuzz_targets/xgettext.rs"
test = false
doc = false
20 changes: 20 additions & 0 deletions i18n-helpers/fuzz/fuzz_targets/xgettext.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#![no_main]

use std::path::PathBuf;
use std::str::FromStr;

use libfuzzer_sys::fuzz_target;
use mdbook::renderer::RenderContext;
use mdbook::Config;
use mdbook_i18n_helpers::xgettext::create_catalog;
use mdbook_i18n_helpers_fuzz::{create_book, BookItem};

fuzz_target!(|inputs: (&str, Vec<BookItem>)| {
let (summary, book_items) = inputs;

let book = create_book(book_items);

let ctx = RenderContext::new(PathBuf::new(), book, Config::from_str("").unwrap(), "");

let _ = create_catalog(&ctx, |_| Ok(summary.to_string()));
});

0 comments on commit cb0ce49

Please sign in to comment.