feat: add ClamAV to scan for malicious files

This commit is contained in:
Elias Schneider
2023-01-13 10:16:35 +01:00
parent 16b697053a
commit 76088cc76a
18 changed files with 284 additions and 171 deletions

View File

@@ -1,7 +1,11 @@
import { Stack, TextInput } from "@mantine/core";
import { ModalsContextProps } from "@mantine/modals/lib/context";
const showShareLinkModal = (modals: ModalsContextProps, shareId: string, appUrl : string) => {
const showShareLinkModal = (
modals: ModalsContextProps,
shareId: string,
appUrl: string
) => {
const link = `${appUrl}/share/${shareId}`;
return modals.openModal({
title: "Share link",

View File

@@ -53,7 +53,10 @@ const Dropzone = ({
disabled={isUploading}
openRef={openRef as ForwardedRef<() => void>}
onDrop={(newFiles: FileUpload[]) => {
const fileSizeSum = [...newFiles, ...files].reduce((n, { size }) => n + size, 0);
const fileSizeSum = [...newFiles, ...files].reduce(
(n, { size }) => n + size,
0
);
if (fileSizeSum > config.get("MAX_SHARE_SIZE")) {
toast.error(

View File

@@ -47,21 +47,19 @@ const Share = ({ shareId }: { shareId: string }) => {
.catch((e) => {
const { error } = e.response.data;
if (e.response.status == 404) {
showErrorModal(
modals,
"Not found",
"This share can't be found. Please check your link."
);
if (error == "share_removed") {
showErrorModal(modals, "Share removed", e.response.data.message);
} else {
showErrorModal(
modals,
"Not found",
"This share can't be found. Please check your link."
);
}
} else if (error == "share_password_required") {
showEnterPasswordModal(modals, getShareToken);
} else if (error == "share_token_required") {
getShareToken();
} else if (error == "forbidden") {
showErrorModal(
modals,
"Forbidden",
"You're not allowed to see this share. Are you logged in with the correct account?"
);
} else {
showErrorModal(modals, "Error", "An unknown error occurred.");
}

View File

@@ -1,3 +1,3 @@
export type FileUpload = File & { uploadingProgress: number };
export type FileUploadResponse = {id: string, name: string}
export type FileUploadResponse = { id: string; name: string };