Browse Source

Added restricted file extensions for uploads

pull/111/head
Teknikode 5 years ago
parent
commit
bf47978253
  1. 2
      Teknik/Areas/API/Controllers/APIv1Controller.cs
  2. 2
      Teknik/Areas/Upload/Controllers/UploadController.cs
  3. 2
      Utilities/Configuration/UploadConfig.cs

2
Teknik/Areas/API/Controllers/APIv1Controller.cs

@ -90,7 +90,7 @@ namespace Teknik.Areas.API.Controllers @@ -90,7 +90,7 @@ namespace Teknik.Areas.API.Controllers
// Check content type restrictions (Only for encrypting server side
if (model.encrypt || !string.IsNullOrEmpty(model.key))
{
if (Config.UploadConfig.RestrictedContentTypes.Contains(model.contentType))
if (Config.UploadConfig.RestrictedContentTypes.Contains(model.contentType) || Config.UploadConfig.RestrictedExtensions.Contains(fileExt))
{
return Json(new { error = new { message = "File Type Not Allowed" } });
}

2
Teknik/Areas/Upload/Controllers/UploadController.cs

@ -88,7 +88,7 @@ namespace Teknik.Areas.Upload.Controllers @@ -88,7 +88,7 @@ namespace Teknik.Areas.Upload.Controllers
// Check content type restrictions (Only for encrypting server side
if (encrypt)
{
if (Config.UploadConfig.RestrictedContentTypes.Contains(fileType))
if (Config.UploadConfig.RestrictedContentTypes.Contains(fileType) || Config.UploadConfig.RestrictedExtensions.Contains(fileExt))
{
return Json(new { error = new { message = "File Type Not Allowed" } });
}

2
Utilities/Configuration/UploadConfig.cs

@ -35,6 +35,7 @@ namespace Teknik.Configuration @@ -35,6 +35,7 @@ namespace Teknik.Configuration
public int ClamPort { get; set; }
// Content Type Restrictions
public List<string> RestrictedContentTypes { get; set; }
public List<string> RestrictedExtensions { get; set; }
public UploadConfig()
{
@ -61,6 +62,7 @@ namespace Teknik.Configuration @@ -61,6 +62,7 @@ namespace Teknik.Configuration
ClamServer = "localhost";
ClamPort = 3310;
RestrictedContentTypes = new List<string>();
RestrictedExtensions = new List<string>();
}
}
}

Loading…
Cancel
Save