Skip to content

Commit 902367f

Browse files
committed
Test that leading-- host names aren't used in -G check
This test was absent before, but seems important to add to verify that the code there was correct (it was), but also because I plan to refactor that code to use `host_as_argument` rather than the older (in some cases potentially ambiguous) `host_argument_safe`. This is specific to the case where a command like `ssh -G` -- but where `ssh` is an uncertain command such that gix-transport tries to figure out what is -- is used. A netloc is passed as part of that, but the netloc used consists only of a host and not a username, even when this is a step in a longer process that will later use (and check the safety of) the username. So only the host has to be checked (at that stage) to make sure it cannot masquerade as an option argument.
1 parent 524739b commit 902367f

File tree

1 file changed

+6
-1
lines changed
  • gix-transport/src/client/blocking_io

1 file changed

+6
-1
lines changed

gix-transport/src/client/blocking_io/file.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,13 @@ mod tests {
316316
"user@-oProxyCommand=open$IFS-aCalculator:username/repo",
317317
] {
318318
let url = gix_url::parse((*url).into()).expect("valid url");
319+
let options = ssh::connect::Options {
320+
command: Some("unrecognized".into()),
321+
disallow_shell: false,
322+
kind: None,
323+
};
319324
assert!(matches!(
320-
ssh::connect(url, Protocol::V1, Default::default(), false),
325+
ssh::connect(url, Protocol::V1, options, false),
321326
Err(ssh::Error::AmbiguousHostName { host }) if host == "-oProxyCommand=open$IFS-aCalculator",
322327
));
323328
}

0 commit comments

Comments
 (0)