Repository: mercedes-benz/sechub
Issue: Improve SerecoSourceRelevantPartResolver to avoid NPE inside Sereco

### Situation
The relevant part resolver inside Sereco can fail when doing the regular expression matching when  the source is null.

### Wanted
No NPE when source is null

### Solution

Inside `SerecoSourceRelevantPartResolver.java` we check for `null`  and return an empty string as a fallback result.

https://github.com/mercedes-benz/sechub/blob/1deb8b6aba4e1a5d891f1b1e8cfb25fdf2a3198a/sechub-scan-product-sereco/src/main/java/com/mercedesbenz/sechub/domain/scan/product/sereco/SerecoSourceRelevantPartResolver.java#L13-L16

```java
    public String toRelevantPart(String source) {
        String result = P.matcher(source).replaceAll("");
        return result.toLowerCase();
    }
```
### Details
```java
Caused by: java.lang.NullPointerException: null     
at java.base/java.util.regex.Matcher.getTextLength(Unknown Source)     
at java.base/java.util.regex.Matcher.reset(Unknown Source)     
at java.base/java.util.regex.Matcher.<init>(Unknown Source)     
at java.base/java.util.regex.Pattern.matcher(Unknown Source)     
at com.mercedesbenz.sechub.domain.scan.product.sereco.SerecoSourceRelevantPartResolver.toRelevantPart(SerecoSourceRelevantPartResolver.java:14)     
at com.mercedesbenz.sechub.domain.scan.product.sereco.SerecoFalsePositiveCodeScanStrategy.createRelevantReplacment(SerecoFalsePositiveCodeScanStrategy.java:153)     
at com.mercedesbenz.sechub.domain.scan.product.sereco.SerecoFalsePositiveCodeScanStrategy.isFalsePositive(SerecoFalsePositiveCodeScanStrategy.java:120)     
at com.mercedesbenz.sechub.domain.scan.product.sereco.SerecoFalsePositiveFinder.isFound(SerecoFalsePositiveFinder.java:37)     
at com.mercedesbenz.sechub.domain.scan.product.sereco.SerecoFalsePositiveMarker.isFalsePositive(SerecoFalsePositiveMarker.java:91)     
at com.mercedesbenz.sechub.domain.scan.product.sereco.SerecoFalsePositiveMarker.handleVulnereability(SerecoFalsePositiveMarker.java:68)     
at com.mercedesbenz.sechub.domain.scan.product.sereco.SerecoFalsePositiveMarker.markFalsePositives(SerecoFalsePositiveMarker.java:61)     
at com.mercedesbenz.sechub.domain.scan.product.sereco.SerecoProductResultTransformer.transform(SerecoProductResultTransformer.java:68)     
at com.mercedesbenz.sechub.domain.scan.SecHubReportProductTransformerService.createResult(SecHubReportProductTransformerService.java:75)     
at com.mercedesbenz.sechub.domain.scan.SecHubReportProductTransformerService.createResult(SecHubReportProductTransformerService.java:53)     
at com.mercedesbenz.sechub.domain.scan.report.CreateScanReportService.createReport(CreateScanReportService.java:79)
```

Changed files:
sechub-scan-product-sereco/src/test/java/com/mercedesbenz/sechub/domain/scan/product/sereco/SerecoSourceRelevantPartResolverTest.java
sechub-scan-product-sereco/src/main/java/com/mercedesbenz/sechub/domain/scan/product/sereco/SerecoSourceRelevantPartResolver.java

diff --git a/sechub-scan-product-sereco/src/main/java/com/mercedesbenz/sechub/domain/scan/product/sereco/SerecoSourceRelevantPartResolver.java b/sechub-scan-product-sereco/src/main/java/com/mercedesbenz/sechub/domain/scan/product/sereco/SerecoSourceRelevantPartResolver.java
index 0b92a107d..1599733c8 100644
--- a/sechub-scan-product-sereco/src/main/java/com/mercedesbenz/sechub/domain/scan/product/sereco/SerecoSourceRelevantPartResolver.java
+++ b/sechub-scan-product-sereco/src/main/java/com/mercedesbenz/sechub/domain/scan/product/sereco/SerecoSourceRelevantPartResolver.java
@@ -11,6 +11,9 @@ public class SerecoSourceRelevantPartResolver {
     private static final Pattern P = Pattern.compile("\\\\s");
 
     public String toRelevantPart(String source) {
+        if (source == null) {
+            return "";
+        }
         String result = P.matcher(source).replaceAll("");
         return result.toLowerCase();
     }
diff --git a/sechub-scan-product-sereco/src/test/java/com/mercedesbenz/sechub/domain/scan/product/sereco/SerecoSourceRelevantPartResolverTest.java b/sechub-scan-product-sereco/src/test/java/com/mercedesbenz/sechub/domain/scan/product/sereco/SerecoSourceRelevantPartResolverTest.java
index 5116790dc..14e324d70 100644
--- a/sechub-scan-product-sereco/src/test/java/com/mercedesbenz/sechub/domain/scan/product/sereco/SerecoSourceRelevantPartResolverTest.java
+++ b/sechub-scan-product-sereco/src/test/java/com/mercedesbenz/sechub/domain/scan/product/sereco/SerecoSourceRelevantPartResolverTest.java
@@ -1,22 +1,22 @@
 // SPDX-License-Identifier: MIT
 package com.mercedesbenz.sechub.domain.scan.product.sereco;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class SerecoSourceRelevantPartResolverTest {
 
     private SerecoSourceRelevantPartResolver resolverToTest;
 
-    @Before
-    public void before() throws Exception {
+    @BeforeEach
+    void beforeEach() throws Exception {
         resolverToTest = new SerecoSourceRelevantPartResolver();
     }
 
     @Test
-    public void shrink_whitespaces() {
+    void shrink_whitespaces() {
         assertEquals("iwillbeshrinked", resolverToTest.toRelevantPart("i will be shrinked"));
         assertEquals("iwillbeshrinked", resolverToTest.toRelevantPart("i will   be    shrinked"));
         assertEquals("iwillbeshrinked", resolverToTest.toRelevantPart("i will beshrinked"));
@@ -25,10 +25,20 @@ public class SerecoSourceRelevantPartResolverTest {
     }
 
     @Test
-    public void lowercased() {
+    void lowercased() {
         assertEquals("lowered", resolverToTest.toRelevantPart("loWEREd"));
         assertEquals("lowered", resolverToTest.toRelevantPart("LOWERED"));
         assertEquals("lowered", resolverToTest.toRelevantPart("lowered"));
     }
 
+    @Test
+    void null_source_returns_empty_string() {
+        assertEquals("", resolverToTest.toRelevantPart(null));
+    }
+
+    @Test
+    void empty_source_returns_empty_string() {
+        assertEquals("", resolverToTest.toRelevantPart(""));
+    }
+
 }