Fix missing filtering, filter inconsistencies, and filter logging (#1082)
Some checks are pending
Continuous Integration / Build & Test (push) Waiting to run
Upload Translations to Crowdin / crowdin-sync (push) Waiting to run
Build Docker Image / Build and Publish (push) Waiting to run
Qodana / qodana (push) Waiting to run

* Fix missing filtering, filter inconsistencies, and filter logging

* Remove unused import and replace removed logger

* Make filter log arguments optional

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

Co-authored-by: sudokoko <sudo@koko.rip>

* Update ProjectLighthouse.Servers.Website/Pages/Debug/FilterTestPage.cshtml.cs

Co-authored-by: sudokoko <sudo@koko.rip>

* Replace filter location strings with enum

* Rename enum to FilterLocation for readability

---------

Co-authored-by: sudokoko <sudo@koko.rip>
This commit is contained in:
FeTetra 2024-12-10 20:01:37 -05:00 committed by GitHub
commit f059b20489
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 59 additions and 38 deletions

View file

@ -10,6 +10,7 @@ using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Filter;
using LBPUnion.ProjectLighthouse.Types.Resources;
using LBPUnion.ProjectLighthouse.Types.Serialization;
using LBPUnion.ProjectLighthouse.Types.Users;
@ -142,7 +143,7 @@ public class PublishController : ControllerBase
// Yes Rider, this isn't null
Debug.Assert(slot.Resources != null, "slot.ResourceList != null");
slot.Name = CensorHelper.FilterMessage(slot.Name);
slot.Name = CensorHelper.FilterMessage(slot.Name, FilterLocation.SlotName, user.Username);
if (slot.Name.Length > 64)
{
@ -153,7 +154,7 @@ public class PublishController : ControllerBase
return this.BadRequest();
}
slot.Description = CensorHelper.FilterMessage(slot.Description);
slot.Description = CensorHelper.FilterMessage(slot.Description, FilterLocation.SlotDescription, user.Username);
if (slot.Description.Length > 512)
{

View file

@ -99,7 +99,9 @@ public class ReviewController : ControllerBase
GameReview? newReview = await this.DeserializeBody<GameReview>();
if (newReview == null) return this.BadRequest();
newReview.Text = CensorHelper.FilterMessage(newReview.Text);
// Temporary fix until this can be refactored to use a UserEntity properly
string username = await this.database.UsernameFromGameToken(token);
newReview.Text = CensorHelper.FilterMessage(newReview.Text, FilterLocation.SlotReview, username);
if (newReview.Text.Length > 512) return this.BadRequest();