Parcourir la source

Added restricted file extensions for uploads

tags/3.0.0
Teknikode il y a 2 ans
Parent
révision
bf47978253

+ 1
- 1
Teknik/Areas/API/Controllers/APIv1Controller.cs Voir le fichier

@@ -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" } });
}

+ 1
- 1
Teknik/Areas/Upload/Controllers/UploadController.cs Voir le fichier

@@ -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
- 0
Utilities/Configuration/UploadConfig.cs Voir le fichier

@@ -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
ClamServer = "localhost";
ClamPort = 3310;
RestrictedContentTypes = new List<string>();
RestrictedExtensions = new List<string>();
}
}
}

Chargement…
Annuler
Enregistrer