Repository: kestra-io/kestra
Issue: Using 'include' fails when injecting namespaceFiles
Labels: bug

### Explain the bug

When I wanted to inject the `test` directory in namespaceFiles, I used the `include` keyword according to the documentation, but the `test` directory was not injected successfully as expected.

```
id: test
namespace: test

tasks:
    - id: test
      type: io.kestra.plugin.scripts.python.Commands
      namespaceFiles:
        enabled: true
        include:
          - "test/**"
      commands:
        - ls -R /tmp/kestra-wd
```

<img width="1020" alt="image" src="https://github.com/kestra-io/kestra/assets/95691624/254d7cc5-0672-4f06-9d9f-a41a404e442d">

<img width="690" alt="image" src="https://github.com/kestra-io/kestra/assets/95691624/1032613e-be10-49e0-a028-0cc41d2ab3a0">

### Environment Information

- Kestra Version: v0.13.8
- Operating System and Java Version (if not using Kestra Docker image): docker


Issue comments:
thanks so much for the issue! I can reproduce
temporary workaround: adding leading `/` in the `include` solves the issue

```yaml
id: test
namespace: dev

tasks:
    - id: test
      type: io.kestra.plugin.scripts.python.Commands
      namespaceFiles:
        enabled: true
        include:
          - "/test/**"
      commands:
        - ls test/ .
```
![image](https://github.com/kestra-io/kestra/assets/86264395/d3a844ef-3357-457a-9c6b-b9d49bb01f2d)


Pull request review comments:

Patch that resolved the issue:
diff --git a/core/src/main/java/io/kestra/core/runners/NamespaceFilesService.java b/core/src/main/java/io/kestra/core/runners/NamespaceFilesService.java
index c27313b732..15bbca2051 100644
--- a/core/src/main/java/io/kestra/core/runners/NamespaceFilesService.java
+++ b/core/src/main/java/io/kestra/core/runners/NamespaceFilesService.java
@@ -97,7 +97,7 @@ private static boolean match(List<String> patterns, String file) {
             .stream()
             .anyMatch(s -> FileSystems
                 .getDefault()
-                .getPathMatcher("glob:" + s)
+                .getPathMatcher("glob:" + (s.matches("\\w+[\\s\\S]*") ? "**/" + s : s))
                 .matches(Paths.get(file))
             );
     }


Test patch:
diff --git a/core/src/test/java/io/kestra/core/runners/NamespaceFilesServiceTest.java b/core/src/test/java/io/kestra/core/runners/NamespaceFilesServiceTest.java
index 0e54899a83..e71f570fa0 100644
--- a/core/src/test/java/io/kestra/core/runners/NamespaceFilesServiceTest.java
+++ b/core/src/test/java/io/kestra/core/runners/NamespaceFilesServiceTest.java
@@ -19,8 +19,7 @@
 
 import static io.kestra.core.utils.Rethrow.throwFunction;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.*;
 
 @MicronautTest
 class NamespaceFilesServiceTest {
@@ -94,8 +93,10 @@ public void filter() throws Exception {
         String namespace = "io.kestra." + IdUtils.create();
 
         put(null, namespace, "/a/b/c/1.sql", "1");
-        put(null, namespace, "/a/3.sql", "2");
-        put(null, namespace, "/b/c/d/1.sql", "3");
+        put(null, namespace, "/a/2.sql", "2");
+        put(null, namespace, "/b/c/d/3.sql", "3");
+        put(null, namespace, "/b/d/4.sql", "4");
+        put(null, namespace, "/c/5.sql", "5");
 
         List<URI> injected = namespaceFilesService.inject(
             runContextFactory.of(),
@@ -103,16 +104,27 @@ public void filter() throws Exception {
             namespace,
             basePath,
             NamespaceFiles.builder()
-                .include(List.of("/a/**"))
-                .exclude(List.of("**/3.sql"))
+                .include(List.of(
+                    "/a/**",
+                    "c/**"
+                ))
+                .exclude(List.of("**/2.sql"))
                 .build()
         );
 
-        assertThat(injected.size(), is(1));
-        assertThat(injected.get(0).getPath(), containsString("c/1.sql"));
-        List<Path> tempDir = Files.walk(basePath).filter(path -> path.toFile().isFile()).toList();
-        assertThat(tempDir.size(), is(1));
-        assertThat(tempDir.get(0).toString(), is(Paths.get(basePath.toString(), "/a/b/c/1.sql").toString()));
+        assertThat(injected, containsInAnyOrder(
+            hasProperty("path", endsWith("1.sql")),
+            hasProperty("path", endsWith("3.sql")),
+            hasProperty("path", endsWith("5.sql"))
+        ));
+        List<String> tempDirEntries = Files.walk(basePath).filter(path -> path.toFile().isFile())
+            .map(Path::toString)
+            .toList();
+        assertThat(tempDirEntries, containsInAnyOrder(
+            is(Paths.get(basePath.toString(), "/a/b/c/1.sql").toString()),
+            is(Paths.get(basePath.toString(), "/b/c/d/3.sql").toString()),
+            is(Paths.get(basePath.toString(), "/c/5.sql").toString())
+        ));
     }
 
     @Test