github-advanced-security[bot] commented on code in PR #1162:
URL: https://github.com/apache/syncope/pull/1162#discussion_r2307316061


##########
core/spring/src/test/java/org/apache/syncope/core/spring/SpringTestConfiguration.java:
##########
@@ -45,4 +52,13 @@
     public ImplementationLookup implementationLookup() {
         return new DummyImplementationLookup();
     }
+
+    @Bean
+    public Blacklist groovyBlackList() throws IOException {
+        try (InputStream is = 
getClass().getResourceAsStream("/META-INF/groovy.blacklist");

Review Comment:
   ## Unsafe use of getResource
   
   The idiom getClass().getResource() is unsafe for classes that may be 
extended.
   
   [Show more 
details](https://github.com/apache/syncope/security/code-scanning/2278)



##########
fit/core-reference/src/test/java/org/apache/syncope/fit/core/MacroTaskITCase.java:
##########
@@ -264,4 +273,61 @@
             assertEquals(ClientExceptionType.DelegatedAdministration, 
e.getType());
         }
     }
+
+    @Test
+    public void groovySecuritySandbox() throws IOException {
+        createMacroActionsIfNeeded(
+                "ProcessBuilderMacroActions",
+                ImplementationEngine.GROOVY,
+                IOUtils.toString(
+                        
getClass().getResourceAsStream("/ProcessBuilderMacroActions.groovy"), 
StandardCharsets.UTF_8));
+
+        MacroTaskTO task = new MacroTaskTO();
+        task.setName("groovySecuritySandbox" + UUID.randomUUID().toString());
+        task.setActive(true);
+        task.setRealm("/odd");
+        task.setMacroActions("ProcessBuilderMacroActions");
+
+        Response response = TASK_SERVICE.create(TaskType.MACRO, task);
+        String firstTaskKey = 
response.getHeaderString(RESTHeaders.RESOURCE_KEY);
+        assertNotNull(firstTaskKey);
+        TASK_SERVICE.execute(new 
ExecSpecs.Builder().key(firstTaskKey).build());
+
+        ExecTO exec = await().atMost(MAX_WAIT_SECONDS, 
TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(() -> {
+            try {
+                return TASK_SERVICE.read(TaskType.MACRO, firstTaskKey, 
true).getExecutions().getFirst();
+            } catch (Exception e) {
+                return null;
+            }
+        }, e -> e != null && !"JOB_FIRED".equals(e.getStatus()));
+        assertEquals(ExecStatus.FAILURE.name(), exec.getStatus());
+        assertTrue(exec.getMessage().startsWith("java.lang.SecurityException: 
Insecure call to"));
+
+        createMacroActionsIfNeeded(
+                "BashMacroActions",
+                ImplementationEngine.GROOVY,
+                IOUtils.toString(
+                        
getClass().getResourceAsStream("/BashMacroActions.groovy"), 
StandardCharsets.UTF_8));

Review Comment:
   ## Unsafe use of getResource
   
   The idiom getClass().getResource() is unsafe for classes that may be 
extended.
   
   [Show more 
details](https://github.com/apache/syncope/security/code-scanning/2280)



##########
fit/core-reference/src/test/java/org/apache/syncope/fit/core/MacroTaskITCase.java:
##########
@@ -264,4 +273,61 @@
             assertEquals(ClientExceptionType.DelegatedAdministration, 
e.getType());
         }
     }
+
+    @Test
+    public void groovySecuritySandbox() throws IOException {
+        createMacroActionsIfNeeded(
+                "ProcessBuilderMacroActions",
+                ImplementationEngine.GROOVY,
+                IOUtils.toString(
+                        
getClass().getResourceAsStream("/ProcessBuilderMacroActions.groovy"), 
StandardCharsets.UTF_8));

Review Comment:
   ## Unsafe use of getResource
   
   The idiom getClass().getResource() is unsafe for classes that may be 
extended.
   
   [Show more 
details](https://github.com/apache/syncope/security/code-scanning/2279)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to