feat(ios,p0): iOS P0 platform, audio fixes, channel UX
This commit is contained in:
@@ -258,8 +258,7 @@ fn is_ipv6_like(s: &str) -> bool {
|
||||
return false;
|
||||
}
|
||||
// At least one non-colon char, all are hex or colon.
|
||||
s.chars().any(|c| c.is_ascii_hexdigit())
|
||||
&& s.chars().all(|c| c.is_ascii_hexdigit() || c == ':')
|
||||
s.chars().any(|c| c.is_ascii_hexdigit()) && s.chars().all(|c| c.is_ascii_hexdigit() || c == ':')
|
||||
}
|
||||
|
||||
fn redact_email(s: &str) -> String {
|
||||
@@ -303,7 +302,13 @@ fn redact_tokens(s: &str) -> String {
|
||||
let mut out = String::with_capacity(s.len());
|
||||
let mut buf = String::new();
|
||||
for ch in s.chars() {
|
||||
if ch.is_ascii_alphanumeric() || ch == '+' || ch == '/' || ch == '=' || ch == '_' || ch == '-' {
|
||||
if ch.is_ascii_alphanumeric()
|
||||
|| ch == '+'
|
||||
|| ch == '/'
|
||||
|| ch == '='
|
||||
|| ch == '_'
|
||||
|| ch == '-'
|
||||
{
|
||||
buf.push(ch);
|
||||
} else {
|
||||
if looks_like_token(&buf) {
|
||||
@@ -352,7 +357,9 @@ impl InMemoryLogSink {
|
||||
pub fn new(capacity: usize, redactor: Redactor) -> Self {
|
||||
Self {
|
||||
capacity,
|
||||
buf: Arc::new(Mutex::new(std::collections::VecDeque::with_capacity(capacity))),
|
||||
buf: Arc::new(Mutex::new(std::collections::VecDeque::with_capacity(
|
||||
capacity,
|
||||
))),
|
||||
redactor,
|
||||
}
|
||||
}
|
||||
@@ -551,6 +558,15 @@ impl Visit for PttBanCheckVisitor {
|
||||
fn record_bool(&mut self, field: &Field, _value: bool) {
|
||||
self.check(field.name());
|
||||
}
|
||||
fn record_f64(&mut self, field: &Field, _value: f64) {
|
||||
self.check(field.name());
|
||||
}
|
||||
fn record_i128(&mut self, field: &Field, _value: i128) {
|
||||
self.check(field.name());
|
||||
}
|
||||
fn record_u128(&mut self, field: &Field, _value: u128) {
|
||||
self.check(field.name());
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@@ -639,7 +655,10 @@ mod tests {
|
||||
#[test]
|
||||
fn redacts_ipv4() {
|
||||
let r = Redactor::default();
|
||||
assert_eq!(r.redact("connect to 192.168.1.1:9987"), "connect to [ip]:9987");
|
||||
assert_eq!(
|
||||
r.redact("connect to 192.168.1.1:9987"),
|
||||
"connect to [ip]:9987"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -653,10 +672,7 @@ mod tests {
|
||||
#[test]
|
||||
fn redacts_email() {
|
||||
let r = Redactor::default();
|
||||
assert_eq!(
|
||||
r.redact("user alice@example.com bug"),
|
||||
"user [email] bug"
|
||||
);
|
||||
assert_eq!(r.redact("user alice@example.com bug"), "user [email] bug");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -780,8 +796,7 @@ mod tests {
|
||||
tracing::info!(key_code = 42, "banned record must drop");
|
||||
tracing::info!(backend_id = "linux-portal", "safe record must pass");
|
||||
});
|
||||
let exported =
|
||||
DiagnosticExport::from_sink(&sink, vec![("k".into(), "v".into())]).unwrap();
|
||||
let exported = DiagnosticExport::from_sink(&sink, vec![("k".into(), "v".into())]).unwrap();
|
||||
let text = exported.to_text();
|
||||
assert!(
|
||||
!text.contains("banned record must drop"),
|
||||
@@ -792,4 +807,70 @@ mod tests {
|
||||
"sanitiser must forward the safe record to the inner layer"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn banned_field_f64_is_caught() {
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
|
||||
let secrets = KnownSecretRegistry::default();
|
||||
let redactor = Redactor::with_secrets(secrets);
|
||||
let sink = InMemoryLogSink::new(16, redactor);
|
||||
let inner = RedactingLogLayer::new(sink.clone());
|
||||
let sanitised = PttSanitizer::wrap(inner);
|
||||
let subscriber = tracing_subscriber::registry().with(sanitised);
|
||||
|
||||
tracing::subscriber::with_default(subscriber, || {
|
||||
tracing::info!(key_code = 42.5_f64, "f64 banned record must drop");
|
||||
tracing::info!(backend_id = "linux-portal", "safe record must pass");
|
||||
});
|
||||
|
||||
let exported = DiagnosticExport::from_sink(&sink, vec![("k".into(), "v".into())]).unwrap();
|
||||
let text = exported.to_text();
|
||||
assert!(!text.contains("f64 banned record must drop"));
|
||||
assert!(text.contains("safe record must pass"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn banned_field_i128_is_caught() {
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
|
||||
let secrets = KnownSecretRegistry::default();
|
||||
let redactor = Redactor::with_secrets(secrets);
|
||||
let sink = InMemoryLogSink::new(16, redactor);
|
||||
let inner = RedactingLogLayer::new(sink.clone());
|
||||
let sanitised = PttSanitizer::wrap(inner);
|
||||
let subscriber = tracing_subscriber::registry().with(sanitised);
|
||||
|
||||
tracing::subscriber::with_default(subscriber, || {
|
||||
tracing::info!(scan_code = 42_i128, "i128 banned record must drop");
|
||||
tracing::info!(backend_id = "linux-portal", "safe record must pass");
|
||||
});
|
||||
|
||||
let exported = DiagnosticExport::from_sink(&sink, vec![("k".into(), "v".into())]).unwrap();
|
||||
let text = exported.to_text();
|
||||
assert!(!text.contains("i128 banned record must drop"));
|
||||
assert!(text.contains("safe record must pass"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn banned_field_u128_is_caught() {
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
|
||||
let secrets = KnownSecretRegistry::default();
|
||||
let redactor = Redactor::with_secrets(secrets);
|
||||
let sink = InMemoryLogSink::new(16, redactor);
|
||||
let inner = RedactingLogLayer::new(sink.clone());
|
||||
let sanitised = PttSanitizer::wrap(inner);
|
||||
let subscriber = tracing_subscriber::registry().with(sanitised);
|
||||
|
||||
tracing::subscriber::with_default(subscriber, || {
|
||||
tracing::info!(virtual_key = 42_u128, "u128 banned record must drop");
|
||||
tracing::info!(backend_id = "linux-portal", "safe record must pass");
|
||||
});
|
||||
|
||||
let exported = DiagnosticExport::from_sink(&sink, vec![("k".into(), "v".into())]).unwrap();
|
||||
let text = exported.to_text();
|
||||
assert!(!text.contains("u128 banned record must drop"));
|
||||
assert!(text.contains("safe record must pass"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user