diff --git a/.circleci/config.yml b/.circleci/config.yml index eecaa1eab5..db7c1a890a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -343,7 +343,7 @@ workflows: branches: only: - develop - - fix/regsource + - fix/infected-submission # This is alternate dev env for parallel testing - "build-test": context : org-global diff --git a/__tests__/shared/components/SubmissionManagement/__snapshots__/Submission.jsx.snap b/__tests__/shared/components/SubmissionManagement/__snapshots__/Submission.jsx.snap index eee3e3054e..7a713fe290 100644 --- a/__tests__/shared/components/SubmissionManagement/__snapshots__/Submission.jsx.snap +++ b/__tests__/shared/components/SubmissionManagement/__snapshots__/Submission.jsx.snap @@ -24,14 +24,7 @@ exports[`Snapshot match 1`] = ` + /> + /> { /* TODO: At the moment we just fetch downloads from the legacy @@ -127,6 +128,7 @@ Submission.propTypes = { type: PT.string, created: PT.any, download: PT.any, + url: PT.string, }), showScreeningDetails: PT.bool, track: PT.string.isRequired, diff --git a/src/shared/utils/tc.js b/src/shared/utils/tc.js index 37514bc606..6edfd72a1c 100644 --- a/src/shared/utils/tc.js +++ b/src/shared/utils/tc.js @@ -305,4 +305,26 @@ export function isValidEmail(email) { return pattern.test(email); } +/** + * Test if the file is safe for download. This patch currently checks the location of the submission + * to determine if the file is infected or not. This is an immedaite patch, and should be updated to + * check the review scan score for review type virus scan. + * + * @returns {String|Boolean} true if submission is safe for download, + * otherwise string describing reason for not being safe for download + */ +export function safeForDownload(url) { + if (url == null) return 'Download link unavailable'; + + if (url.toLowerCase().indexOf('submissions-quarantine/') !== -1) { + return 'Malware found in submission'; + } + + if (url.toLowerCase().indexOf('submissions-dmz/') !== -1) { + return 'AV Scan in progress'; + } + + return true; +} + export default undefined;