Skip to content

Commit

Permalink
Merge branch 'master' into disable-usage-stats-in-fips-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck committed Sep 27, 2023
2 parents e4d8eab + 9dabd87 commit e94ecd1
Show file tree
Hide file tree
Showing 99 changed files with 1,137 additions and 385 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<a href="https://jenkins.io">
<img width="400" src="https://www.jenkins.io/images/jenkins-logo-title-dark.svg">
<img width="400" src="https://www.jenkins.io/images/jenkins-logo-title-dark.svg" alt="Jenkins logo">
</a>

# About
Expand Down
2 changes: 1 addition & 1 deletion ath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -o xtrace
cd "$(dirname "$0")"

# https://github.com/jenkinsci/acceptance-test-harness/releases
export ATH_VERSION=5699.v27deb_ef5796c
export ATH_VERSION=5717.v51fb_b_1f0f6d1

if [[ $# -eq 0 ]]; then
export JDK=17
Expand Down
10 changes: 2 additions & 8 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ THE SOFTWARE.
<properties>
<asm.version>9.5</asm.version>
<slf4jVersion>2.0.9</slf4jVersion>
<stapler.version>1802.v9e2750160d01</stapler.version>
<stapler.version>1814.vdc9dd5217ee2</stapler.version>
<groovy.version>2.4.21</groovy.version>
</properties>

Expand All @@ -64,7 +64,7 @@ THE SOFTWARE.
<!-- https://docs.spring.io/spring-security/site/docs/5.5.4/reference/html5/#getting-maven-no-boot -->
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-bom</artifactId>
<version>5.8.6</version>
<version>5.8.7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -175,12 +175,6 @@ THE SOFTWARE.
<artifactId>jcip-annotations</artifactId>
<version>1.0</version>
</dependency>
<!-- TODO remove after determining this will not break plugins -->
<dependency>
<groupId>net.sf.kxml</groupId>
<artifactId>kxml2</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
<executions>
<execution>
<goals>
Expand Down
5 changes: 0 additions & 5 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,6 @@ THE SOFTWARE.
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
</dependency>
<!-- TODO remove after determining this will not break plugins -->
<dependency>
<groupId>net.sf.kxml</groupId>
<artifactId>kxml2</artifactId>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
Expand Down
21 changes: 2 additions & 19 deletions core/src/main/java/hudson/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import static hudson.init.InitMilestone.PLUGINS_LISTED;
import static hudson.init.InitMilestone.PLUGINS_PREPARED;
import static hudson.init.InitMilestone.PLUGINS_STARTED;
import static java.nio.file.attribute.PosixFilePermission.OWNER_READ;
import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
Expand Down Expand Up @@ -83,18 +81,15 @@
import java.net.URLConnection;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;
import java.security.CodeSource;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -1883,16 +1878,6 @@ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, Servl
copier = new FileUploadPluginCopier(fileItem);
}

if (FileSystems.getDefault().supportedFileAttributeViews().contains("posix")) {
Arrays.stream(Objects.requireNonNull(tmpDir.listFiles())).forEach((file -> {
try {
Files.setPosixFilePermissions(file.toPath(), EnumSet.of(OWNER_READ, OWNER_WRITE));
} catch (IOException e) {
throw new RuntimeException(e);
}
}));
}

if ("".equals(fileName)) {
return new HttpRedirect("advanced");
}
Expand All @@ -1902,7 +1887,8 @@ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, Servl
}

// first copy into a temporary file name
File t = File.createTempFile("uploaded", ".jpi");
File t = File.createTempFile("uploaded", ".jpi", tmpDir);
tmpDir.deleteOnExit();
t.deleteOnExit();
// TODO Remove this workaround after FILEUPLOAD-293 is resolved.
Files.delete(Util.fileToPath(t));
Expand All @@ -1913,9 +1899,6 @@ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, Servl
throw new ServletException(e);
}
copier.cleanup();
if (!tmpDir.delete()) {
System.err.println("Failed to delete temporary directory: " + tmpDir);
}

final String baseName = identifyPluginShortName(t);

Expand Down
7 changes: 7 additions & 0 deletions core/src/main/java/hudson/ProxyConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import hudson.model.Descriptor;
import hudson.model.Saveable;
import hudson.model.listeners.SaveableListener;
import hudson.util.DaemonThreadFactory;
import hudson.util.FormValidation;
import hudson.util.NamingThreadFactory;
import hudson.util.Scrambler;
import hudson.util.Secret;
import hudson.util.XStream2;
Expand All @@ -58,6 +60,8 @@
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import jenkins.UserAgentURLConnectionDecorator;
Expand Down Expand Up @@ -370,6 +374,8 @@ public static HttpClient newHttpClient() {
return newHttpClientBuilder().followRedirects(HttpClient.Redirect.NORMAL).build();
}

