-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#3825 - Virus Scanning - Empty File Check #3862
#3825 - Virus Scanning - Empty File Check #3862
Conversation
studentFile.uniqueFileName, | ||
); | ||
if (contentLength === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 , the contentLength was already available in the objectStorageService. Good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work @andrewsignori-aot
@@ -36,7 +39,7 @@ export class VirusScanProcessor { | |||
} catch (error: unknown) { | |||
if (error instanceof CustomNamedError) { | |||
const errorMessage = error.message; | |||
if (error.name === FILE_NOT_FOUND) { | |||
if ([FILE_NOT_FOUND, EMPTY_FILE].includes(error.name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor. please update the comment underneath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, updated.
// Empty files are not suitable for virus scanning using passthrough. | ||
throw new CustomNamedError( | ||
`File ${uniqueFileName} has no content to be scanned.`, | ||
EMPTY_FILE, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
*/ | ||
export function createFakeGetObjectResponse(fileContent: string): jest.Mock { | ||
return jest.fn(() => { | ||
const buffer = Buffer.from(fileContent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this scenario. One very minor comment.
Quality Gate passedIssues Measures |
When starting a socket to send a file content to
clamav
using the passthrough and no content is sent, the connection stays open for an indefinite amount of time (over 5 minutes).Changed queue-consumers to throw an error and remove the job, same behavior when the file is not found.
We can have a separate ticket to apply validation for the file upload to avoid accepting empty files, but I considered it outside this hotfix issue.
ClamAV debug log when a empty file is send for scanning.