diff --git a/api/controllers/document.js b/api/controllers/document.js index eb2df0c3..9bffe6d7 100644 --- a/api/controllers/document.js +++ b/api/controllers/document.js @@ -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; @@ -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 { @@ -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; diff --git a/api/dao/documentDAO.js b/api/dao/documentDAO.js index 017a1a56..93c915a7 100644 --- a/api/dao/documentDAO.js +++ b/api/dao/documentDAO.js @@ -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 = @@ -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); }