1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 07:27:04 +00:00

Merge pull request #4893 from haiwen/check_virus

check virus when upload file via share link
This commit is contained in:
Daniel Pan
2021-05-20 15:40:56 +08:00
committed by GitHub
2 changed files with 19 additions and 5 deletions

View File

@@ -43,7 +43,7 @@ from seahub.settings import SHARE_LINK_EXPIRE_DAYS_MAX, \
SHARE_LINK_EXPIRE_DAYS_MIN, SHARE_LINK_LOGIN_REQUIRED, \
SHARE_LINK_EXPIRE_DAYS_DEFAULT, \
ENABLE_SHARE_LINK_AUDIT, ENABLE_VIDEO_THUMBNAIL, \
THUMBNAIL_ROOT
THUMBNAIL_ROOT, ENABLE_UPLOAD_LINK_VIRUS_CHECK
from seahub.wiki.models import Wiki
from seahub.views.file import can_edit_file
from seahub.views import check_folder_permission
@@ -808,11 +808,17 @@ class ShareLinkUpload(APIView):
# generate token
obj_id = json.dumps({'parent_dir': path})
check_virus = False
if is_pro_version() and ENABLE_UPLOAD_LINK_VIRUS_CHECK:
check_virus = True
token = seafile_api.get_fileserver_access_token(repo_id,
obj_id,
'upload-link',
share_link.username,
use_onetime=False)
use_onetime=False,
check_virus=check_virus)
if not token:
error_msg = 'Internal Server Error'

View File

@@ -25,12 +25,14 @@ from seahub.api2.throttling import AnonRateThrottle, UserRateThrottle
from seahub.api2.permissions import CanGenerateUploadLink
from seahub.share.models import UploadLinkShare, check_share_link_common
from seahub.utils import gen_shared_upload_link, gen_file_upload_url
from seahub.utils import gen_shared_upload_link, gen_file_upload_url, \
is_pro_version
from seahub.views import check_folder_permission
from seahub.utils.timeutils import datetime_to_isoformat_timestr
from seahub.settings import UPLOAD_LINK_EXPIRE_DAYS_DEFAULT, \
UPLOAD_LINK_EXPIRE_DAYS_MIN, UPLOAD_LINK_EXPIRE_DAYS_MAX
UPLOAD_LINK_EXPIRE_DAYS_MIN, UPLOAD_LINK_EXPIRE_DAYS_MAX, \
ENABLE_UPLOAD_LINK_VIRUS_CHECK
logger = logging.getLogger(__name__)
@@ -349,11 +351,17 @@ class UploadLinkUpload(APIView):
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
obj_id = json.dumps({'parent_dir': path})
check_virus = False
if is_pro_version() and ENABLE_UPLOAD_LINK_VIRUS_CHECK:
check_virus = True
token = seafile_api.get_fileserver_access_token(repo_id,
obj_id,
'upload-link',
uls.username,
use_onetime=False)
use_onetime=False,
check_virus=check_virus)
if not token:
error_msg = 'Internal Server Error'