Skip to content

Commit

Permalink
Merge pull request #731 from tolkamps1/fix-virus-scanning-env-variable
Browse files Browse the repository at this point in the history
Fix handling of virus scanning env variable.
  • Loading branch information
tolkamps1 authored Jan 24, 2024
2 parents 3e612dd + 137719c commit b6a39e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit b6a39e6

Please sign in to comment.