Skip to content
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

Fuzz more of gix_url::Url #1209

Merged
merged 2 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gix-url/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2021"
cargo-fuzz = true

[dependencies]
anyhow = "1.0.76"
libfuzzer-sys = "0.4"

[dependencies.gix-url]
Expand Down
25 changes: 24 additions & 1 deletion gix-url/fuzz/fuzz_targets/parse.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
#![no_main]
use anyhow::Result;
use libfuzzer_sys::fuzz_target;
use std::hint::black_box;
use std::path::Path;

fn fuzz(data: &[u8]) -> Result<()> {
let url = gix_url::parse(data.into())?;
_ = black_box(url.user());
_ = black_box(url.password());
_ = black_box(url.password());
if let Some(safe_host) = black_box(url.host_argument_safe()) {
// Ensure malicious host paths can't be returned see;
// https://secure.phabricator.com/T12961
assert!(!safe_host.starts_with("ssh://-"));
}
_ = black_box(url.path_argument_safe());
_ = black_box(url.path_is_root());
_ = black_box(url.port_or_default());
_ = black_box(url.canonicalized(Path::new("/cwd")));
_ = black_box(url.to_bstring());

_ = black_box(gix_url::expand_path::parse(data.into()));
Ok(())
}

fuzz_target!(|data: &[u8]| {
let _a = gix_url::parse(data.into());
_ = black_box(fuzz(data));
});
Loading