Implement LBP1 tags, stricter resource checking, and more (#463)

* Add LBP1 tags, more strict resource checking, and more.

* Fix unit tests

* Add more length checking to dependency parser

* Online editor problems

* Fix tests pt 2

* Self code review and fixed digest bugs

* Don't add content length if it was already set

* Fix status endpoint

* Fix review bug and simplify review serialization

* Fix a typo in review serialization

* Remove duplicated code and fix search

* Remove duplicate database call
This commit is contained in:
Josh 2022-08-31 20:38:58 -05:00 committed by GitHub
parent 58c340aff8
commit d640c000aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 735 additions and 209 deletions

View file

@ -4,7 +4,6 @@ using System.Xml.Serialization;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Levels;
using LBPUnion.ProjectLighthouse.PlayerData;
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
using LBPUnion.ProjectLighthouse.Serialization;
using Microsoft.AspNetCore.Mvc;
@ -39,6 +38,12 @@ public class ScoreController : ControllerBase
Score? score = (Score?)serializer.Deserialize(new StringReader(bodyString));
if (score == null) return this.BadRequest();
if (score.PlayerIds.Length == 0) return this.BadRequest();
if (score.Points < 0) return this.BadRequest();
if (score.Type is > 4 or < 1) return this.BadRequest();
SanitizationHelper.SanitizeStringsInClass(score);
if (slotType == "developer") id = await SlotHelper.GetPlaceholderSlotId(this.database, id, SlotType.Developer);
@ -60,6 +65,9 @@ public class ScoreController : ControllerBase
case GameVersion.LittleBigPlanet3:
slot.PlaysLBP3Complete++;
break;
case GameVersion.LittleBigPlanetPSP: break;
case GameVersion.Unknown: break;
default: throw new ArgumentOutOfRangeException();
}
// Submit scores from all players in lobby
@ -110,7 +118,6 @@ public class ScoreController : ControllerBase
[SuppressMessage("ReSharper", "PossibleMultipleEnumeration")]
public async Task<IActionResult> TopScores(string slotType, int slotId, int type, [FromQuery] int pageStart = -1, [FromQuery] int pageSize = 5)
{
// Get username
GameToken? token = await this.database.GameTokenFromRequest(this.Request);
if (token == null) return this.StatusCode(403, "");