This is an automated email from the ASF dual-hosted git repository.

mhanson pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 718aafeb35 GEODE-10248: Adding a new Suspicious Strings exception 
(#7612)
718aafeb35 is described below

commit 718aafeb35906c6f25dac0bf266a2cdb962bd37a
Author: mhansonp <hans...@vmware.com>
AuthorDate: Tue Apr 26 09:33:05 2022 -0700

    GEODE-10248: Adding a new Suspicious Strings exception (#7612)
    
    
    for Management Requests that get logged and a test
---
 .../apache/geode/test/greplogs/LogConsumer.java    | 21 ++++++---
 .../org/apache/geode/test/greplogs/Patterns.java   |  6 ++-
 .../geode/test/greplogs/LogConsumerTest.java       | 52 ++++++++++++++++++++++
 3 files changed, 71 insertions(+), 8 deletions(-)

diff --git 
a/geode-dunit/src/main/java/org/apache/geode/test/greplogs/LogConsumer.java 
b/geode-dunit/src/main/java/org/apache/geode/test/greplogs/LogConsumer.java
index c313418344..93da8d05ac 100644
--- a/geode-dunit/src/main/java/org/apache/geode/test/greplogs/LogConsumer.java
+++ b/geode-dunit/src/main/java/org/apache/geode/test/greplogs/LogConsumer.java
@@ -31,6 +31,7 @@ import static 
org.apache.geode.test.greplogs.Patterns.JAVA_LANG_ERROR;
 import static org.apache.geode.test.greplogs.Patterns.LOG_STATEMENT;
 import static org.apache.geode.test.greplogs.Patterns.MALFORMED_I18N_MESSAGE;
 import static org.apache.geode.test.greplogs.Patterns.MALFORMED_LOG4J_MESSAGE;
+import static org.apache.geode.test.greplogs.Patterns.MANAGEMENT_REQUEST;
 import static org.apache.geode.test.greplogs.Patterns.RMI_WARNING;
 import static org.apache.geode.test.greplogs.Patterns.RVV_BIT_SET_MESSAGE;
 import static org.apache.geode.test.greplogs.Patterns.WARN_OR_LESS_LOG_LEVEL;
@@ -43,6 +44,7 @@ import java.util.regex.MatchResult;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+
 public class LogConsumer {
 
   /** Limit long errors to this many lines */
@@ -162,13 +164,18 @@ public class LogConsumer {
   }
 
   private boolean isExceptionErrorOrSomeSpecialCase(CharSequence line) {
-    return (EXCEPTION.matcher(line).find() ||
-        JAVA_LANG_ERROR.matcher(line).find() ||
-        MALFORMED_I18N_MESSAGE.matcher(line).find() ||
-        MALFORMED_LOG4J_MESSAGE.matcher(line).find()) &&
-        !(HYDRA_MASTER_LOCATORS_WILDCARD.matcher(line).find()) &&
-        !(WARN_OR_LESS_LOG_LEVEL.matcher(line).find() &&
-            RVV_BIT_SET_MESSAGE.matcher(line).find());
+    // if one of the following finds is true
+    return (EXCEPTION.matcher(line).find() || 
JAVA_LANG_ERROR.matcher(line).find()
+        || MALFORMED_I18N_MESSAGE.matcher(line).find()
+        || MALFORMED_LOG4J_MESSAGE.matcher(line).find()) &&
+    // and we don't find the below
+        !(HYDRA_MASTER_LOCATORS_WILDCARD.matcher(line).find())
+        && !(WARN_OR_LESS_LOG_LEVEL.matcher(line).find()
+            && MANAGEMENT_REQUEST.matcher(line).find())
+        && !(WARN_OR_LESS_LOG_LEVEL.matcher(line).find() // Warning message or 
lower
+            && RVV_BIT_SET_MESSAGE.matcher(line).find()); // rvv bit sit 
message
+    // then it is an exception error or some special case.
+
   }
 
   private void addErrLinesToAll(CharSequence line) {
diff --git 
a/geode-dunit/src/main/java/org/apache/geode/test/greplogs/Patterns.java 
b/geode-dunit/src/main/java/org/apache/geode/test/greplogs/Patterns.java
index 662bad915d..514a7b9e2c 100644
--- a/geode-dunit/src/main/java/org/apache/geode/test/greplogs/Patterns.java
+++ b/geode-dunit/src/main/java/org/apache/geode/test/greplogs/Patterns.java
@@ -58,7 +58,11 @@ public enum Patterns {
   /** "{}" literal which is probably unused Log4J parameter */
   MALFORMED_LOG4J_MESSAGE(compile("\\{\\}")),
   /** "{}" literal used for hydra master locators wildcard */
-  
HYDRA_MASTER_LOCATORS_WILDCARD(compile("hydra\\.MasterDescription\\.master\\.locators=\\{\\}"));
+  
HYDRA_MASTER_LOCATORS_WILDCARD(compile("hydra\\.MasterDescription\\.master\\.locators=\\{\\}")),
+  /**
+   * "Management Request:" messages "Management Request: 
PUT[url=/management/v1/deployments]...."
+   */
+  MANAGEMENT_REQUEST(compile("Management Request:"));
 
   private final Pattern pattern;
 
diff --git 
a/geode-dunit/src/test/java/org/apache/geode/test/greplogs/LogConsumerTest.java 
b/geode-dunit/src/test/java/org/apache/geode/test/greplogs/LogConsumerTest.java
index 1380db652c..b221440a5a 100644
--- 
a/geode-dunit/src/test/java/org/apache/geode/test/greplogs/LogConsumerTest.java
+++ 
b/geode-dunit/src/test/java/org/apache/geode/test/greplogs/LogConsumerTest.java
@@ -157,6 +157,58 @@ public class LogConsumerTest {
     assertThat(value).isNull();
   }
 
+  @Test
+  public void close_returnsNull_ifLineContains_ManagementRequest() {
+    String managmentRequest =
+        "[info 2022/04/16 09:39:11.008 UTC locator-0 <qtp773068785-114> 
tid=0x72] Management Request: PUT[url=/management/v1/deployments]; user=null; 
payload=---YMBX204KTK7fmoVc8vVmUZOfJOmATtYGRLlAK\n"
+            + "Content-Disposition: form-data; name=\"file\"; 
filename=\"lib.jar\"\n"
+            + "Content-Type: application/java-archive\n"
+            + "Content-Length: 426\n"
+            + "\n"
+            + 
"PK?????????L?T????????????????Class1.class????;?o?>?????^.?f?.v?nv??F?6?????;F?f\n"
+            + "?0F?????TF?~???T????????????Wp~iQr?[&?????X\\l???X??????\n"
+            + "4?\"?? ????I?K??O?JM.aPd`?????@?T\n"
+            + 
"$??<Y0???Uk;??F?4;?d????8?4??'?PK??k??6????????PK?????????L?T????????????????timestamp3435040?447????PK??{6}?????\n"
+            + 
"???PK???????????L?Tk??6??????????????????????????Class1.class????PK???????????L?T{6}?????\n"
+            + "?????????????????????timestampPK??????????u?????????\n"
+            + "---YMBX204KTK7fmoVc8vVmUZOfJOmATtYGRLlAK\n"
+            + "Content-Disposition: form-data; name=\"config\"\n"
+            + "Content-Type: application/json\n"
+            + "\n"
+            + 
"{\"class\":\"org.apache.geode.management.configuration.Deployment\",\"group\":\"group1\",\"deployedTime\":null,\"deployedBy\":null,\"fileName\":\"lib.jar\"}\n"
+            + "---YMBX204KTK7fmoVc8vVmUZOfJOmATtYGRLlAK--";
+    logConsumer.consume(managmentRequest);
+    String value = logConsumer.close();
+
+    assertThat(value).isNull();
+  }
+
+  @Test
+  public void close_returnsLine_ifLineContains_ManagementRequest() {
+    String managmentRequest =
+        "[error 2022/04/16 09:39:11.008 UTC locator-0 <qtp773068785-114> 
tid=0x72] Management Request: PUT[url=/management/v1/deployments]; user=null; 
payload=---YMBX204KTK7fmoVc8vVmUZOfJOmATtYGRLlAK\n"
+            + "Content-Disposition: form-data; name=\"file\"; 
filename=\"lib.jar\"\n"
+            + "Content-Type: application/java-archive\n"
+            + "Content-Length: 426\n"
+            + "\n"
+            + 
"PK?????????L?T????????????????Class1.class????;?o?>?????^.?f?.v?nv??F?6?????;F?f\n"
+            + "?0F?????TF?~???T????????????Wp~iQr?[&?????X\\l???X??????\n"
+            + "4?\"?? ????I?K??O?JM.aPd`?????@?T\n"
+            + 
"$??<Y0???Uk;??F?4;?d????8?4??'?PK??k??6????????PK?????????L?T????????????????timestamp3435040?447????PK??{6}?????\n"
+            + 
"???PK???????????L?Tk??6??????????????????????????Class1.class????PK???????????L?T{6}?????\n"
+            + "?????????????????????timestampPK??????????u?????????\n"
+            + "---YMBX204KTK7fmoVc8vVmUZOfJOmATtYGRLlAK\n"
+            + "Content-Disposition: form-data; name=\"config\"\n"
+            + "Content-Type: application/json\n"
+            + "\n"
+            + 
"{\"class\":\"org.apache.geode.management.configuration.Deployment\",\"group\":\"group1\",\"deployedTime\":null,\"deployedBy\":null,\"fileName\":\"lib.jar\"}\n"
+            + "---YMBX204KTK7fmoVc8vVmUZOfJOmATtYGRLlAK--";
+    logConsumer.consume(managmentRequest);
+    String value = logConsumer.close();
+
+    assertThat(value).contains(managmentRequest);
+  }
+
   @Test
   public void close_returnsLine_ifLineContainsException() {
     logConsumer.consume(EXCEPTION_MESSAGE);

Reply via email to