relay_event_normalization::span::description

Function scrub_host

source
pub fn scrub_host<'a>(
    host: Host<&'a str>,
    allow_list: &'a [String],
) -> Cow<'a, str>
Expand description

Scrub a Host object.

Domain names are run through a scrubber. All IP addresses except well known ones are replaced with a scrubbed variant. Returns the scrubbed value as a string.

ยงExamples

use url::{Host, Url};
use std::net::{Ipv4Addr, Ipv6Addr};
use relay_event_normalization::span::description::scrub_host;

assert_eq!(scrub_host(Host::Domain("foo.bar.baz"), &[]), "*.bar.baz");
assert_eq!(scrub_host(Host::Ipv4(Ipv4Addr::LOCALHOST), &[]), "127.0.0.1");
assert_eq!(scrub_host(Host::Ipv4(Ipv4Addr::new(8, 8, 8, 8)), &[String::from("8.8.8.8")]), "8.8.8.8");