Skip to content

Commit 079a4cb

Browse files
committed
Remove FileOnMasterKeySource and SECURITY-1322 migration
It has been 5 years since the security fix was introduced and the migration code occureed. Whilst an admin could have still (ab)used the CLI/REST to set a FileOnMaster they could not do this from the UI creating a disparity. This change removes the migration and the ability to use this via CLI/REST
1 parent 5e08c0a commit 079a4cb

File tree

13 files changed

+3
-442
lines changed

13 files changed

+3
-442
lines changed

pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@
169169
</goals>
170170
</execution>
171171
</executions>
172+
<configuration>
173+
<compatibleSinceVersion>1344</compatibleSinceVersion>
174+
</configuration>
172175
</plugin>
173176
<plugin>
174177
<groupId>org.antlr</groupId>

src/main/java/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl.java

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,10 @@
3737
import hudson.util.FormValidation;
3838
import hudson.util.Secret;
3939
import java.io.ByteArrayInputStream;
40-
import java.io.File;
4140
import java.io.IOException;
4241
import java.io.ObjectStreamException;
4342
import java.io.Serializable;
4443
import java.nio.charset.StandardCharsets;
45-
import java.nio.file.Files;
46-
import java.nio.file.InvalidPathException;
47-
import java.nio.file.Paths;
4844
import java.security.KeyStore;
4945
import java.security.KeyStoreException;
5046
import java.security.NoSuchAlgorithmException;
@@ -58,7 +54,6 @@
5854
import java.util.logging.LogRecord;
5955
import java.util.logging.Logger;
6056

61-
import jenkins.model.Jenkins;
6257
import net.jcip.annotations.GuardedBy;
6358
import org.apache.commons.fileupload.FileItem;
6459
import org.apache.commons.lang.StringUtils;
@@ -337,72 +332,6 @@ protected static FormValidation validateCertificateKeystore(String type, byte[]
337332
}
338333
}
339334

340-
/**
341-
* Let the user reference a file on the disk.
342-
* @deprecated This approach has security vulnerabilities and should be migrated to {@link UploadedKeyStoreSource}
343-
*/
344-
@Deprecated
345-
public static class FileOnMasterKeyStoreSource extends KeyStoreSource {
346-
347-
/**
348-
* Our logger.
349-
*/
350-
private static final Logger LOGGER = Logger.getLogger(FileOnMasterKeyStoreSource.class.getName());
351-
352-
/**
353-
* The path of the file on the controller.
354-
*/
355-
private final String keyStoreFile;
356-
357-
public FileOnMasterKeyStoreSource(String keyStoreFile) {
358-
this.keyStoreFile = keyStoreFile;
359-
}
360-
361-
/**
362-
* {@inheritDoc}
363-
*/
364-
@NonNull
365-
@Override
366-
public byte[] getKeyStoreBytes() {
367-
try {
368-
return Files.readAllBytes(Paths.get(keyStoreFile));
369-
} catch (IOException | InvalidPathException e) {
370-
LOGGER.log(Level.WARNING, "Could not read private key file " + keyStoreFile, e);
371-
return new byte[0];
372-
}
373-
}
374-
375-
/**
376-
* {@inheritDoc}
377-
*/
378-
@Override
379-
public long getKeyStoreLastModified() {
380-
return new File(keyStoreFile).lastModified();
381-
}
382-
383-
/**
384-
* {@inheritDoc}
385-
*/
386-
@Override
387-
public String toString() {
388-
return "FileOnMasterKeyStoreSource{" +
389-
"keyStoreFile='" + keyStoreFile + '\'' +
390-
"}";
391-
}
392-
393-
private Object readResolve() {
394-
if (!Jenkins.get().hasPermission(Jenkins.RUN_SCRIPTS)) {
395-
LOGGER.warning("SECURITY-1322: Permission failure migrating FileOnMasterKeyStoreSource to UploadedKeyStoreSource for a Certificate. An administrator may need to perform the migration.");
396-
Jenkins.get().checkPermission(Jenkins.RUN_SCRIPTS);
397-
}
398-
399-
LOGGER.log(Level.INFO, "SECURITY-1322: Migrating FileOnMasterKeyStoreSource to UploadedKeyStoreSource. The containing item may need to be saved to complete the migration.");
400-
SecretBytes secretBytes = SecretBytes.fromBytes(getKeyStoreBytes());
401-
return new UploadedKeyStoreSource(secretBytes);
402-
}
403-
404-
}
405-
406335
/**
407336
* Let the user reference an uploaded file.
408337
*/

src/main/resources/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl/FileOnMasterKeyStoreSource/config.jelly

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/main/resources/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl/FileOnMasterKeyStoreSource/config_de.properties

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/main/resources/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl/FileOnMasterKeyStoreSource/config_fr.properties

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/main/resources/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl/FileOnMasterKeyStoreSource/config_it.properties

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/main/resources/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl/FileOnMasterKeyStoreSource/config_ja.properties

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/main/resources/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl/FileOnMasterKeyStoreSource/help-keyStoreFile.html

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/main/resources/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl/FileOnMasterKeyStoreSource/help-keyStoreFile_fr.html

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/main/resources/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl/FileOnMasterKeyStoreSource/help-keyStoreFile_it.html

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)