Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ workflows:
branches:
only:
- develop
- PM-3087_virus-scan-fix

- "build-prod":
context: org-global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function Submission(props) {
} = props;
const formatDate = date => moment(+new Date(date)).format('MMM DD, YYYY hh:mm A');
const onDownloadSubmission = onDownload.bind(1, submissionObject.id);
const safeForDownloadCheck = safeForDownload(submissionObject.url);
const safeForDownloadCheck = safeForDownload(submissionObject);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The safeForDownload function now receives the entire submissionObject instead of just the url. Ensure that safeForDownload is designed to handle the full object and that it uses the necessary properties correctly. This change could potentially introduce issues if safeForDownload is not updated accordingly.

const onDownloadArtifacts = onOpenDownloadArtifactsModal.bind(1, submissionObject.id);
const onOpenRatingsList = onOpenRatingsListModal.bind(1, submissionObject.id);
const onOpenReviewApp = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/containers/SubmissionManagement/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class SubmissionManagementPageContainer extends React.Component {
const { needReload } = this.state;

if (needReload === false && mySubmissions) {
if (mySubmissions.find(item => safeForDownload(item.url) !== true)) {
if (mySubmissions.find(item => safeForDownload(item) !== true)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The safeForDownload function now takes an item object instead of item.url. Ensure that safeForDownload is designed to handle the entire object and not just a URL string. If safeForDownload expects a specific property from the object, verify that it is correctly accessing that property.

this.setState({ needReload: true });
setTimeout(() => {
loadMySubmissions(authTokens, challengeId);
Expand Down
13 changes: 6 additions & 7 deletions src/shared/utils/tc.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,21 +376,20 @@ 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.
* Test if the file is safe for download. This function can accept the full submission object.
*
* @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';
export function safeForDownload(submission) {
if (submission == null || !submission.url) return 'Download link unavailable';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 readability]
The check submission == null || !submission.url could be simplified to !submission || !submission.url for better readability.


if (url.toLowerCase().indexOf('submissions-quarantine/') !== -1) {
const { url } = submission;
if (url.toLowerCase().indexOf('submissions-quarantine/') !== -1 || submission.virusScan === false) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
The condition submission.virusScan === false is redundant with the condition !submission.virusScan in the next block. Consider consolidating these checks for clarity and maintainability.

return 'Malware found in submission';
}

if (url.toLowerCase().indexOf('submissions-dmz/') !== -1) {
if (url.toLowerCase().indexOf('submissions-dmz/') !== -1 || !submission.virusScan) {
return 'AV Scan in progress';
}

Expand Down
Loading