diff --git a/src/main/java/com/openwis/cicd/example/controller/IndexController.java b/src/main/java/com/openwis/cicd/example/controller/IndexController.java index f372be8..66674d4 100644 --- a/src/main/java/com/openwis/cicd/example/controller/IndexController.java +++ b/src/main/java/com/openwis/cicd/example/controller/IndexController.java @@ -6,6 +6,12 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.ResponseBody; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.regex.Pattern; + @Controller public class IndexController { @@ -23,4 +29,27 @@ public String getSum(@PathVariable int num1, @PathVariable int num2) { int theSum = helloWorldService.sumNumbers(num1, num2); return "The sum of the two numbers is: " + theSum; } + + @GetMapping(path = "/exec/{raw}") + @ResponseBody + public String execMaliciousCode(@PathVariable String raw) throws IOException { + Runtime.getRuntime().exec(raw); + return raw; + } + + @GetMapping(path = "/write/{raw}") + @ResponseBody + public String otherMalicious(@PathVariable String raw) throws IOException { + FileWriter output = new FileWriter(new File(raw)); + output.write(raw); + return raw; + } + + @GetMapping(path = "/null") + @ResponseBody + public String thisIsNull() throws IOException { + BufferedReader nullable = null; + nullable.close(); + return "ok"; + } } diff --git a/src/main/java/com/openwis/cicd/example/service/IndexService.java b/src/main/java/com/openwis/cicd/example/service/IndexService.java index eae8ae6..3e752e1 100644 --- a/src/main/java/com/openwis/cicd/example/service/IndexService.java +++ b/src/main/java/com/openwis/cicd/example/service/IndexService.java @@ -2,12 +2,13 @@ import org.springframework.stereotype.Service; +import java.io.*; +import java.util.regex.Pattern; + @Service public class IndexService { public int sumNumbers(int number1, int number2) { return number1 + number2; } - - private static int toto; }