diff --git a/pom.xml b/pom.xml index 2444e43..a5d1864 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,6 @@ org.graalvm.buildtools native-maven-plugin - diff --git a/readme.md b/readme.md index cab0d56..c922d64 100644 --- a/readme.md +++ b/readme.md @@ -23,10 +23,23 @@ You can retrieve your Api Key [here](https://demo.defectdojo.org/api/key-v2) aft ### Via Docker -You can use docker to install scan2dojo: +You can use Docker to run `scan2dojo` in interactive mode (`-it`) and automatically remove the container after use with the `--rm` option. - docker pull moudjames23/scan2dojo:v1.0.0 + docker run --rm -it moudjames23/scan2dojo:1.0.0 + + + +You can also mount a volume to specify the location of your scan results when running the Docker image. For example, if your scan results are located at `/Users/Moud/Libs/trivy.json`, you can mount it like this: + + docker run --rm -it -v /Users/Moud/Libs:/data moudjames23/scan2dojo:1.0.0 + +You can directly execute a commande like this: + + docker run -v /Users/Moud/Libs:/dat moudjames23/scan2dojo:1.0.0 import --scanType "Trivy Scan" --file /data/trivy.json --productName "Scan2dojo" --engagementName "Release" --minimumSeverity High + +> Before running this command, make sure that the product "Scan2dojo" exists and that the "Release" engagement also exists. + ### MacOs or Linux @@ -60,10 +73,6 @@ This command sets the endpoint and API key that will be used by the application - --***endpoint***: The url of the defectdojo service endpoint - --***apiKey***: The api key used to authenticate requests to the endpoint -In interactive mode, you can just type: - - scan2dojo configure - ### Create a new product type his command allows the user to create a new product type by providing a name, description, and two boolean flags to specify if the product type is critical and/or considered a key type. diff --git a/src/main/java/io/github/moudjames23/scan2dojo/command/S2DCommand.java b/src/main/java/io/github/moudjames23/scan2dojo/command/S2DCommand.java index c56252b..ea7e7ba 100644 --- a/src/main/java/io/github/moudjames23/scan2dojo/command/S2DCommand.java +++ b/src/main/java/io/github/moudjames23/scan2dojo/command/S2DCommand.java @@ -12,7 +12,6 @@ import org.springframework.shell.standard.ShellOption; import java.io.IOException; -import java.net.URISyntaxException; @ShellComponent @@ -20,10 +19,12 @@ public class S2DCommand { private final Scan2Dojo scan2Dojo; + @Value("${APP_VERSION}") private String version; + public S2DCommand(Scan2Dojo importService) { this.scan2Dojo = importService; } @@ -85,7 +86,7 @@ public String displayHelp() { public void configure( @ShellOption(defaultValue = "", help = "The URL of the Scan2Dojo service endpoint.") String endpoint, @ShellOption(defaultValue = "", help = "The API key used to authenticate requests to the endpoint.") String apiKey - ) throws IOException, URISyntaxException { + ) throws IOException { this.scan2Dojo.configure(endpoint, apiKey); diff --git a/src/main/java/io/github/moudjames23/scan2dojo/dto/Configuration.java b/src/main/java/io/github/moudjames23/scan2dojo/dto/Configuration.java index 7323774..31dda98 100644 --- a/src/main/java/io/github/moudjames23/scan2dojo/dto/Configuration.java +++ b/src/main/java/io/github/moudjames23/scan2dojo/dto/Configuration.java @@ -87,6 +87,8 @@ public void save() throws IOException { objectMapper.writeValue(configPath.toFile(), data); + printlnWithBorder(GREEN, "Configuration updated successfully 🎉🎉🎉"); + } } diff --git a/src/main/java/io/github/moudjames23/scan2dojo/http/Scan2Dojo.java b/src/main/java/io/github/moudjames23/scan2dojo/http/Scan2Dojo.java index 5978372..102233c 100644 --- a/src/main/java/io/github/moudjames23/scan2dojo/http/Scan2Dojo.java +++ b/src/main/java/io/github/moudjames23/scan2dojo/http/Scan2Dojo.java @@ -1,5 +1,6 @@ package io.github.moudjames23.scan2dojo.http; +import io.github.moudjames23.scan2dojo.dto.Configuration; import io.github.moudjames23.scan2dojo.dto.requests.EngagementRequest; import io.github.moudjames23.scan2dojo.dto.requests.ImportRequest; import io.github.moudjames23.scan2dojo.dto.requests.ProductRequest; @@ -7,26 +8,24 @@ import io.github.moudjames23.scan2dojo.dto.responses.EngagementResponse; import io.github.moudjames23.scan2dojo.dto.responses.ImportResponse; import io.github.moudjames23.scan2dojo.dto.responses.ProductResponse; -import io.github.moudjames23.scan2dojo.dto.Configuration; import io.github.moudjames23.scan2dojo.dto.responses.ProductTypeResponse; import io.github.moudjames23.scan2dojo.enums.ScanType; import io.github.moudjames23.scan2dojo.enums.Severity; import io.github.moudjames23.scan2dojo.util.EnumUtil; -import io.github.moudjames23.scan2dojo.util.RequestUtil; import org.springframework.stereotype.Service; import java.io.File; import java.io.IOException; -import java.net.URISyntaxException; import static io.github.moudjames23.scan2dojo.util.MessageUtil.*; -import static io.github.moudjames23.scan2dojo.util.RequestUtil.*; +import static io.github.moudjames23.scan2dojo.util.RequestUtil.executeRequest; @Service public class Scan2Dojo { private Configuration configuration; + public Scan2Dojo() { this.configuration = new Configuration(); @@ -36,15 +35,12 @@ public void version() { printlnWithBorder(RED, "Version"); } - public void configure(String endpoint, String apiKey) throws IOException, URISyntaxException { + public void configure(String endpoint, String apiKey) throws IOException { configuration.setEndpoint(endpoint); configuration.setApiKey(apiKey); configuration.save(); - - printlnWithBorder(GREEN, "Configuration updated successfully 🎉🎉🎉"); - } public void createProductType(ProductTypeRequest productTypeRequest) throws IOException { diff --git a/src/main/resources/META-INF/native-image/reflect-config.json b/src/main/resources/META-INF/native-image/reflect-config.json index 2dd19bd..dbe7c7a 100644 --- a/src/main/resources/META-INF/native-image/reflect-config.json +++ b/src/main/resources/META-INF/native-image/reflect-config.json @@ -1,4 +1,13 @@ [ + { + "name": "io.github.moudjames23.scan2dojo.dto.responses.ProductTypeResponse", + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredClasses" : true, + "allPublicClasses" : true + }, { "name": "io.github.moudjames23.scan2dojo.dto.responses.ProductResponse", "allDeclaredConstructors" : true,