From 078a6909a5dc02613cc31905fea5ec613f6bd6d9 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Tue, 25 May 2021 12:39:59 +0200 Subject: [PATCH] Improved bot log detection. --- .../statoolinfos/metrics/http/HttpAccessLog.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLog.java b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLog.java index 390b750..4b8ce02 100644 --- a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLog.java +++ b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLog.java @@ -23,6 +23,7 @@ import java.time.format.DateTimeFormatter; import java.util.Locale; import java.util.regex.Pattern; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -184,7 +185,18 @@ public class HttpAccessLog { boolean result; - result = StringsUtils.containsAnyIgnoreCase(this.userAgent.toString(), "bot", "monitoring"); + if (StringsUtils.containsAnyIgnoreCase(this.userAgent.toString(), "bot", "monitoring", "Apache-HttpClient")) + { + result = true; + } + else if (StringUtils.startsWithAny(this.userAgent.toString(), "Java/", "HotJava/")) + { + result = true; + } + else + { + result = false; + } // return result;