Skip to content

Commit b82622f

Browse files
Merge pull request #6064 from topcoder-platform/develop
Release v1.15.8
2 parents 4dac800 + b98f942 commit b82622f

File tree

5 files changed

+34
-21
lines changed

5 files changed

+34
-21
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ workflows:
343343
branches:
344344
only:
345345
- develop
346-
- fix/regsource
346+
- fix/infected-submission
347347
# This is alternate dev env for parallel testing
348348
- "build-test":
349349
context : org-global

__tests__/shared/components/SubmissionManagement/__snapshots__/Submission.jsx.snap

+3-17
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,7 @@ exports[`Snapshot match 1`] = `
2424
<button
2525
onClick={[Function]}
2626
type="button"
27-
>
28-
<DownloadIcon
29-
height="16"
30-
viewBox="0 0 16 16"
31-
width="16"
32-
xmlns="http://www.w3.org/2000/svg"
33-
/>
34-
</button>
27+
/>
3528
<button
3629
className="src-shared-components-SubmissionManagement-Submission-___styles__delete-icon___2M67z"
3730
disabled={true}
@@ -87,14 +80,7 @@ exports[`Snapshot match 2`] = `
8780
<button
8881
onClick={[Function]}
8982
type="button"
90-
>
91-
<DownloadIcon
92-
height="16"
93-
viewBox="0 0 16 16"
94-
width="16"
95-
xmlns="http://www.w3.org/2000/svg"
96-
/>
97-
</button>
83+
/>
9884
<button
9985
className="src-shared-components-SubmissionManagement-Submission-___styles__delete-icon___2M67z"
10086
disabled={true}
@@ -123,4 +109,4 @@ exports[`Snapshot match 2`] = `
123109
</div>
124110
</td>
125111
</tr>
126-
`;
112+
`;

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -232,5 +232,8 @@
232232
"webpack-pwa-manifest": "^3.7.1",
233233
"webpack-stats-plugin": "^0.2.1",
234234
"workbox-webpack-plugin": "^3.6.2"
235+
},
236+
"volta": {
237+
"node": "8.11.2"
235238
}
236239
}

src/shared/components/SubmissionManagement/Submission/index.jsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import _ from 'lodash';
1515
import moment from 'moment';
1616
import React from 'react';
17-
import { COMPETITION_TRACKS, CHALLENGE_STATUS } from 'utils/tc';
17+
import { COMPETITION_TRACKS, CHALLENGE_STATUS, safeForDownload } from 'utils/tc';
1818

1919
import PT from 'prop-types';
2020

@@ -38,6 +38,7 @@ export default function Submission(props) {
3838
} = props;
3939
const formatDate = date => moment(+new Date(date)).format('MMM DD, YYYY hh:mm A');
4040
const onDownloadSubmission = onDownload.bind(1, submissionObject.id);
41+
const safeForDownloadCheck = safeForDownload(submissionObject.url);
4142

4243
return (
4344
<tr styleName="submission-row">
@@ -54,7 +55,7 @@ export default function Submission(props) {
5455
{
5556
track === COMPETITION_TRACKS.DES && (
5657
<td styleName="status-col">
57-
{submissionObject.screening
58+
{safeForDownloadCheck !== true ? safeForDownloadCheck : submissionObject.screening
5859
&& (
5960
<ScreeningStatus
6061
screeningObject={submissionObject.screening}
@@ -71,7 +72,7 @@ export default function Submission(props) {
7172
onClick={() => onDownloadSubmission(submissionObject.id)}
7273
type="button"
7374
>
74-
<DownloadIcon />
75+
{ safeForDownloadCheck === true && <DownloadIcon /> }
7576
</button>
7677
{ /*
7778
TODO: At the moment we just fetch downloads from the legacy
@@ -127,6 +128,7 @@ Submission.propTypes = {
127128
type: PT.string,
128129
created: PT.any,
129130
download: PT.any,
131+
url: PT.string,
130132
}),
131133
showScreeningDetails: PT.bool,
132134
track: PT.string.isRequired,

src/shared/utils/tc.js

+22
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,26 @@ export function isValidEmail(email) {
305305
return pattern.test(email);
306306
}
307307

308+
/**
309+
* Test if the file is safe for download. This patch currently checks the location of the submission
310+
* to determine if the file is infected or not. This is an immedaite patch, and should be updated to
311+
* check the review scan score for review type virus scan.
312+
*
313+
* @returns {String|Boolean} true if submission is safe for download,
314+
* otherwise string describing reason for not being safe for download
315+
*/
316+
export function safeForDownload(url) {
317+
if (url == null) return 'Download link unavailable';
318+
319+
if (url.toLowerCase().indexOf('submissions-quarantine/') !== -1) {
320+
return 'Malware found in submission';
321+
}
322+
323+
if (url.toLowerCase().indexOf('submissions-dmz/') !== -1) {
324+
return 'AV Scan in progress';
325+
}
326+
327+
return true;
328+
}
329+
308330
export default undefined;

0 commit comments

Comments
 (0)