SUPPORT-8841: add scan result code in logs
This commit is contained in:
parent
c4a514a8ec
commit
58f6ff8666
2 changed files with 15 additions and 8 deletions
|
|
@ -68,6 +68,7 @@ public class FileScanService {
|
|||
|
||||
try (InputStream inputStream = process.getInputStream()) {
|
||||
String result = new String(inputStream.readAllBytes());
|
||||
LOGGER.info("File {} scanned with result: {}", originalFileName, result);
|
||||
checkScanResult(result, originalFileName);
|
||||
|
||||
int exitCode = process.waitFor();
|
||||
|
|
@ -100,14 +101,20 @@ public class FileScanService {
|
|||
}
|
||||
|
||||
private void checkScanResult(String result, String originalFileName) {
|
||||
for (String line : result.split("\n")) {
|
||||
String[] lineParts = line.split(":");
|
||||
if (lineParts.length > 1) {
|
||||
if (lineParts[0].startsWith(passwordProtectedResultName)
|
||||
&& Integer.parseInt(lineParts[1].trim()) > 0) {
|
||||
throw new AvException("Detected password-protected file: " + originalFileName);
|
||||
}
|
||||
if (!result.contains(passwordProtectedResultName)) {
|
||||
LOGGER.warn("File scan result doesn't contains \"{}\", "
|
||||
+ "please check property \"password.protected.result.name\" is correct",
|
||||
passwordProtectedResultName);
|
||||
}
|
||||
|
||||
for (String line : result.split("\n")) {
|
||||
String[] lineParts = line.split(":");
|
||||
if (lineParts.length > 1) {
|
||||
if (lineParts[0].startsWith(passwordProtectedResultName)
|
||||
&& Integer.parseInt(lineParts[1].trim()) > 0) {
|
||||
throw new AvException("Detected password-protected file: " + originalFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ file:
|
|||
password:
|
||||
protected:
|
||||
result:
|
||||
name: '???????, ?????????? ???????'
|
||||
name: 'Объекты, защищенные паролем'
|
||||
Loading…
Add table
Add a link
Reference in a new issue