diff --git a/compliance-core/src/net_guard.rs b/compliance-core/src/net_guard.rs index 1c8749e..0ab8674 100644 --- a/compliance-core/src/net_guard.rs +++ b/compliance-core/src/net_guard.rs @@ -59,8 +59,10 @@ pub enum NetGuardError { const HTTP_SCHEMES: &[&str] = &["http", "https"]; /// Schemes accepted for a git remote. `file://` and `git://` are refused: the /// first reads the agent's own disk (including other tenants' checkouts), the -/// second is unauthenticated and cleartext. -const GIT_SCHEMES: &[&str] = &["http", "https", "ssh"]; +/// second is unauthenticated and cleartext. `ssh://` is refused too, because +/// the agent holds no git SSH key — see `pipeline::git::reject_ssh_url`, which +/// gives the same answer for the scp-style form that carries no scheme. +const GIT_SCHEMES: &[&str] = &["http", "https"]; /// Host suffixes that only mean something inside a private network. const INTERNAL_SUFFIXES: &[&str] = &[ @@ -451,7 +453,7 @@ mod tests { } #[test] - fn git_urls_refuse_file_and_git_schemes_but_allow_ssh() { + fn git_urls_refuse_file_git_and_ssh_schemes() { assert!(guard() .check_git_url("file:///tmp/compliance-scanner/repos/other-tenant/app") .is_err()); @@ -462,9 +464,11 @@ mod tests { assert!(guard() .check_git_url("https://example.com/org/repo.git") .is_ok()); + // The agent has no SSH key to offer, so an SSH remote could only + // authenticate as somebody else. assert!(guard() .check_git_url("ssh://git@example.com:22222/org/repo.git") - .is_ok()); + .is_err()); // …but not to an internal host. assert!(guard().check_git_url("https://gitea/org/repo.git").is_err()); }