feat: deploy cloud-only RMM and verify audited APT diagnostics
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-13 13:49:11 +01:00
parent 6c3203d725
commit fbef0e4e2f
48 changed files with 3125 additions and 34 deletions
+69 -3
View File
@@ -15,7 +15,39 @@ pub const MAX_BODY: usize = 1024 * 1024;
pub const MAX_BATCH: usize = 16;
const MAX_INCOMING: usize = 32;
/// No environment proxy trust, redirects, alternate names or system CA fallback.
/// One configured DNS identity for URLs, SNI and certificate verification.
/// RMM_CONNECT_ADDR changes only the TCP destination, never this identity.
pub fn server_name() -> Result<String> {
let name = match std::env::var("RMM_SERVER_NAME") {
Ok(name) => name,
Err(std::env::VarError::NotPresent) => "rmm-dev.internal".into(),
Err(error) => return Err(error.into()),
};
validate_server_name(&name)?;
Ok(name)
}
fn validate_server_name(name: &str) -> Result<()> {
ensure!(
!name.is_empty()
&& name.len() <= 253
&& name.is_ascii()
&& name.parse::<std::net::IpAddr>().is_err()
&& name.split('.').all(|label| {
!label.is_empty()
&& label.len() <= 63
&& label.as_bytes()[0].is_ascii_alphanumeric()
&& label.as_bytes()[label.len() - 1].is_ascii_alphanumeric()
&& label
.bytes()
.all(|b| b.is_ascii_alphanumeric() || b == b'-')
}),
"INVALID_SERVER_NAME"
);
Ok(())
}
/// No environment proxy trust, redirects or system CA fallback.
/// `address` is a parsed RMM_CONNECT_ADDR; it overrides TCP only, never SNI.
pub fn mtls_client(address: SocketAddr, ca: &[u8], cert: &[u8], key: &[u8]) -> Result<Client> {
ensure!(
@@ -31,7 +63,7 @@ pub fn mtls_client(address: SocketAddr, ca: &[u8], cert: &[u8], key: &[u8]) -> R
.tls_built_in_root_certs(false)
.add_root_certificate(reqwest::Certificate::from_pem(ca)?)
.identity(reqwest::Identity::from_pem(&identity)?)
.resolve("rmm-dev.internal", address)
.resolve(&server_name()?, address)
.no_proxy()
.redirect(reqwest::redirect::Policy::none())
.connect_timeout(Duration::from_secs(10))
@@ -124,7 +156,7 @@ impl HttpsChannel {
);
let mut channel = Self {
client,
origin: format!("https://rmm-dev.internal:{}", address.port()),
origin: format!("https://{}:{}", server_name()?, address.port()),
agent: hello.agent_id.clone(),
enrollment: hello.enrollment_generation,
generation: 0,
@@ -324,3 +356,37 @@ impl HttpsChannel {
Ok(())
}
}
#[cfg(test)]
mod endpoint_tests {
use super::*;
#[test]
fn configured_dns_identity_cannot_inject_a_url_or_disable_name_checks() {
for name in ["rmm-dev.internal", "discovery.ease-technologies.de"] {
assert!(validate_server_name(name).is_ok());
}
for name in [
"",
"127.0.0.1",
"::1",
"host:443",
"https://host",
"user@host",
"host/path",
"host?query",
"host#fragment",
".host",
"host.",
"a..b",
"-host.example",
"host-.example",
"white space",
"\nlocalhost",
"höst.example",
] {
assert!(validate_server_name(name).is_err(), "{name:?}");
}
assert!(validate_server_name(&format!("{}.example", "a".repeat(64))).is_err());
}
}