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

Remove usage of obsolete trilead-putty key #200

Merged
merged 7 commits into from
Mar 27, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.util.Secret;

import java.util.List;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,19 @@
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import jenkins.model.Jenkins;
import net.jcip.annotations.GuardedBy;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.jenkins.ui.icon.Icon;
import org.jenkins.ui.icon.IconSet;
import org.jenkins.ui.icon.IconType;
import org.kohsuke.putty.PuTTYKey;
import org.kohsuke.stapler.DataBoundConstructor;

/**
Expand Down Expand Up @@ -154,24 +150,9 @@
}
long lastModified = privateKeySource.getPrivateKeysLastModified();
if (privateKeys == null || privateKeys.isEmpty() || lastModified > privateKeysLastModified) {
List<String> privateKeys = new ArrayList<>();
for (String privateKey : privateKeySource.getPrivateKeys()) {
try {
if (PuTTYKey.isPuTTYKeyFile(new StringReader(privateKey))) {
// strictly we should be encrypting the openssh version with the passphrase, but
// if the key we pass back does not have a passphrase, then the passphrase will not be
// checked, so not an issue.
privateKeys.add(new PuTTYKey(new StringReader(privateKey),
passphrase == null ? "" : passphrase.getPlainText())
.toOpenSSH());
} else {
privateKeys.add(privateKey.endsWith("\n") ? privateKey : privateKey + "\n");
}
} catch (IOException e) {
// ignore
}
}
this.privateKeys = privateKeys;
this.privateKeys = privateKeySource.getPrivateKeys().stream()
.map(privateKey -> privateKey.endsWith("\n") ? privateKey : privateKey + "\n")

Check warning on line 154 in src/main/java/com/cloudbees/jenkins/plugins/sshcredentials/impl/BasicSSHUserPrivateKey.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 154 is only partially covered, one branch is missing
.collect(Collectors.toList());
this.privateKeysLastModified = lastModified;
}
return privateKeys;
Expand Down
Loading