use super::*;
#[test]
fn output_flag_rejects_format_selector() {
assert!(paths("gh pr list --output json").is_empty());
assert!(paths("kubectl get pods --output=yaml").is_empty());
assert!(paths("mytool --output summary").is_empty());
assert_eq!(
paths("mytool --output report.json"),
vec![("report.json".to_string(), "flag-output")]
);
assert_eq!(
paths("mytool --output=/tmp/out"),
vec![("/tmp/out".to_string(), "flag-output")]
);
}
#[test]
fn output_flag_format_selector_edge_forms() {
assert!(paths("kubectl get pods --out=wide").is_empty());
assert!(paths("tool --logfile=none").is_empty());
assert!(paths("tool --output --verbose").is_empty());
assert_eq!(
paths("tool --output ./json"),
vec![("./json".to_string(), "flag-output")]
);
}
#[test]
fn curl_dash_o_output_caught() {
assert_eq!(
paths("curl -s https://api.example.com/d -o /tmp/x.json"),
vec![("/tmp/x.json".to_string(), "curl")]
);
}
#[test]
fn curl_long_output_flag_both_forms() {
assert_eq!(
paths("curl URL --output /tmp/a.json"),
vec![("/tmp/a.json".to_string(), "flag-output")]
);
assert_eq!(
paths("curl URL --output=/tmp/b.json"),
vec![("/tmp/b.json".to_string(), "flag-output")]
);
}
#[test]
fn curl_capital_o_no_path_is_skipped() {
assert!(paths("curl -O https://example.com/file.tar.gz").is_empty());
assert!(paths("curl -sO https://example.com/x").is_empty());
}
#[test]
fn wget_capital_o_output_caught() {
assert_eq!(
paths("wget -O /tmp/x.bin https://example.com/x"),
vec![("/tmp/x.bin".to_string(), "wget")]
);
}
#[test]
fn wget_output_document_caught() {
assert_eq!(
paths("wget --output-document /tmp/y.bin https://example.com/y"),
vec![("/tmp/y.bin".to_string(), "wget")]
);
}
#[test]
fn junit_xml_flag_both_dashes_caught() {
assert_eq!(
paths("pytest --junit-xml=/tmp/r.xml"),
vec![("/tmp/r.xml".to_string(), "flag-output")]
);
assert_eq!(
paths("pytest --junitxml=/tmp/r2.xml"),
vec![("/tmp/r2.xml".to_string(), "flag-output")]
);
}
#[test]
fn report_path_flag_spaced_caught() {
assert_eq!(
paths("gitleaks detect --report-path /tmp/leaks.json"),
vec![("/tmp/leaks.json".to_string(), "flag-output")]
);
}
#[test]
fn generic_output_flags_caught() {
assert_eq!(
paths("sometool --output=/tmp/o.txt"),
vec![("/tmp/o.txt".to_string(), "flag-output")]
);
assert_eq!(
paths("sometool --logfile /tmp/run.log"),
vec![("/tmp/run.log".to_string(), "flag-output")]
);
}
#[test]
fn dd_of_output_caught() {
assert_eq!(
paths("dd if=/dev/zero of=/tmp/x.bin bs=1M count=4"),
vec![("/tmp/x.bin".to_string(), "dd")]
);
}
#[test]
fn dd_of_dev_null_dropped() {
assert!(paths("dd if=/tmp/src of=/dev/null").is_empty());
}
#[test]
fn zip_dest_is_first_operand_only() {
assert_eq!(
paths("zip /tmp/x.zip a b c"),
vec![("/tmp/x.zip".to_string(), "zip")]
);
assert_eq!(
paths("zip -r /tmp/y.zip dir/"),
vec![("/tmp/y.zip".to_string(), "zip")]
);
}