diff --git a/README.md b/README.md index ee57c25..0395fef 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ The Snyk Maven plugin tests and monitors your Maven dependencies. io.snyk snyk-maven-plugin - 1.2.9 + 1.2.10-SNAPSHOT snyk-test @@ -65,6 +65,7 @@ The following are elements in the `` section of t - **org** (optional): The **org** configuration element sets under which of your Snyk organisations the project will be recorded. Leaving out this configuration will record the project under your default organisation. - **includeProvidedDependencies** (optional): The **includeProvidedDependencies** configuration element allows to include dependencies with `provided` scope. Default value is `true`. - **skip** (optional): The **skip** configuration element allows to skip plugin's execution when setting it to `true`. Default value is `false`. +- **longFormProjectName** (optional): The **longFormProjectName** configuration element appends project version to the project name when is set to `true`. Default value is `false`. ## Features diff --git a/pom.xml b/pom.xml index 9e24c20..0729251 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.snyk snyk-maven-plugin - 1.2.9 + 1.2.10-SNAPSHOT maven-plugin Snyk.io Maven Plugin diff --git a/src/it/settings.xml b/src/it/settings.xml index 1f16e10..bd30daa 100644 --- a/src/it/settings.xml +++ b/src/it/settings.xml @@ -8,7 +8,7 @@ true - 1.2.9 + 1.2.10-SNAPSHOT diff --git a/src/main/java/io/snyk/maven/plugins/SnykMonitor.java b/src/main/java/io/snyk/maven/plugins/SnykMonitor.java index dbfa15c..304d59d 100644 --- a/src/main/java/io/snyk/maven/plugins/SnykMonitor.java +++ b/src/main/java/io/snyk/maven/plugins/SnykMonitor.java @@ -79,6 +79,9 @@ public class SnykMonitor extends AbstractMojo { @Parameter(property = "snyk.skip") private boolean skip; + @Parameter(property = "snyk.longFormProjectName") + private boolean longFormProjectName; + private String baseUrl = ""; /** @@ -176,6 +179,10 @@ private HttpResponse sendDataToSnyk(JSONObject projectTree) private JSONObject prepareRequestBody(JSONObject projectTree) { JSONObject body = new JSONObject(); + if (longFormProjectName) { + projectTree.replace("name", projectTree.get("name") + ":" + projectTree.get("version")); + } + JSONObject meta = new JSONObject(); String groupId = project.getGroupId(); String artifactId = project.getArtifactId(); diff --git a/src/main/java/io/snyk/maven/plugins/SnykTest.java b/src/main/java/io/snyk/maven/plugins/SnykTest.java index c466bc4..dba2985 100644 --- a/src/main/java/io/snyk/maven/plugins/SnykTest.java +++ b/src/main/java/io/snyk/maven/plugins/SnykTest.java @@ -82,6 +82,9 @@ public class SnykTest extends AbstractMojo { @Parameter(property = "snyk.skip") private boolean skip; + @Parameter(property = "snyk.longFormProjectName") + private boolean longFormProjectName; + private String baseUrl = ""; private static int SEVERITY_LOW = 100; @@ -140,6 +143,10 @@ private void executeInternal() throws MojoFailureException, IOException { JSONObject projectTree = new ProjectTraversal( project, repoSystem, repoSession, remoteRepositories, includeProvidedDependencies).getTree(); + if (longFormProjectName) { + projectTree.replace("name", projectTree.get("name") + ":" + projectTree.get("version")); + } + HttpResponse response = sendDataToSnyk(projectTree); parseResponse(response); }