mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 23:48:47 +00:00
Merge pull request #4893 from haiwen/check_virus
check virus when upload file via share link
This commit is contained in:
@@ -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_MIN, SHARE_LINK_LOGIN_REQUIRED, \
|
||||||
SHARE_LINK_EXPIRE_DAYS_DEFAULT, \
|
SHARE_LINK_EXPIRE_DAYS_DEFAULT, \
|
||||||
ENABLE_SHARE_LINK_AUDIT, ENABLE_VIDEO_THUMBNAIL, \
|
ENABLE_SHARE_LINK_AUDIT, ENABLE_VIDEO_THUMBNAIL, \
|
||||||
THUMBNAIL_ROOT
|
THUMBNAIL_ROOT, ENABLE_UPLOAD_LINK_VIRUS_CHECK
|
||||||
from seahub.wiki.models import Wiki
|
from seahub.wiki.models import Wiki
|
||||||
from seahub.views.file import can_edit_file
|
from seahub.views.file import can_edit_file
|
||||||
from seahub.views import check_folder_permission
|
from seahub.views import check_folder_permission
|
||||||
@@ -808,11 +808,17 @@ class ShareLinkUpload(APIView):
|
|||||||
|
|
||||||
# generate token
|
# generate token
|
||||||
obj_id = json.dumps({'parent_dir': path})
|
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,
|
token = seafile_api.get_fileserver_access_token(repo_id,
|
||||||
obj_id,
|
obj_id,
|
||||||
'upload-link',
|
'upload-link',
|
||||||
share_link.username,
|
share_link.username,
|
||||||
use_onetime=False)
|
use_onetime=False,
|
||||||
|
check_virus=check_virus)
|
||||||
|
|
||||||
if not token:
|
if not token:
|
||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
|
@@ -25,12 +25,14 @@ from seahub.api2.throttling import AnonRateThrottle, UserRateThrottle
|
|||||||
from seahub.api2.permissions import CanGenerateUploadLink
|
from seahub.api2.permissions import CanGenerateUploadLink
|
||||||
|
|
||||||
from seahub.share.models import UploadLinkShare, check_share_link_common
|
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.views import check_folder_permission
|
||||||
from seahub.utils.timeutils import datetime_to_isoformat_timestr
|
from seahub.utils.timeutils import datetime_to_isoformat_timestr
|
||||||
|
|
||||||
from seahub.settings import UPLOAD_LINK_EXPIRE_DAYS_DEFAULT, \
|
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__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -349,11 +351,17 @@ class UploadLinkUpload(APIView):
|
|||||||
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
||||||
|
|
||||||
obj_id = json.dumps({'parent_dir': path})
|
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,
|
token = seafile_api.get_fileserver_access_token(repo_id,
|
||||||
obj_id,
|
obj_id,
|
||||||
'upload-link',
|
'upload-link',
|
||||||
uls.username,
|
uls.username,
|
||||||
use_onetime=False)
|
use_onetime=False,
|
||||||
|
check_virus=check_virus)
|
||||||
|
|
||||||
if not token:
|
if not token:
|
||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
|
Reference in New Issue
Block a user