Move filter to separate config and add more scanning (#603)

* Create .gitattributes

Added a .gitattributes file that excludes the local customWordFilter.txt file from merged updates, allowing server operators to maintain their own word filter list and not have it overwritten.

* Update .gitignore

Added chatCensoredList to gitignore

* Update .gitignore

* Dynamic censor list file changes

Removed .gitattributes file, attempted to make chatCensoredList.txt into a dynamic file loaded at runtime instead.

* Added additional censorship coverage

Censorship now covers:
Level titles
Level descriptions
Reviews
Comments

* Delete chatCensoredList.txt

* Update .gitignore

Co-authored-by: Josh <josh@slendy.pw>

* Update filter verbiage

* Update ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs

Co-authored-by: Josh <josh@slendy.pw>

* Update ProjectLighthouse/Helpers/CensorHelper.cs

Co-authored-by: Josh <josh@slendy.pw>

* Add CensorConfiguration and add more filters

Co-authored-by: Josh <josh@slendy.pw>
This commit is contained in:
HomicidalChicken 2023-01-19 22:24:45 -05:00 committed by GitHub
commit 326b9e5529
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 70 additions and 53 deletions

View file

@ -119,7 +119,9 @@ public class CommentController : ControllerBase
targetId = await this.database.UserIdFromUsername(username!);
}
bool success = await this.database.PostComment(token.UserId, targetId, type, comment.Message);
string filteredText = CensorHelper.FilterMessage(comment.Message);
bool success = await this.database.PostComment(token.UserId, targetId, type, filteredText);
if (success) return this.Ok();
return this.BadRequest();

View file

@ -116,13 +116,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
return this.Ok();
}
string scannedText = CensorHelper.ScanMessage(message);
string filteredText = CensorHelper.FilterMessage(message);
string username = await this.database.UsernameFromGameToken(token);
if (ServerConfiguration.Instance.LogChatFiltering)
Logger.Info($"{username}: {message} / {scannedText}", LogArea.Filter);
Logger.Info($"{username}: {message} / {filteredText}", LogArea.Filter);
return this.Ok(scannedText);
return this.Ok(filteredText);
}
}

View file

@ -107,12 +107,16 @@ public class PublishController : ControllerBase
return this.BadRequest();
}
slot.Description = CensorHelper.FilterMessage(slot.Description);
if (slot.Description.Length > 512)
{
Logger.Warn($"Rejecting level upload, description too long ({slot.Description.Length} characters)", LogArea.Publish);
return this.BadRequest();
}
slot.Name = CensorHelper.FilterMessage(slot.Name);
if (slot.Name.Length > 64)
{
Logger.Warn($"Rejecting level upload, title too long ({slot.Name.Length} characters)", LogArea.Publish);

View file

@ -94,6 +94,8 @@ public class ReviewController : ControllerBase
Review? newReview = await this.DeserializeBody<Review>();
if (newReview == null) return this.BadRequest();
newReview.Text = CensorHelper.FilterMessage(newReview.Text);
if (newReview.Text.Length > 512) return this.BadRequest();
Review? review = await this.database.Reviews.FirstOrDefaultAsync(r => r.SlotId == slotId && r.ReviewerId == token.UserId);