Page MenuHomePhorge

D14814.1768460616.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D14814.1768460616.diff

diff --git a/keyserver/src/creators/invite-link-creator.js b/keyserver/src/creators/invite-link-creator.js
--- a/keyserver/src/creators/invite-link-creator.js
+++ b/keyserver/src/creators/invite-link-creator.js
@@ -119,6 +119,8 @@
if (!blobResult.success) {
if (blobResult.reason === 'HASH_IN_USE') {
throw new ServerError('already_in_use');
+ } else if (blobResult.reason === 'OFFENSIVE_WORDS') {
+ throw new ServerError('offensive_words');
} else {
throw new ServerError('unknown_error');
}
diff --git a/lib/utils/blob-service.js b/lib/utils/blob-service.js
--- a/lib/utils/blob-service.js
+++ b/lib/utils/blob-service.js
@@ -73,6 +73,21 @@
return `${urlSafeDeviceID}:${uuid.v4()}`;
}
+async function isBadRequest(
+ response: Response,
+ // if not provided, assume Bad Request check for any reason
+ reason?: string,
+): Promise<boolean> {
+ if (response.status !== 400) {
+ return false;
+ }
+ if (!reason) {
+ return true;
+ }
+ const responseBody = await response.text();
+ return responseBody === reason;
+}
+
export type BlobOperationResult =
| {
+success: true,
@@ -80,7 +95,7 @@
}
| {
+success: false,
- +reason: 'HASH_IN_USE' | 'INVALID_CSAT' | 'OTHER',
+ +reason: 'HASH_IN_USE' | 'INVALID_CSAT' | 'OFFENSIVE_WORDS' | 'OTHER',
+status: number,
+statusText: string,
};
@@ -141,6 +156,14 @@
reason = 'HASH_IN_USE';
} else if (httpResponseIsInvalidCSAT(uploadBlobResponse)) {
reason = 'INVALID_CSAT';
+ } else {
+ const requestWasOffensive = await isBadRequest(
+ uploadBlobResponse,
+ 'offensive_words',
+ );
+ if (requestWasOffensive) {
+ reason = 'OFFENSIVE_WORDS';
+ }
}
return {
diff --git a/services/blob/src/http/errors.rs b/services/blob/src/http/errors.rs
--- a/services/blob/src/http/errors.rs
+++ b/services/blob/src/http/errors.rs
@@ -10,7 +10,7 @@
use crate::constants::error_types;
use crate::database::errors::{BlobDBError, Error as DBError};
use crate::s3::Error as S3Error;
-use crate::service::BlobServiceError;
+use crate::service::{BlobServiceError, InviteLinkError};
pub(super) fn handle_blob_service_error(err: &BlobServiceError) -> HttpError {
trace!("Handling blob service error: {:?}", err);
@@ -77,8 +77,16 @@
ErrorBadRequest("bad request")
}
BlobServiceError::InviteLinkError(invite_link_error) => {
- debug!("Received invite link error: {0}", invite_link_error);
- ErrorBadRequest("bad request")
+ match invite_link_error {
+ InviteLinkError::Offensive => {
+ tracing::info!("Rejected offensive name.");
+ ErrorBadRequest("offensive_words")
+ }
+ _ => {
+ warn!("Received invite link error: {0:?}", invite_link_error);
+ ErrorBadRequest("bad request")
+ }
+ }
}
err => {
error!(

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 15, 7:03 AM (5 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5936617
Default Alt Text
D14814.1768460616.diff (2 KB)

Event Timeline