Skip to content

Commit 7d0d519

Browse files
committed
update: Mask all endpoints
1 parent f7b4afd commit 7d0d519

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/alerts/target.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,23 +164,35 @@ impl Target {
164164
})
165165
}
166166
TargetType::Other(other_web_hook) => {
167+
let endpoint = other_web_hook.endpoint.to_string();
168+
let masked_endpoint = if endpoint.len() > 20 {
169+
format!("{}********", &endpoint[..20])
170+
} else {
171+
"********".to_string()
172+
};
167173
json!({
168174
"name":self.name,
169175
"type":"webhook",
170-
"endpoint":other_web_hook.endpoint,
176+
"endpoint":masked_endpoint,
171177
"headers":other_web_hook.headers,
172178
"skipTlsCheck":other_web_hook.skip_tls_check,
173179
"notificationConfig":self.notification_config,
174180
"id":self.id
175181
})
176182
}
177183
TargetType::AlertManager(alert_manager) => {
184+
let endpoint = alert_manager.endpoint.to_string();
185+
let masked_endpoint = if endpoint.len() > 20 {
186+
format!("{}********", &endpoint[..20])
187+
} else {
188+
"********".to_string()
189+
};
178190
if let Some(auth) = alert_manager.auth {
179191
let password = "********";
180192
json!({
181193
"name":self.name,
182194
"type":"webhook",
183-
"endpoint":alert_manager.endpoint,
195+
"endpoint":masked_endpoint,
184196
"username":auth.username,
185197
"password":password,
186198
"skipTlsCheck":alert_manager.skip_tls_check,
@@ -191,7 +203,7 @@ impl Target {
191203
json!({
192204
"name":self.name,
193205
"type":"webhook",
194-
"endpoint":alert_manager.endpoint,
206+
"endpoint":masked_endpoint,
195207
"username":Value::Null,
196208
"password":Value::Null,
197209
"skipTlsCheck":alert_manager.skip_tls_check,

0 commit comments

Comments
 (0)