mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added restricted content types parameter for uploads
This commit is contained in:
parent
1fe63a06bd
commit
e6589638bd
@ -87,6 +87,15 @@ 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))
|
||||
{
|
||||
return Json(new { error = new { message = "File Type Not Allowed" } });
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the key size and block size if empty
|
||||
if (model.keySize <= 0)
|
||||
model.keySize = Config.UploadConfig.KeySize;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using nClam;
|
||||
using nClam;
|
||||
using Piwik.Tracker;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -84,6 +84,15 @@ namespace Teknik.Areas.Upload.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
// Check content type restrictions (Only for encrypting server side
|
||||
if (encrypt)
|
||||
{
|
||||
if (Config.UploadConfig.RestrictedContentTypes.Contains(fileType))
|
||||
{
|
||||
return Json(new { error = new { message = "File Type Not Allowed" } });
|
||||
}
|
||||
}
|
||||
|
||||
using (TeknikEntities db = new TeknikEntities())
|
||||
{
|
||||
Models.Upload upload = Uploader.SaveFile(db, Config, data.InputStream, fileType, contentLength, encrypt, fileExt, iv, null, keySize, blockSize);
|
||||
@ -413,4 +422,4 @@ namespace Teknik.Areas.Upload.Controllers
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@ -31,6 +31,8 @@ namespace Teknik.Configuration
|
||||
public bool VirusScanEnable { get; set; }
|
||||
public string ClamServer { get; set; }
|
||||
public int ClamPort { get; set; }
|
||||
// Content Type Restrictions
|
||||
public List<string> RestrictedContentTypes { get; set; }
|
||||
|
||||
public UploadConfig()
|
||||
{
|
||||
@ -55,6 +57,7 @@ namespace Teknik.Configuration
|
||||
VirusScanEnable = false;
|
||||
ClamServer = "localhost";
|
||||
ClamPort = 3310;
|
||||
RestrictedContentTypes = new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user