Skip to content

Commit

Permalink
[SECURITY-2176]
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Adrian-Tofan committed Mar 30, 2021
1 parent 9fbd698 commit b286378
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -489,7 +489,7 @@
<dependency>
<groupId>com.microfocus.sv</groupId>
<artifactId>SVConfigurator</artifactId>
<version>5.3</version>
<version>5.4.1</version>
<exclusions>
<exclusion>
<groupId>commons-io</groupId>
Expand Down
Expand Up @@ -41,13 +41,15 @@ public class SvServerSettingsModel implements Serializable{

private final String name;
private final String url;
private final boolean trustEveryone;
private final String username;
private final Secret password;

@DataBoundConstructor
public SvServerSettingsModel(String name, String url, String username, Secret password) {
public SvServerSettingsModel(String name, String url, boolean trustEveryone, String username, Secret password) {
this.name = StringUtils.trim(name);
this.url = StringUtils.trim(url);
this.trustEveryone = trustEveryone;
this.username = username;
this.password = password;
}
Expand All @@ -64,6 +66,10 @@ public URL getUrlObject() throws MalformedURLException {
return new URL(url);
}

public boolean isTrustEveryone() {
return trustEveryone;
}

public String getUsername() {
return username;
}
Expand Down
Expand Up @@ -139,12 +139,14 @@ public FormValidation doCheckPassword(@QueryParameter String value, @QueryParame

@RequirePOST
@SuppressWarnings("unused")
public FormValidation doTestConnection(@QueryParameter("url") final String url, @QueryParameter("username") final String username,
public FormValidation doTestConnection(@QueryParameter("url") final String url,
@QueryParameter("trustEveryone") final boolean trustEveryone,
@QueryParameter("username") final String username,
@QueryParameter("password") final String password) {
try {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
Credentials credentials = (!StringUtils.isBlank(username)) ? new Credentials(username, password) : null;
ICommandExecutor commandExecutor = new CommandExecutorFactory().createCommandExecutor(new URL(url), credentials);
ICommandExecutor commandExecutor = new CommandExecutorFactory().createCommandExecutor(new URL(url), trustEveryone, credentials);
ServerInfo serverInfo = commandExecutor.getClient().getServerInfo();
return FormValidation.ok("Validation passed. Connected to %s server of version: %s", serverInfo.getServerType(), serverInfo.getProductVersion());
} catch (Exception e) {
Expand Down
Expand Up @@ -115,6 +115,7 @@ private void addServiceIfDeployed(String service, ArrayList<ServiceInfo> results
}

protected ICommandExecutor createCommandExecutor() throws Exception {
return new CommandExecutorFactory().createCommandExecutor(server.getUrlObject(), server.getCredentials());
return new CommandExecutorFactory()
.createCommandExecutor(server.getUrlObject(), server.isTrustEveryone(), server.getCredentials());
}
}
Expand Up @@ -91,8 +91,8 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnul
try {
SvServerSettingsModel serverModel = getSelectedServerSettings();

logger.printf("%nStarting %s for SV Server '%s' (%s as %s) on %s%n", getDescriptor().getDisplayName(),
serverModel.getName(), serverModel.getUrlObject(), serverModel.getUsername(), startDate);
logger.printf("%nStarting %s for SV Server '%s' (%s as %s, ignoreSslErrors=%s) on %s%n", getDescriptor().getDisplayName(),
serverModel.getName(), serverModel.getUrlObject(), serverModel.getUsername(), serverModel.isTrustEveryone(), startDate);
logConfig(logger, " ");
validateServiceSelection();

Expand Down
Expand Up @@ -54,6 +54,10 @@
<f:textbox value="${srv.url}"/>
</f:entry>

<f:entry title="${%Ignore SSL errors}" field="trustEveryone">
<f:checkbox value="${srv.trustEveryone}"/>
</f:entry>

<f:entry title="${%User name}" field="username">
<f:textbox value="${srv.username}"/>
</f:entry>
Expand All @@ -64,7 +68,7 @@

<f:validateButton
title="${%Test Connection}" progress="${%Testing...}"
method="testConnection" with="url,username,password"/>
method="testConnection" with="url,trustEveryone,username,password"/>

<f:entry title="">
<div align="right">
Expand Down

0 comments on commit b286378

Please sign in to comment.