From 5abafcc95a50553b02761ec0a2e4564ad9a1bcd8 Mon Sep 17 00:00:00 2001 From: Rakib Ansary Date: Mon, 7 Mar 2022 15:31:36 +0600 Subject: [PATCH 1/6] fix: disable download of infected submissions --- .circleci/config.yml | 2 +- package.json | 3 +++ .../components/SubmissionManagement/Submission/index.jsx | 7 ++++--- src/shared/utils/tc.js | 9 +++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9bb0a50e15..7a26e82e5e 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/package.json b/package.json index 37d04f4e84..da9928d998 100644 --- a/package.json +++ b/package.json @@ -232,5 +232,8 @@ "webpack-pwa-manifest": "^3.7.1", "webpack-stats-plugin": "^0.2.1", "workbox-webpack-plugin": "^3.6.2" + }, + "volta": { + "node": "8.11.2" } } diff --git a/src/shared/components/SubmissionManagement/Submission/index.jsx b/src/shared/components/SubmissionManagement/Submission/index.jsx index 770b8ffb58..dc92dbd4d2 100644 --- a/src/shared/components/SubmissionManagement/Submission/index.jsx +++ b/src/shared/components/SubmissionManagement/Submission/index.jsx @@ -14,7 +14,7 @@ import _ from 'lodash'; import moment from 'moment'; import React from 'react'; -import { COMPETITION_TRACKS, CHALLENGE_STATUS } from 'utils/tc'; +import { COMPETITION_TRACKS, CHALLENGE_STATUS, safeForDownload } from 'utils/tc'; import PT from 'prop-types'; @@ -54,7 +54,7 @@ export default function Submission(props) { { track === COMPETITION_TRACKS.DES && ( - {submissionObject.screening + {!safeForDownload(submissionObject.url) ? 'Malware found in submission' : submissionObject.screening && ( onDownloadSubmission(submissionObject.id)} type="button" > - + { safeForDownload(submissionObject.url) && } { /* TODO: At the moment we just fetch downloads from the legacy @@ -127,6 +127,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..f827cd5d38 100644 --- a/src/shared/utils/tc.js +++ b/src/shared/utils/tc.js @@ -305,4 +305,13 @@ 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. + */ +export function safeForDownload(url) { + return url != null && url.indexOf('submissions-quarantine/') === -1; +} + export default undefined; From 46d153ad90a52fa9bba62374dbb25142b891368f Mon Sep 17 00:00:00 2001 From: Rakib Ansary Date: Tue, 22 Mar 2022 11:47:30 +0600 Subject: [PATCH 2/6] fix: update tests --- .../__snapshots__/Submission.jsx.snap | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) 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 diff --git a/src/shared/utils/tc.js b/src/shared/utils/tc.js index 42064969b5..bb38284c32 100644 --- a/src/shared/utils/tc.js +++ b/src/shared/utils/tc.js @@ -309,9 +309,22 @@ export function isValidEmail(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) { - return url != null && url.toLowerCase().indexOf('submissions-quarantine/') === -1 && url.toLowerCase().indexOf('submissions-dmz/') === -1; + 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; From 06af5fe9bc91fc7df11be01d96cf96388a5575a1 Mon Sep 17 00:00:00 2001 From: Rakib Ansary Date: Thu, 24 Mar 2022 19:21:24 +0600 Subject: [PATCH 6/6] fix: avscan in progress check --- src/shared/utils/tc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/utils/tc.js b/src/shared/utils/tc.js index bb38284c32..6edfd72a1c 100644 --- a/src/shared/utils/tc.js +++ b/src/shared/utils/tc.js @@ -320,7 +320,7 @@ export function safeForDownload(url) { return 'Malware found in submission'; } - if (url.toLowerCase().indexOf('submissions-dmz/') === -1) { + if (url.toLowerCase().indexOf('submissions-dmz/') !== -1) { return 'AV Scan in progress'; }