SUPPORT-9156: remove throw ex

This commit is contained in:
adel.ka 2025-05-06 16:43:21 +03:00
parent 88a3460d65
commit 823eb51905

View file

@ -26,6 +26,7 @@ public class FileScanService {
private static final String KESL_SCAN = "--scan-file"; private static final String KESL_SCAN = "--scan-file";
private static final int CLEAN_CODE = 0; private static final int CLEAN_CODE = 0;
private static final int INFECTED_CODE = 72; private static final int INFECTED_CODE = 72;
private static final int PROTECTED_CODE = 73;
private static final Logger LOGGER = LoggerFactory.getLogger(FileScanService.class); private static final Logger LOGGER = LoggerFactory.getLogger(FileScanService.class);
@Value("${file.upload.directory:/tmp/uploaded_files}") @Value("${file.upload.directory:/tmp/uploaded_files}")
private String uploadDirectory; private String uploadDirectory;
@ -81,7 +82,7 @@ public class FileScanService {
LOGGER.warn("File: {} is identified as password protected. Please review the file.", LOGGER.warn("File: {} is identified as password protected. Please review the file.",
originalFileName originalFileName
); );
exitCode = INFECTED_CODE; exitCode = PROTECTED_CODE;
} }
return exitCode; return exitCode;
@ -89,12 +90,11 @@ public class FileScanService {
private boolean isPasswordProtectedFile(String result) { private boolean isPasswordProtectedFile(String result) {
if (!result.contains(passwordProtectedResultName)) { if (!result.contains(passwordProtectedResultName)) {
LOGGER.warn( throw new AvException(String.format(
"File scan result doesn't contains \"{}\"." "File scan result doesn't contains \"%s\", "
+ "Please check property \"password.protected.result.name\" is correct", + "please check property \"password.protected.result.name\" is correct",
passwordProtectedResultName passwordProtectedResultName
); ));
return true;
} }
for (String line : result.split("\n")) { for (String line : result.split("\n")) {