-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into bugfix/addCredentials
- Loading branch information
Showing
27 changed files
with
408 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/com/cloudbees/plugins/credentials/SecretBytesRedaction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.cloudbees.plugins.credentials; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import jenkins.security.ExtendedReadRedaction; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
||
@Restricted(NoExternalUse.class) | ||
// @Extension | ||
// See SecretBytesReactionExtension | ||
public class SecretBytesRedaction implements ExtendedReadRedaction { | ||
private static final Pattern SECRET_BYTES_PATTERN = Pattern.compile(">(" + SecretBytes.ENCRYPTED_VALUE_PATTERN + ")<"); | ||
|
||
@Override | ||
public String apply(String configDotXml) { | ||
Matcher matcher = SECRET_BYTES_PATTERN.matcher(configDotXml); | ||
StringBuilder cleanXml = new StringBuilder(); | ||
while (matcher.find()) { | ||
if (SecretBytes.isSecretBytes(matcher.group(1))) { | ||
matcher.appendReplacement(cleanXml, ">********<"); | ||
} | ||
} | ||
matcher.appendTail(cleanXml); | ||
return cleanXml.toString(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/cloudbees/plugins/credentials/SecretBytesRedactionExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.cloudbees.plugins.credentials; | ||
|
||
import hudson.ExtensionList; | ||
import hudson.init.Initializer; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import jenkins.security.ExtendedReadRedaction; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
||
@Restricted(NoExternalUse.class) | ||
public class SecretBytesRedactionExtension { | ||
|
||
public static final Logger LOGGER = Logger.getLogger(SecretBytesRedactionExtension.class.getName()); | ||
|
||
// TODO Delete this and annotate `SecretBytesRedaction` with `@Extension` once the core dependency is >= 2.479 | ||
@Initializer | ||
public static void create() { | ||
try { | ||
ExtensionList.lookup(ExtendedReadRedaction.class).add(new SecretBytesRedaction()); | ||
} catch (NoClassDefFoundError unused) { | ||
LOGGER.log(Level.WARNING, "Failed to register SecretBytesRedaction. Update Jenkins to add support for redacting credentials in config.xml files from users with ExtendedRead permission. Learn more: https://www.jenkins.io/redirect/plugin/credentials/SecretBytesRedaction/"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/resources/com/cloudbees/plugins/credentials/common/formBehaviour.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Behaviour.specify(".required-for-submit", 'required-for-submit', -99, function(requiredField) { | ||
const saveButton = requiredField.closest("form").querySelector('[name="Submit"]'); | ||
function updateSave() { | ||
const state = requiredField.value.length === 0; | ||
saveButton.disabled = state; | ||
} | ||
requiredField.addEventListener('input', updateSave); | ||
updateSave(saveButton); | ||
}); | ||
|
||
Behaviour.specify(".autofocus", "autofocus", 0, function(el) { | ||
el.focus(); | ||
}); |
Oops, something went wrong.