Skip to content
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

Fix handling of virus scanning env variable. #731

Merged
merged 1 commit into from
Jan 24, 2024
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
6 changes: 3 additions & 3 deletions api/controllers/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Actions = require('../helpers/actions');
const Utils = require('../helpers/utils');
const MinioController = require('../helpers/minio');

const ENABLE_VIRUS_SCANNING = process.env.ENABLE_VIRUS_SCANNING || false;
const ENABLE_VIRUS_SCANNING = process.env.ENABLE_VIRUS_SCANNING ? process.env.ENABLE_VIRUS_SCANNING.toLowerCase() == 'true' : false;

const generator = new FlakeIdGen;

Expand Down Expand Up @@ -111,7 +111,7 @@ exports.unProtectedPost = async function (args, res) {
console.log('Uploading');
Promise.resolve()
.then(async function () {
if (ENABLE_VIRUS_SCANNING || ENABLE_VIRUS_SCANNING == 'true') {
if (ENABLE_VIRUS_SCANNING) {
console.log('AVScan');
return Utils.avScan(args.swagger.params.upfile.value.buffer);
} else {
Expand Down Expand Up @@ -524,7 +524,7 @@ exports.protectedPost = async function (args, res) {
try {
Promise.resolve()
.then(function () {
if (ENABLE_VIRUS_SCANNING || ENABLE_VIRUS_SCANNING == 'true') {
if (ENABLE_VIRUS_SCANNING) {
return Utils.avScan(args.swagger.params.upfile.value.buffer);
} else {
return true;
Expand Down
4 changes: 2 additions & 2 deletions api/dao/documentDAO.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const _ = require('lodash');
const fs = require('fs');

const generator = new FlakeIdGen;
const ENABLE_VIRUS_SCANNING = process.env.ENABLE_VIRUS_SCANNING || false;
const ENABLE_VIRUS_SCANNING = process.env.ENABLE_VIRUS_SCANNING ? process.env.ENABLE_VIRUS_SCANNING.toLowerCase() == 'true' : false;

exports.documentHateoas = function(document, roles) {
document.links =
Expand Down Expand Up @@ -41,7 +41,7 @@ exports.createDocument = async function(userName, projectId, comment, uploadedFi
try {
let virusScanSuccessful = true;

if (ENABLE_VIRUS_SCANNING || ENABLE_VIRUS_SCANNING == 'true') {
if (ENABLE_VIRUS_SCANNING) {
virusScanSuccessful = Utils.avScan(uploadedFile.buffer);
}

Expand Down
Loading