Skip to content

Commit

Permalink
Merge pull request #16 from rundeck-plugins/RUN-1537
Browse files Browse the repository at this point in the history
RUN-1537: report the list of keys
  • Loading branch information
ltamaster authored Jun 6, 2023
2 parents 457c69d + 93ba809 commit 91e1985
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
pluginLibs group: 'commons-io', name: 'commons-io', version: '2.6', ext: 'jar'
pluginLibs group: 'net.sf.expectit', name: 'expectit-core', version: '0.9.0'

implementation 'org.rundeck:rundeck-core:4.6.1-20220914'
implementation 'org.rundeck:rundeck-core:4.14.0-rc1-20230606'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.26'

testImplementation 'junit:junit:4.12'
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/plugin/sshjplugin/SSHJFileCopierPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,9 @@ private String[] copyMultipleFiles(
public SecretBundle prepareSecretBundle(ExecutionContext context, INodeEntry node) {
return SSHJSecretBundleUtil.createBundle(context, node);
}

@Override
public List<String> listSecretsPath(ExecutionContext context, INodeEntry node) {
return SSHJSecretBundleUtil.getSecretsPath(context, node);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.commons.lang.StringUtils;

import java.util.Arrays;
import java.util.List;


@Plugin(service = ServiceNameConstants.NodeExecutor, name = SSHJNodeExecutorPlugin.SERVICE_PROVIDER_NAME)
Expand Down Expand Up @@ -333,6 +334,11 @@ public SecretBundle prepareSecretBundle(ExecutionContext context, INodeEntry nod
return SSHJSecretBundleUtil.createBundle(context, node);
}

@Override
public List<String> listSecretsPath(ExecutionContext context, INodeEntry node) {
return SSHJSecretBundleUtil.getSecretsPath(context, node);
}

static class ExtractFailure {

private String errormsg;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/plugin/sshjplugin/model/SSHJConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static enum AuthenticationType {

String getPrivateKeyPath() throws IOException;

String getPrivateKeyStoragePath() throws IOException;
String getPrivateKeyStoragePath();

InputStream getPrivateKeyStorageData(String path);

Expand All @@ -29,7 +29,7 @@ static enum AuthenticationType {

String getSudoPassword(String path) throws IOException;

String getPrivateKeyPassphraseStoragePath() throws IOException;
String getPrivateKeyPassphraseStoragePath();

String getPrivateKeyPassphrase(String path) throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String getPrivateKeyPath() throws IOException {
}

@Override
public String getPrivateKeyStoragePath() throws IOException {
public String getPrivateKeyStoragePath(){

String path = propertyResolver.resolve(SSHJNodeExecutorPlugin.NODE_ATTR_SSH_KEY_RESOURCE);
if (path == null && framework.hasProperty(Constants.SSH_KEYRESOURCE_PROP)) {
Expand Down Expand Up @@ -156,7 +156,7 @@ public String getSudoPassword(String path) throws IOException {
}

@Override
public String getPrivateKeyPassphraseStoragePath() throws IOException {
public String getPrivateKeyPassphraseStoragePath() {
return propertyResolver.getStoragePath(SSHJNodeExecutorPlugin.NODE_ATTR_SSH_KEY_PASSPHRASE_STORAGE_PATH);
}

Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/plugin/sshjplugin/util/SSHJSecretBundleUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class SSHJSecretBundleUtil {

Expand Down Expand Up @@ -51,4 +53,25 @@ public static SecretBundle createBundle(final ExecutionContext context, final IN
}
}

public static List<String> getSecretsPath(ExecutionContext context, INodeEntry node) {
List<String> listSecretsPath = new ArrayList<>();
final SSHJConnectionParameters nodeAuthentication = new SSHJConnectionParameters(node,context);

if(nodeAuthentication.getPasswordStoragePath() != null) {
listSecretsPath.add(nodeAuthentication.getPasswordStoragePath());
}
if(nodeAuthentication.getPrivateKeyPassphraseStoragePath() != null) {
listSecretsPath.add(nodeAuthentication.getPrivateKeyPassphraseStoragePath());
}
if(nodeAuthentication.getPrivateKeyStoragePath() != null) {
listSecretsPath.add(nodeAuthentication.getPrivateKeyStoragePath());
}

if(nodeAuthentication.getSudoPasswordStoragePath() != null) {
listSecretsPath.add(nodeAuthentication.getSudoPasswordStoragePath());
}

return listSecretsPath;
}

}

0 comments on commit 91e1985

Please sign in to comment.