mirror of
https://github.com/dani-garcia/vaultwarden.wiki.git
synced 2026-11-05 04:48:37 +02:00
Escape request values in log messages (#7921)
This commit is contained in:
1 parent
5d870b796f
commit
6ed6921cc2
9 files changed
+41
-24
No files matched your search
@@ -1148,7 +1148,11 @@ async fn post_email_token(data: Json<EmailTokenData>, headers: Headers, conn: Db
|
||||
error!("Error sending change-email email: {e:#?}");
|
||||
}
|
||||
} else {
|
||||
debug!("Email change request for user ({}) to email ({}) with token ({token})", user.uuid, data.new_email);
|
||||
debug!(
|
||||
"Email change request for user ({}) to email ({}) with token ({token})",
|
||||
user.uuid,
|
||||
data.new_email.escape_debug()
|
||||
);
|
||||
}
|
||||
|
||||
user.email_new = Some(data.new_email);
|
||||
@@ -1403,7 +1407,7 @@ async fn password_hint(data: Json<PasswordHintData>, ip: ClientIp, conn: DbConn)
|
||||
mail::send_password_hint(email, hint).await?;
|
||||
Ok(())
|
||||
} else if let Some(hint) = hint {
|
||||
err!(format!("Your password hint is: {hint}"));
|
||||
err_silent!(format!("Your password hint is: {hint}"));
|
||||
} else {
|
||||
err!(NO_HINT);
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ pub async fn update_cipher_from_data(
|
||||
{
|
||||
match NaiveDateTime::parse_from_str(&dt, "%+") {
|
||||
// ISO 8601 format
|
||||
Err(err) => warn!("Error parsing LastKnownRevisionDate '{dt}': {err}"),
|
||||
Err(err) => warn!("Error parsing LastKnownRevisionDate '{}': {err}", dt.escape_debug()),
|
||||
Ok(dt) if cipher.updated_at.signed_duration_since(dt).num_seconds() > 1 => {
|
||||
err!("The client copy of this cipher is out of date. Resync the client and try again.")
|
||||
}
|
||||
@@ -521,7 +521,7 @@ pub async fn update_cipher_from_data(
|
||||
// A missing attachment means it was removed via an other client.
|
||||
// Also the Desktop Client supports removing attachments and save an update afterwards.
|
||||
// Bitwarden it self ignores these mismatches server side.
|
||||
warn!("Attachment {id} doesn't exist");
|
||||
warn!("Attachment {} doesn't exist", id.escape_debug());
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -580,7 +580,7 @@ pub async fn update_cipher_from_data(
|
||||
match data.archived_date {
|
||||
Some(dt_str) => match NaiveDateTime::parse_from_str(&dt_str, "%+") {
|
||||
Ok(dt) => cipher.set_archived_at(dt, &headers.user.uuid, conn).await?,
|
||||
Err(err) => warn!("Error parsing ArchivedDate '{dt_str}': {err}"),
|
||||
Err(err) => warn!("Error parsing ArchivedDate '{}': {err}", dt_str.escape_debug()),
|
||||
},
|
||||
None => cipher.unarchive(&headers.user.uuid, conn).await?,
|
||||
}
|
||||
|
||||
@@ -131,13 +131,16 @@ impl FullCollectionData {
|
||||
let org_groups = Group::find_by_organization(org_id, conn).await;
|
||||
let org_group_ids: HashSet<&GroupId> = org_groups.iter().map(|c| &c.uuid).collect();
|
||||
if let Some(e) = self.groups.iter().find(|g| !org_group_ids.contains(&g.id)) {
|
||||
err!("Invalid group", format!("Group {} does not belong to organization {}!", e.id, org_id))
|
||||
err!("Invalid group", format!("Group {} does not belong to organization {}!", e.id.escape_debug(), org_id))
|
||||
}
|
||||
|
||||
let org_memberships = Membership::find_by_org(org_id, conn).await;
|
||||
let org_membership_ids: HashSet<&MembershipId> = org_memberships.iter().map(|m| &m.uuid).collect();
|
||||
if let Some(e) = self.users.iter().find(|m| !org_membership_ids.contains(&m.id)) {
|
||||
err!("Invalid member", format!("Member {} does not belong to organization {}!", e.id, org_id))
|
||||
err!(
|
||||
"Invalid member",
|
||||
format!("Member {} does not belong to organization {}!", e.id.escape_debug(), org_id)
|
||||
)
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -552,7 +555,7 @@ async fn post_bulk_access_collections(
|
||||
let org_groups = Group::find_by_organization(&org_id, &conn).await;
|
||||
let org_group_ids: HashSet<&GroupId> = org_groups.iter().map(|g| &g.uuid).collect();
|
||||
if let Some(g) = data.groups.iter().find(|g| !org_group_ids.contains(&g.id)) {
|
||||
err!("Invalid group", format!("Group {} does not belong to organization {}!", g.id, org_id))
|
||||
err!("Invalid group", format!("Group {} does not belong to organization {}!", g.id.escape_debug(), org_id))
|
||||
}
|
||||
|
||||
for col_id in data.collection_ids {
|
||||
@@ -975,13 +978,16 @@ impl InviteData {
|
||||
let org_collections = Collection::find_by_organization(org_id, conn).await;
|
||||
let org_collection_ids: HashSet<&CollectionId> = org_collections.iter().map(|c| &c.uuid).collect();
|
||||
if let Some(e) = self.collections.iter().flatten().find(|c| !org_collection_ids.contains(&c.id)) {
|
||||
err!("Invalid collection", format!("Collection {} does not belong to organization {}!", e.id, org_id))
|
||||
err!(
|
||||
"Invalid collection",
|
||||
format!("Collection {} does not belong to organization {}!", e.id.escape_debug(), org_id)
|
||||
)
|
||||
}
|
||||
|
||||
let org_groups = Group::find_by_organization(org_id, conn).await;
|
||||
let org_group_ids: HashSet<&GroupId> = org_groups.iter().map(|c| &c.uuid).collect();
|
||||
if let Some(e) = self.groups.iter().find(|g| !org_group_ids.contains(g)) {
|
||||
err!("Invalid group", format!("Group {} does not belong to organization {}!", e, org_id))
|
||||
err!("Invalid group", format!("Group {} does not belong to organization {}!", e.escape_debug(), org_id))
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1157,7 +1163,7 @@ async fn bulk_reinvite_members(
|
||||
let err_msg = match reinvite_member_impl(&org_id, &member_id, &headers.user.email, &conn).await {
|
||||
Ok(()) => String::new(),
|
||||
Err(e) => {
|
||||
warn!("Unable to reinvite member {member_id}: {e:?}");
|
||||
warn!("Unable to reinvite member {}: {e:?}", member_id.escape_debug());
|
||||
e.message().to_owned()
|
||||
}
|
||||
};
|
||||
@@ -1333,7 +1339,7 @@ async fn bulk_confirm_invite(
|
||||
let err_msg = match confirm_invite_impl(&org_id, &member_id, &user_key, &headers, &conn, &nt).await {
|
||||
Ok(()) => String::new(),
|
||||
Err(e) => {
|
||||
warn!("Unable to confirm member {member_id}: {e:?}");
|
||||
warn!("Unable to confirm member {}: {e:?}", member_id.escape_debug());
|
||||
e.message().to_owned()
|
||||
}
|
||||
};
|
||||
@@ -1617,7 +1623,7 @@ async fn bulk_delete_member(
|
||||
let err_msg = match delete_member_impl(&org_id, &member_id, &headers, &conn, &nt).await {
|
||||
Ok(()) => String::new(),
|
||||
Err(e) => {
|
||||
warn!("Unable to delete member {member_id}: {e:?}");
|
||||
warn!("Unable to delete member {}: {e:?}", member_id.escape_debug());
|
||||
e.message().to_owned()
|
||||
}
|
||||
};
|
||||
@@ -2286,7 +2292,7 @@ async fn bulk_revoke_members(
|
||||
let err_msg = match revoke_member_impl(&org_id, &member_id, &headers, &conn).await {
|
||||
Ok(()) => String::new(),
|
||||
Err(e) => {
|
||||
warn!("Unable to revoke member {member_id}: {e:?}");
|
||||
warn!("Unable to revoke member {}: {e:?}", member_id.escape_debug());
|
||||
e.message().to_owned()
|
||||
}
|
||||
};
|
||||
@@ -2392,7 +2398,7 @@ async fn bulk_restore_members(
|
||||
let err_msg = match restore_member_impl(&org_id, &member_id, &headers, &conn).await {
|
||||
Ok(()) => String::new(),
|
||||
Err(e) => {
|
||||
warn!("Unable to restore member {member_id}: {e:?}");
|
||||
warn!("Unable to restore member {}: {e:?}", member_id.escape_debug());
|
||||
e.message().to_owned()
|
||||
}
|
||||
};
|
||||
@@ -2547,13 +2553,16 @@ impl GroupRequest {
|
||||
let org_collections = Collection::find_by_organization(org_id, conn).await;
|
||||
let org_collection_ids: HashSet<&CollectionId> = org_collections.iter().map(|c| &c.uuid).collect();
|
||||
if let Some(e) = self.collections.iter().find(|c| !org_collection_ids.contains(&c.id)) {
|
||||
err!("Invalid collection", format!("Collection {} does not belong to organization {}!", e.id, org_id))
|
||||
err!(
|
||||
"Invalid collection",
|
||||
format!("Collection {} does not belong to organization {}!", e.id.escape_debug(), org_id)
|
||||
)
|
||||
}
|
||||
|
||||
let org_memberships = Membership::find_by_org(org_id, conn).await;
|
||||
let org_membership_ids: HashSet<&MembershipId> = org_memberships.iter().map(|m| &m.uuid).collect();
|
||||
if let Some(e) = self.users.iter().find(|m| !org_membership_ids.contains(m)) {
|
||||
err!("Invalid member", format!("Member {} does not belong to organization {}!", e, org_id))
|
||||
err!("Invalid member", format!("Member {} does not belong to organization {}!", e.escape_debug(), org_id))
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in new issue
Block a user