Fix more koko suggestions

This commit is contained in:
FeTetra 2025-03-01 22:43:50 -05:00
commit 0d3e1391ed
3 changed files with 19 additions and 19 deletions

View file

@ -35,18 +35,18 @@ public class ResourcesController : ControllerBase
} }
[HttpGet("r/{hash}")] [HttpGet("r/{hash}")]
public Task<IActionResult> GetResource(string hash) public IActionResult GetResource(string hash)
{ {
string path = FileHelper.GetResourcePath(hash); string path = FileHelper.GetResourcePath(hash);
string fullPath = Path.GetFullPath(path); string fullPath = Path.GetFullPath(path);
// Prevent directory traversal attacks // Prevent directory traversal attacks
if (!fullPath.StartsWith(FileHelper.FullResourcePath)) return Task.FromResult<IActionResult>(this.BadRequest()); if (!fullPath.StartsWith(FileHelper.FullResourcePath)) return this.BadRequest();
if (FileHelper.ResourceExists(hash)) return Task.FromResult<IActionResult>(this.File(IOFile.OpenRead(path), "application/octet-stream")); if (FileHelper.ResourceExists(hash)) return this.File(IOFile.OpenRead(path), "application/octet-stream");
return Task.FromResult<IActionResult>(this.NotFound()); return this.NotFound();
} }
[HttpPost("upload/{hash}/unattributed")] [HttpPost("upload/{hash}/unattributed")]

View file

@ -6,21 +6,21 @@ namespace LBPUnion.ProjectLighthouse.Configuration;
public class EmailEnforcementConfiguration : ConfigurationBase<EmailEnforcementConfiguration> public class EmailEnforcementConfiguration : ConfigurationBase<EmailEnforcementConfiguration>
{ {
public override int ConfigVersion { get; set; } = 4; public override int ConfigVersion { get; set; } = 1;
public override string ConfigName { get; set; } = "enforce-email.yml"; public override string ConfigName { get; set; } = "enforce-email.yml";
public override bool NeedsConfiguration { get; set; } = false; public override bool NeedsConfiguration { get; set; } = false;
public bool EnableEmailEnforcement => false; public bool EnableEmailEnforcement { get; set; } = false;
public bool EnableEmailBlacklist => false; public bool EnableEmailBlacklist { get; set; } = false;
// No blacklist by default, add path to blacklist // No blacklist by default, add path to blacklist
public string BlacklistFilePath => ""; public string BlacklistFilePath { get; set; } = "";
// Endpoints to be blocked // Endpoints to be blocked
// This is kind of a random list so some may need to be added or removed // This is kind of a random list so some may need to be added or removed
public HashSet<string> BlockedEndpoints => new() public HashSet<string> BlockedEndpoints { get; set; } = new()
{ {
// Comments // Comments
"rateUserComment", "rateUserComment",

View file

@ -89,17 +89,17 @@ public static class SMTPHelper
return false; return false;
// Don't even bother if there are no domains in blacklist (AKA file path is empty/invalid, or file itself is empty) // Don't even bother if there are no domains in blacklist (AKA file path is empty/invalid, or file itself is empty)
if (ServerConfiguration.Instance.EmailEnforcement.EnableEmailBlacklist && blacklistedDomains.Count > 0) if (!ServerConfiguration.Instance.EmailEnforcement.EnableEmailBlacklist || blacklistedDomains.Count <= 0)
{ return true;
// Get domain by splitting at '@' character
string domain = email.Split('@')[1];
// Return false if domain is found in blacklist // Get domain by splitting at '@' character
if (blacklistedDomains.Contains(domain)) string domain = email.Split('@')[1];
{
Logger.Info($"Invalid email address {email} submitted by user.", LogArea.Email); // Return false if domain is found in blacklist
return false; if (blacklistedDomains.Contains(domain))
} {
Logger.Info($"Invalid email address {email} submitted by user.", LogArea.Email);
return false;
} }
return true; return true;