Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to override the Project group name in the Snyk UI #90

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The Snyk Maven plugin tests and monitors your Maven dependencies.
<plugin>
<groupId>io.snyk</groupId>
<artifactId>snyk-maven-plugin</artifactId>
<version>1.2.9</version>
<version>1.2.10-SNAPSHOT</version>
<executions>
<execution>
<id>snyk-test</id>
Expand Down Expand Up @@ -65,6 +65,7 @@ The following are elements in the `<configuration></configuration>` 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`.
- **remoteRepoUrl** (optional): The **remoteRepoUrl** configuration element allows to override the Project group name in the Snyk UI. Leaving out this configuration will record the project under the default group name `groupId:artifactId`.

## Features

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.snyk</groupId>
<artifactId>snyk-maven-plugin</artifactId>
<version>1.2.9</version>
<version>1.2.10-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Snyk.io Maven Plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion src/it/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<snyk.maven.plugin.version>1.2.9</snyk.maven.plugin.version>
<snyk.maven.plugin.version>1.2.10-SNAPSHOT</snyk.maven.plugin.version>
</properties>
<repositories>
<repository>
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/io/snyk/maven/plugins/SnykMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class SnykMonitor extends AbstractMojo {
@Parameter
private String org = "";

@Parameter(property = "snyk.remoteRepoUrl")
private String remoteRepoUrl = "";

@Parameter
private String endpoint = Constants.DEFAULT_ENDPOINT;

Expand Down Expand Up @@ -176,6 +179,10 @@ private HttpResponse sendDataToSnyk(JSONObject projectTree)
private JSONObject prepareRequestBody(JSONObject projectTree) {
JSONObject body = new JSONObject();

if (!remoteRepoUrl.equals("")) {
projectTree.replace("name", remoteRepoUrl);
}

JSONObject meta = new JSONObject();
String groupId = project.getGroupId();
String artifactId = project.getArtifactId();
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/io/snyk/maven/plugins/SnykTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class SnykTest extends AbstractMojo {
@Parameter
private String org = "";

@Parameter(property = "snyk.remoteRepoUrl")
private String remoteRepoUrl = "";

@Parameter
private String failOnSeverity = "low";

Expand Down Expand Up @@ -140,6 +143,10 @@ private void executeInternal() throws MojoFailureException, IOException {
JSONObject projectTree = new ProjectTraversal(
project, repoSystem, repoSession, remoteRepositories, includeProvidedDependencies).getTree();

if (!remoteRepoUrl.equals("")) {
projectTree.replace("name", remoteRepoUrl);
}

HttpResponse response = sendDataToSnyk(projectTree);
parseResponse(response);
}
Expand Down