mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-05 16:15:54 +00:00
Add findsecbugs plugin to spotbugs.
And suppress existing warnings. We should clean some of them up, but that's for different PRs.
This commit is contained in:
1 parent
30dbf728ec
commit
c76ee59810
21 files changed
+63
-2
No files matched your search
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
package hudson.cli;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import hudson.cli.client.Messages;
|
||||
import java.io.DataInputStream;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
@@ -104,6 +105,7 @@ public class CLI {
|
||||
}
|
||||
|
||||
private enum Mode {HTTP, SSH, WEB_SOCKET}
|
||||
@SuppressFBWarnings(value = {"PATH_TRAVERSAL_IN", "URLCONNECTION_SSRF_FD"}, justification = "User provided values for running the program.")
|
||||
public static int _main(String[] _args) throws Exception {
|
||||
List<String> args = Arrays.asList(_args);
|
||||
PrivateKeyProvider provider = new PrivateKeyProvider();
|
||||
@@ -175,6 +177,7 @@ public class CLI {
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
|
||||
// bypass host name check, too.
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
|
||||
@SuppressFBWarnings(value = "WEAK_HOSTNAME_VERIFIER", justification = "User set parameter to skip verifier.")
|
||||
public boolean verify(String s, SSLSession sslSession) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package hudson.cli;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StreamCorruptedException;
|
||||
import java.io.StringWriter;
|
||||
@@ -11,6 +13,7 @@ import java.io.StringWriter;
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
@SuppressFBWarnings(value = "INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE")
|
||||
class DiagnosedStreamCorruptionException extends StreamCorruptedException {
|
||||
private final Exception diagnoseFailure;
|
||||
private final byte[] readBack;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package hudson.cli;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -44,6 +46,7 @@ public class FullDuplexHttpStream {
|
||||
* @param authorization
|
||||
* The value of the authorization header, if non-null.
|
||||
*/
|
||||
@SuppressFBWarnings(value = "URLCONNECTION_SSRF_FD", justification = "Client-side code doesn't involve SSRF.")
|
||||
public FullDuplexHttpStream(URL base, String relativeTarget, String authorization) throws IOException {
|
||||
if (!base.toString().endsWith("/")) {
|
||||
throw new IllegalArgumentException(base.toString());
|
||||
@@ -93,6 +96,7 @@ public class FullDuplexHttpStream {
|
||||
}
|
||||
|
||||
// As this transport mode is using POST, it is necessary to resolve possible redirections using GET first.
|
||||
@SuppressFBWarnings(value = "URLCONNECTION_SSRF_FD", justification = "Client-side code doesn't involve SSRF.")
|
||||
private URL tryToResolveRedirects(URL base, String authorization) {
|
||||
try {
|
||||
HttpURLConnection con = (HttpURLConnection) base.openConnection();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package hudson.cli;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
@@ -7,6 +9,7 @@ import java.security.cert.X509Certificate;
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
@SuppressFBWarnings(value = "WEAK_TRUST_MANAGER", justification = "User set parameter to skip verifier.")
|
||||
public class NoCheckTrustManager implements X509TrustManager {
|
||||
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
*/
|
||||
class SSHCLI {
|
||||
|
||||
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE", justification = "Due to whatever reason FindBugs reports it fot try-with-resources")
|
||||
@SuppressFBWarnings(value = "URLCONNECTION_SSRF_FD", justification = "Client-side code doesn't involve SSRF.")
|
||||
static int sshConnection(String jenkinsUrl, String user, List<String> args, PrivateKeyProvider provider, final boolean strictHostKey) throws IOException {
|
||||
Logger.getLogger(SecurityUtils.class.getName()).setLevel(Level.WARNING); // suppress: BouncyCastle not registered, using the default JCE provider
|
||||
URL url = new URL(jenkinsUrl + "login");
|
||||
|
||||
Reference in new issue
Block a user