private static final Executor httpClientExecutor = Executors.newCachedThreadPool(new NamingThreadFactory(new DaemonThreadFactory(), "Jenkins HttpClient"));

/**
* Create a new {@link HttpClient.Builder} preconfigured with Jenkins-specific default settings.
*
Expand Down Expand Up @@ -397,6 +403,7 @@ public static HttpClient.Builder newHttpClientBuilder() {
if (DEFAULT_CONNECT_TIMEOUT_MILLIS > 0) {
httpClientBuilder.connectTimeout(Duration.ofMillis(DEFAULT_CONNECT_TIMEOUT_MILLIS));
}
httpClientBuilder.executor(httpClientExecutor);
return httpClientBuilder;
}

Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/hudson/XmlFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ private Object unmarshal(Object o, boolean nullOut) throws IOException {
}

public void write(Object o) throws IOException {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, new Throwable(), () -> "Writing " + file);
}
mkdirs();
AtomicFileWriter w = force
? new AtomicFileWriter(file)
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/console/ExpandableDetailsNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.Functions;
import hudson.MarkupText;
import java.io.IOException;
import java.util.logging.Level;
Expand All @@ -52,7 +53,7 @@ public ExpandableDetailsNote(String caption, String html) {
@Override
public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
text.addMarkup(charPos,
"<input type=button value='" + caption + "' class='reveal-expandable-detail'><div class='expandable-detail'>" + html + "</div>");
"<input type=button value='" + Functions.htmlAttributeEscape(caption) + "' class='reveal-expandable-detail'><div class='expandable-detail'>" + html + "</div>");
return null;
}

Expand Down
12 changes: 11 additions & 1 deletion core/src/main/java/hudson/logging/LogRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,16 @@ public int hashCode() {
*/
@RequirePOST
public synchronized void doDoDelete(StaplerResponse rsp) throws IOException, ServletException {
delete();
rsp.sendRedirect2("..");
}

/**
* Deletes this log recorder.
* @throws IOException In case anything went wrong while deleting the configuration file.
* @since TODO
*/
public void delete() throws IOException {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);

getConfigFile().delete();
Expand All @@ -544,7 +554,7 @@ public synchronized void doDoDelete(StaplerResponse rsp) throws IOException, Ser
loggers.forEach(Target::disable);

getParent().getRecorders().forEach(logRecorder -> logRecorder.getLoggers().forEach(Target::enable));
rsp.sendRedirect2("..");
SaveableListener.fireOnChange(this, getConfigFile());
}

/**
Expand Down
12 changes: 9 additions & 3 deletions core/src/main/java/hudson/model/AbstractItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,15 @@ public final String getUrl() {
View view = (View) last.getObject();
if (view.getOwner().getItemGroup() == getParent() && !view.isDefault()) {
// Showing something inside a view, so should use that as the base URL.
String base = last.getUrl().substring(req.getContextPath().length() + 1) + '/';
LOGGER.log(Level.FINER, "using {0}{1} for {2} from {3}", new Object[] {base, shortUrl, this, uri});
return base + shortUrl;
String prefix = req.getContextPath() + "/";
String url = last.getUrl();
if (url.startsWith(prefix)) {
String base = url.substring(prefix.length()) + '/';
LOGGER.log(Level.FINER, "using {0}{1} for {2} from {3} given {4}", new Object[] {base, shortUrl, this, uri, prefix});
return base + shortUrl;
} else {
LOGGER.finer(() -> url + " does not start with " + prefix + " as expected");
}
} else {
LOGGER.log(Level.FINER, "irrelevant {0} for {1} from {2}", new Object[] {view.getViewName(), this, uri});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import hudson.Util;
import hudson.model.Queue.WaitingItem;
import hudson.model.queue.ScheduleResult;
import hudson.util.AlternativeUiTextProvider;
import java.io.IOException;
import java.util.AbstractList;
import java.util.ArrayList;
Expand Down Expand Up @@ -72,6 +73,8 @@
public class ParametersDefinitionProperty extends OptionalJobProperty<Job<?, ?>>
implements Action {

public static final AlternativeUiTextProvider.Message<Job> BUILD_BUTTON_TEXT = new AlternativeUiTextProvider.Message<>();

private final List<ParameterDefinition> parameterDefinitions;

@DataBoundConstructor
Expand All @@ -87,6 +90,11 @@ private Object readResolve() {
return parameterDefinitions == null ? new ParametersDefinitionProperty() : this;
}


public final String getBuildButtonText() {
return AlternativeUiTextProvider.get(BUILD_BUTTON_TEXT, owner, Messages.ParametersDefinitionProperty_BuildButtonText());
}

@Deprecated
public AbstractProject<?, ?> getOwner() {
return (AbstractProject) owner;
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/java/hudson/model/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -1896,8 +1896,6 @@ protected final void execute(@NonNull RunExecution job) {

LOGGER.log(FINE, "{0} main build action completed: {1}", new Object[] {this, result});
CheckPoint.MAIN_COMPLETED.report();
} catch (ThreadDeath t) {
throw t;
} catch (AbortException e) { // orderly abortion.
result = Result.FAILURE;
listener.error(e.getMessage());
Expand All @@ -1919,8 +1917,6 @@ protected final void execute(@NonNull RunExecution job) {
// even if the main build fails fatally, try to run post build processing
job.post(Objects.requireNonNull(listener));

} catch (ThreadDeath t) {
throw t;
} catch (Throwable e) {
handleFatalBuildProblem(listener, e);
result = Result.FAILURE;
Expand Down
28 changes: 22 additions & 6 deletions core/src/main/java/hudson/model/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public synchronized String getDescription() {

@DataBoundSetter
public synchronized void setDescription(String description) {
this.description = description;
this.description = Util.nullify(description);
}

/**
Expand Down Expand Up @@ -405,13 +405,29 @@ public boolean isFilterExecutors() {
return filterExecutors;
}

/**
* @since TODO
*/
@DataBoundSetter
public void setFilterExecutors(boolean filterExecutors) {
this.filterExecutors = filterExecutors;
}

/**
* If true, only show relevant queue items
*/
public boolean isFilterQueue() {
return filterQueue;
}

/**
* @since TODO
*/
@DataBoundSetter
public void setFilterQueue(boolean filterQueue) {
this.filterQueue = filterQueue;
}

/**
* If this view uses {@code <t:projectView>} for rendering, this method returns columns to be displayed.
*/
Expand Down Expand Up @@ -1013,13 +1029,13 @@ public final synchronized void doConfigSubmit(StaplerRequest req, StaplerRespons

submit(req);

description = Util.nullify(req.getParameter("description"));
filterExecutors = req.getParameter("filterExecutors") != null;
filterQueue = req.getParameter("filterQueue") != null;

var json = req.getSubmittedForm();
setDescription(json.optString("description"));
setFilterExecutors(json.optBoolean("filterExecutors"));
setFilterQueue(json.optBoolean("filterQueue"));
rename(req.getParameter("name"));

getProperties().rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors());
getProperties().rebuild(req, json, getApplicablePropertyDescriptors());

save();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public static void fireOnChange(Saveable o, XmlFile file) {
for (SaveableListener l : all()) {
try {
l.onChange(o, file);
} catch (ThreadDeath t) {
throw t;
} catch (Throwable t) {
Logger.getLogger(SaveableListener.class.getName()).log(Level.WARNING, null, t);
}
Expand Down
11 changes: 6 additions & 5 deletions core/src/main/java/hudson/tasks/Publisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ public Descriptor<Publisher> getDescriptor() {
*
* @see DescriptorExtensionList#createDescriptorList(hudson.model.Hudson, Class)
*/
@SuppressFBWarnings(value = "SE_COMPARATOR_SHOULD_BE_SERIALIZABLE", justification = "Since the publisher is not Serializable, " +
"no need for the Comparator")
public static final class DescriptorExtensionListImpl extends DescriptorExtensionList<Publisher, Descriptor<Publisher>>
implements Comparator<ExtensionComponent<Descriptor<Publisher>>> {
public static final class DescriptorExtensionListImpl extends DescriptorExtensionList<Publisher, Descriptor<Publisher>> {

public DescriptorExtensionListImpl(Jenkins hudson) {
super(hudson, Publisher.class);
Expand All @@ -142,10 +139,14 @@ public DescriptorExtensionListImpl(Jenkins hudson) {
@Override
protected List<ExtensionComponent<Descriptor<Publisher>>> sort(List<ExtensionComponent<Descriptor<Publisher>>> r) {
List<ExtensionComponent<Descriptor<Publisher>>> copy = new ArrayList<>(r);
copy.sort(this);
copy.sort(new ExtensionComponentComparator());
return copy;
}
}

@SuppressFBWarnings(value = "SE_COMPARATOR_SHOULD_BE_SERIALIZABLE", justification = "Since the publisher is not Serializable, " +
"no need for the Comparator")
private static final class ExtensionComponentComparator implements Comparator<ExtensionComponent<Descriptor<Publisher>>> {
@Override
public int compare(ExtensionComponent<Descriptor<Publisher>> lhs, ExtensionComponent<Descriptor<Publisher>> rhs) {
int r = classify(lhs.getInstance()) - classify(rhs.getInstance());
Expand Down
Loading

0 comments on commit e94ecd1

Please sign in to comment.