Huge refactor, submission system addition & security improvements. +Implementation of moderation cmds.
This commit is contained in:
@@ -7,9 +7,15 @@ pub const RENDER_DOCUMENT: u32 = 1 << 5;
|
||||
pub const RENDER_EXECUTABLE: u32 = 1 << 6;
|
||||
pub const RENDER_DANGEROUS: u32 = 1 << 7;
|
||||
pub const RENDER_NO_INLINE: u32 = 1 << 8;
|
||||
pub const RENDER_SENSITIVE: u32 = 1 << 9;
|
||||
|
||||
const DANGEROUS_EXTENSIONS: &[&str] = &[
|
||||
"exe", "scr", "bat", "cmd", "sh", "dll", "so", "dylib", "jar", "msi", "com", "app", "apk",
|
||||
"ps1", "py", "pyw", "vbs", "js", "html", "htm",
|
||||
];
|
||||
|
||||
const SENSITIVE_EXTENSIONS: &[&str] = &[
|
||||
"db", "sqlite", "sqlite3", "sqlitedb", "mdf", "mdb", "accdb", "dump", "sql", "backup", "bak",
|
||||
];
|
||||
|
||||
const DANGEROUS_MIME_TYPES: &[&str] = &[
|
||||
@@ -18,6 +24,11 @@ const DANGEROUS_MIME_TYPES: &[&str] = &[
|
||||
"text/css",
|
||||
"application/javascript",
|
||||
"application/ecmascript",
|
||||
"application/x-python",
|
||||
"text/x-python",
|
||||
"application/x-powershell",
|
||||
"application/x-shellscript",
|
||||
"text/x-shellscript",
|
||||
];
|
||||
|
||||
pub fn detect_mime_type(data: &[u8], file_name: &str) -> String {
|
||||
@@ -61,6 +72,10 @@ pub fn compute_render_flags(mime_type: &str, file_name: &str, data: &[u8]) -> u3
|
||||
flags |= RENDER_EXECUTABLE | RENDER_DANGEROUS | RENDER_NO_INLINE;
|
||||
}
|
||||
|
||||
if SENSITIVE_EXTENSIONS.contains(&ext.as_str()) {
|
||||
flags |= RENDER_SENSITIVE | RENDER_NO_INLINE;
|
||||
}
|
||||
|
||||
if let Some(kind) = infer::get(data) {
|
||||
let mime = kind.mime_type();
|
||||
if mime == "application/x-executable"
|
||||
|
||||
Reference in New Issue
Block a user