add av.check.enabled property
This commit is contained in:
parent
e7f8aaed29
commit
43e0cafcca
3 changed files with 13 additions and 5 deletions
|
|
@ -51,6 +51,8 @@ import ru.micord.ervu.av.s3.S3Service;
|
|||
@Service
|
||||
public class FileUploadService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FileUploadService.class);
|
||||
@Value("${av.check.enabled}")
|
||||
private boolean avCheckEnabled;
|
||||
@Value("${av.rest.address}")
|
||||
private String avRestAddress;
|
||||
@Value("${av.first.timeout.milliseconds}")
|
||||
|
|
@ -87,13 +89,17 @@ public class FileUploadService {
|
|||
Path filePath = Paths.get(fileSavingPath, fileUrl.fileName());
|
||||
String downloadUrl = fileUrl.fileUrl();
|
||||
downloadFile(downloadUrl, filePath);
|
||||
boolean clean = true;
|
||||
boolean infected = false;
|
||||
|
||||
AvResponse avResponse = checkFile(filePath);
|
||||
if (avCheckEnabled) {
|
||||
AvResponse avResponse = checkFile(filePath);
|
||||
|
||||
boolean clean = Arrays.stream(avResponse.verdicts())
|
||||
.anyMatch(verdict -> verdict.equalsIgnoreCase(AvResponse.Scan.VERDICT_CLEAN));
|
||||
boolean infected = Arrays.stream(avResponse.verdicts())
|
||||
.anyMatch(verdict -> verdict.equalsIgnoreCase(AvResponse.Scan.VERDICT_INFECTED));
|
||||
clean = Arrays.stream(avResponse.verdicts())
|
||||
.anyMatch(verdict -> verdict.equalsIgnoreCase(AvResponse.Scan.VERDICT_CLEAN));
|
||||
infected = Arrays.stream(avResponse.verdicts())
|
||||
.anyMatch(verdict -> verdict.equalsIgnoreCase(AvResponse.Scan.VERDICT_INFECTED));
|
||||
}
|
||||
|
||||
if (infected || !clean) {
|
||||
downloadRequest.fileInfo().setFileUrl(null);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ kafka.out.error.topic.name=${ERVU_KAFKA_ERROR_TOPIC_NAME}
|
|||
kafka.out.success.topic.name=${ERVU_KAFKA_SUCCESS_TOPIC_NAME}
|
||||
kafka.out.response.topic.name=${ERVU_KAFKA_RESPONSE_TOPIC_NAME}
|
||||
#
|
||||
av.check.enabled=${AV_CHECK_ENABLED:false}
|
||||
av.rest.address=${AV_REST_ADDRESS}
|
||||
av.first.timeout.milliseconds=${AV_FIRST_TIMEOUT_MILLISECONDS:1000}
|
||||
av.retry.max.attempts.count=${AV_RETRY_MAX_ATTEMPTS_COUNT:10}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue