Skip to content

Commit 19b02b5

Browse files
authored
Merge branch 'master' into expiring-tokens
2 parents 24d2292 + e690ade commit 19b02b5

File tree

77 files changed

+4407
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4407
-145
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<!-- Comment:
22
A great PR typically begins with the line below.
3-
Replace XXXXX with the numeric part of the issue ID you created in Jira.
4-
Note that if you want your changes backported into LTS, you need to create a Jira issue. See https://www.jenkins.io/download/lts/#backporting-process for more information.
3+
Replace <issue-number> with the issue number.
54
-->
65

7-
See [JENKINS-XXXXX](https://issues.jenkins.io/browse/JENKINS-XXXXX).
6+
Fixes #<issue-number>
87

98
<!-- Comment:
10-
If the issue is not fully described in Jira, add more information here (justification, pull request links, etc.).
9+
If the issue is not fully described in the issue tracker, add more information here (justification, pull request links, etc.).
1110
12-
* We do not require Jira issues for minor improvements.
13-
* Bug fixes should have a Jira issue to facilitate the backporting process.
14-
* Major new features should have a Jira issue.
11+
* We do not require an issue for minor improvements.
12+
* Major new features should have an issue created.
1513
-->
1614

1715
### Testing done
@@ -34,8 +32,8 @@ For refactoring and code cleanup changes, exercise the code before and after the
3432
The changelog entry should be in the imperative mood; e.g., write "do this"/"return that" rather than "does this"/"returns that".
3533
For examples, see: https://www.jenkins.io/changelog/
3634
37-
Do not include the Jira issue in the changelog entry.
38-
Include the Jira issue in the description of the pull request so that the changelog generator can find it and include it in the generated changelog.
35+
Do not include the issue in the changelog entry.
36+
Include the issue in the description of the pull request so that the changelog generator can find it and include it in the generated changelog.
3937
4038
You may add multiple changelog entries if applicable by adding a new entry to the list, e.g.
4139
- First changelog entry
@@ -82,7 +80,7 @@ The changelog generator relies on the presence of the upgrade guidelines section
8280

8381
### Submitter checklist
8482

85-
- [ ] The Jira issue, if it exists, is well-described.
83+
- [ ] The issue, if it exists, is well-described.
8684
- [ ] The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see [examples](https://github.com/jenkins-infra/jenkins.io/blob/master/content/_data/changelogs/weekly.yml)). Fill in the **Proposed upgrade guidelines** section only if there are breaking changes or changes that may require extra steps from users during upgrade.
8785
- [ ] There is automated testing or an explanation as to why this change has no tests.
8886
- [ ] New public classes, fields, and methods are annotated with `@Restricted` or have `@since TODO` Javadocs, as appropriate.
@@ -108,4 +106,4 @@ Before the changes are marked as `ready-for-merge`:
108106
- [ ] Changelog entries in the pull request title and/or **Proposed changelog entries** are accurate, human-readable, and in the imperative mood.
109107
- [ ] Proper changelog labels are set so that the changelog can be generated automatically.
110108
- [ ] If the change needs additional upgrade steps from users, the `upgrade-guide-needed` label is set and there is a **Proposed upgrade guidelines** section in the pull request title (see [example](https://github.com/jenkinsci/jenkins/pull/4387)).
111-
- [ ] If it would make sense to backport the change to LTS, a Jira issue must exist, be a _Bug_ or _Improvement_, and be labeled as `lts-candidate` to be considered (see [query](https://issues.jenkins.io/issues/?filter=12146)).
109+
- [ ] If it would make sense to backport the change to LTS, be a _Bug_ or _Improvement_, and either the issue or pull request must be labeled as `lts-candidate` to be considered.

.github/workflows/publish-release-artifact.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2020
- name: Set up JDK 21
21-
uses: actions/setup-java@46c56d6f92c88cf540acf95a12a4a41197499222 #v 5.0.0
21+
uses: actions/setup-java@4e7e684fbb6e33f88ecb2cf1e6b3797739cf499b #v 5.0.0
2222
with:
2323
distribution: "temurin"
2424
java-version: 21

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ This page provides information about contributing code to the Jenkins core codeb
1818

1919
If you want to contribute to Jenkins, or just learn about the project,
2020
you can start by fixing some easier issues.
21-
In the Jenkins issue tracker we mark such issues as `newbie-friendly`.
22-
You can find them by using this query (check the link) for [newbie friendly issues](<https://issues.jenkins.io/issues/?jql=project%20%3D%20JENKINS%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)%20AND%20component%20%3D%20core%20AND%20labels%20in%20(newbie-friendly)>).
21+
In the Jenkins issue tracker we mark such issues as `good first issue`.
22+
You can find them by using this query (check the link) for [good first issues](https://github.com/jenkinsci/jenkins/issues?q=is%3Aissue%20is%3Aopen%20label%3A%22good%20first%20issue%22).
2323

2424
## Building and Debugging
2525

@@ -261,4 +261,4 @@ just submit a pull request.
261261
- [Jenkins Contribution Landing Page](https://www.jenkins.io/participate/)
262262
- [Jenkins Chat Channels](https://www.jenkins.io/chat/)
263263
- [Beginners Guide To Contributing](https://www.jenkins.io/participate/)
264-
- [List of newbie-friendly issues in the core](<https://issues.jenkins.io/issues/?jql=project%20%3D%20JENKINS%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)%20AND%20component%20%3D%20core%20AND%20labels%20in%20(newbie-friendly)>)
264+
- [List of good first issues in core](https://github.com/jenkinsci/jenkins/issues?q=is%3Aissue%20is%3Aopen%20label%3A%22good%20first%20issue%22)

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ properties([
1414

1515
def axes = [
1616
platforms: ['linux', 'windows'],
17-
jdks: [17, 21, 25],
17+
jdks: [21, 25],
1818
]
1919

2020
stage('Record build') {
2121
retry(conditions: [kubernetesAgent(handleNonKubernetes: true), nonresumable()], count: 2) {
22-
node('maven-17') {
22+
node('maven-21') {
2323
infra.checkoutSCM()
2424

2525
/*

core/src/main/java/hudson/Functions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ public static String toEmailSafeString(String projectName) {
19901990
else
19911991
buf.append('_'); // escape
19921992
}
1993-
return String.valueOf(buf);
1993+
return buf.toString();
19941994
}
19951995

19961996
/**

core/src/main/java/hudson/markup/MarkupFormatter.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,8 @@
3535
import java.io.Writer;
3636
import java.util.Collections;
3737
import java.util.Map;
38-
import java.util.function.Function;
3938
import java.util.logging.Level;
4039
import java.util.logging.Logger;
41-
import java.util.stream.Collectors;
42-
import java.util.stream.Stream;
4340
import jenkins.util.SystemProperties;
4441
import org.kohsuke.accmod.Restricted;
4542
import org.kohsuke.accmod.restrictions.NoExternalUse;
@@ -133,7 +130,7 @@ public HttpResponse doPreviewDescription(@QueryParameter String text) throws IOE
133130
translate(text, w);
134131
Map<String, String> extraHeaders = Collections.emptyMap();
135132
if (PREVIEWS_SET_CSP) {
136-
extraHeaders = Stream.of("Content-Security-Policy", "X-WebKit-CSP", "X-Content-Security-Policy").collect(Collectors.toMap(Function.identity(), v -> "default-src 'none';"));
133+
extraHeaders = Map.of("Content-Security-Policy", "default-src 'none';");
137134
}
138135
return html(200, w.toString(), extraHeaders);
139136
}

core/src/main/java/hudson/model/DirectoryBrowserSupport.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import jenkins.security.MasterToSlaveCallable;
6565
import jenkins.security.ResourceDomainConfiguration;
6666
import jenkins.security.ResourceDomainRootAction;
67+
import jenkins.security.csp.CspHeader;
6768
import jenkins.util.SystemProperties;
6869
import jenkins.util.VirtualFile;
6970
import org.apache.commons.io.IOUtils;
@@ -398,13 +399,14 @@ private void serveFile(StaplerRequest2 req, StaplerResponse2 rsp, VirtualFile ro
398399
rsp.sendRedirect(302, ResourceDomainRootAction.get().getRedirectUrl(resourceToken, req.getRestOfPath()));
399400
} else {
400401
if (!ResourceDomainConfiguration.isResourceRequest(req)) {
401-
// if we're serving this from the main domain, set CSP headers
402+
// If we're serving this from the main domain, set CSP headers. These override the default CSP headers.
402403
String csp = SystemProperties.getString(CSP_PROPERTY_NAME, DEFAULT_CSP_VALUE);
403404
if (!csp.trim().isEmpty()) {
404405
// allow users to prevent sending this header by setting empty system property
405-
for (String header : new String[]{"Content-Security-Policy", "X-WebKit-CSP", "X-Content-Security-Policy"}) {
406-
rsp.setHeader(header, csp);
407-
}
406+
rsp.setHeader(CspHeader.ContentSecurityPolicy.getHeaderName(), csp);
407+
} else {
408+
// Clear the header value if configured by the user.
409+
rsp.setHeader(CspHeader.ContentSecurityPolicy.getHeaderName(), null);
408410
}
409411
}
410412
InputStream in;

core/src/main/java/hudson/model/UsageStatistics.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
import jenkins.security.FIPS140;
6868
import jenkins.util.SystemProperties;
6969
import net.sf.json.JSONObject;
70+
import org.kohsuke.accmod.Restricted;
71+
import org.kohsuke.accmod.restrictions.NoExternalUse;
7072
import org.kohsuke.stapler.StaplerRequest2;
7173

7274
/**
@@ -103,8 +105,7 @@ public UsageStatistics(String keyImage) {
103105
* Returns true if it's time for us to check for new version.
104106
*/
105107
public boolean isDue() {
106-
// user opted out (explicitly or FIPS is requested). no data collection
107-
if (!Jenkins.get().isUsageStatisticsCollected() || DISABLED || FIPS140.useCompliantAlgorithms()) {
108+
if (!isEnabled()) {
108109
return false;
109110
}
110111

@@ -116,6 +117,19 @@ public boolean isDue() {
116117
return false;
117118
}
118119

120+
/**
121+
* Returns whether between UI configuration, system property, and environment,
122+
* usage statistics should be submitted.
123+
*
124+
* @return true if and only if usage stats should be submitted
125+
* @since 2.539
126+
*/
127+
@Restricted(NoExternalUse.class)
128+
public static boolean isEnabled() {
129+
// user opted out (explicitly or FIPS is requested). no data collection
130+
return Jenkins.get().isUsageStatisticsCollected() && !DISABLED && !FIPS140.useCompliantAlgorithms();
131+
}
132+
119133
private RSAPublicKey getKey() {
120134
try {
121135
if (key == null) {

core/src/main/java/hudson/util/FormFieldValidator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ private void _errorWithMarkup(String message, String cssClass) throws IOExceptio
231231
} else {
232232
response.setContentType("text/html;charset=UTF-8");
233233
if (APPLY_CONTENT_SECURITY_POLICY_HEADERS) {
234-
for (String header : new String[]{"Content-Security-Policy", "X-WebKit-CSP", "X-Content-Security-Policy"}) {
235-
response.setHeader(header, "sandbox; default-src 'none';");
236-
}
234+
response.setHeader("Content-Security-Policy", "sandbox; default-src 'none';");
237235
}
238236
response.getWriter().print("<div class=" + cssClass + ">" +
239237
message + "</div>");

core/src/main/java/hudson/util/FormValidation.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,7 @@ public void generateResponse(StaplerRequest2 req, StaplerResponse2 rsp, Object n
612612
protected void respond(StaplerResponse2 rsp, String html) throws IOException, ServletException {
613613
rsp.setContentType("text/html;charset=UTF-8");
614614
if (APPLY_CONTENT_SECURITY_POLICY_HEADERS) {
615-
for (String header : new String[]{"Content-Security-Policy", "X-WebKit-CSP", "X-Content-Security-Policy"}) {
616-
rsp.setHeader(header, "sandbox; default-src 'none';");
617-
}
615+
rsp.setHeader("Content-Security-Policy", "sandbox; default-src 'none';");
618616
}
619617
rsp.getWriter().print(html);
620618
}

0 commit comments

Comments
 (0)