Skip to content

Commit 5803eb5

Browse files
committed
Merge branch 'master' into verbs-everywhere
2 parents 897c9aa + 7880e37 commit 5803eb5

File tree

94 files changed

+3937
-724
lines changed

Some content is hidden

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

94 files changed

+3937
-724
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Jenkins Security Scan
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
types: [ opened, synchronize, reopened ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
security-scan:
12+
uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v2
13+
with:
14+
java-cache: maven
15+
java-version: 11

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,3 @@ build/
1515

1616
# VS Code
1717
.vscode/
18-
19-
# maven-release-plugin
20-
pom.xml.releaseBackup
21-
release.properties

CHANGELOG.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Changelog
22

3+
Release notes for Version 3.0 and newer are published in [GitHub Releases](https://github.com/jenkinsci/matrix-auth-plugin/releases) only.
4+
5+
## Version 2.6.11 (2021-12-08)
6+
7+
* [JENKINS-67311](https://issues.jenkins.io/browse/JENKINS-67311): Fix help button for table ([#108](https://github.com/jenkinsci/matrix-auth-plugin/pull/108))
8+
9+
## Version 2.6.9 (2021-12-03)
10+
11+
* [JENKINS-67210](https://issues.jenkins.io/browse/JENKINS-67210): Fix broken link to global security configuration from help ([#106](https://github.com/jenkinsci/matrix-auth-plugin/pull/106))
12+
* [JENKINS-66964](https://issues.jenkins.io/browse/JENKINS-66964): Fix button tooltips in configuration matrix ([#107](https://github.com/jenkinsci/matrix-auth-plugin/pull/107))
13+
14+
## Version 2.6.8 (2021-07-21)
15+
16+
* [JENKINS-66170](https://issues.jenkins.io/browse/JENKINS-66170): Apply table style when viewing in read-only mode (Extended Read permission).
17+
This fixes a regression in version 2.6.7.
18+
19+
## Version 2.6.7 (2021-05-12)
20+
21+
* Internal: Moved JavaScript to resource files ([#102](https://github.com/jenkinsci/matrix-auth-plugin/pull/102))
22+
* Internal: Migrate from RestartableJenkinsRule to JenkinsSessionRule ([#101](https://github.com/jenkinsci/matrix-auth-plugin/pull/101))
23+
24+
## Version 2.6.6 (2021-03-18)
25+
26+
* [SECURITY-2180](https://www.jenkins.io/security/advisory/2021-03-18/#SECURITY-2180): Ensure Item/Read is only granted it all ancestors grant it as well.
27+
328
## Version 2.6.5 (2021-01-21)
429

530
* [JENKINS-64661](https://issues.jenkins.io/browse/JENKINS-64661): Do not break `properties` in the global Pipeline snippet generator.
@@ -12,7 +37,7 @@
1237

1338
* [JENKINS-56109](https://issues.jenkins.io/browse/JENKINS-56109): Make the plugin compatible with new form layout in Jenkins 2.264 and newer.
1439
* Open links from job, folder, and agent configurations to the Global Security Configuration in a new window.
15-
* Internal: Parent POM update, make test assertions compatible with JEP-295
40+
* Internal: Parent POM update, make test assertions compatible with [JEP-295](https://github.com/jenkinsci/jep/blob/master/jep/295/README.adoc)
1641

1742
## Version 2.6.2 (2020-07-15)
1843

@@ -69,7 +94,6 @@
6994
## Version 2.3 (2018-07-10)
7095

7196
* [JENKINS-52167](https://issues.jenkins.io/browse/JENKINS-52167): Rotate column headers in Google Chrome
72-
7397
* [JENKINS-47424](https://issues.jenkins.io/browse/JENKINS-47424): Don't show 'Implied by' note for the Overall/Administer permission
7498
* [JENKINS-28668](https://issues.jenkins.io/browse/JENKINS-28668): Use a modal dialog to add users/groups to the list to prevent accidental form submissions
7599

@@ -105,9 +129,9 @@
105129
* **Allow configuring per-agent permissions.** This allows e.g. restricting per-agent build permissions when using the Authorize Project plugin ([JENKINS-46654](https://issues.jenkins.io/browse/JENKINS-46654))
106130
* **Prevent accidental lockouts and unexpected lack of permissions**
107131
* Improvement: When submitting a global matrix auth configuration that does not specify an administrator (often happening in accidental/premature form submissions), give the submitting user Administer permission. Note that this could mean that the 'anonymous' may still have admin permission if the form is submitted as an anonymous user. ([JENKINS-46832](https://issues.jenkins.io/browse/JENKINS-46832) / [JENKINS-10871](https://issues.jenkins.io/browse/JENKINS-10871))
108-
* Bug: Ensure that users creating a new job, folder, or node have read and configure access when using the project-based matrix authorization strategy. (<span class="js-issue-title">JENKINS-5277</span>)
132+
* Bug: Ensure that users creating a new job, folder, or node have read and configure access when using the project-based matrix authorization strategy. ([JENKINS-5277](https://issues.jenkins.io/browse/JENKINS-5277))
109133
* Bug: Save the global security configuration after granting administer permission to the first user to sign up. ([JENKINS-20520](https://issues.jenkins.io/browse/JENKINS-20520))
110-
* Bug: Ensure 'empty' matrix permission configurations can be loaded in case this is needed (e.g. programmatically defined). The fix for [JENKINS-10871](https://issues.jenkins.io/browse/JENKINS-10871) will prevent this from happening accidentally. (JENKINS-9774)
134+
* Bug: Ensure 'empty' matrix permission configurations can be loaded in case this is needed (e.g. programmatically defined). The fix for [JENKINS-10871](https://issues.jenkins.io/browse/JENKINS-10871) will prevent this from happening accidentally. ([JENKINS-9774](https://issues.jenkins.io/browse/JENKINS-9774))
111135
* Bug: When using container-based authentication and project-based matrix authorization, permissions granted to groups in items inside folders only may not have been granted to members of those groups.
112136
* **UX improvements for the matrix configuration table**
113137
* Improvement: Indicate whether a permission is implied by another permission in the tool tip, and also indicate when a permission is not implied by Overall/Administer (which is unusual). ([JENKINS-32506](https://issues.jenkins.io/browse/JENKINS-32506))

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ For a basic introduction, see [the section on Matrix Authorization in the Jenkin
66

77
## Changelog
88

9-
See [CHANGELOG](CHANGELOG.md).
9+
See [GitHub Releases](https://github.com/jenkinsci/matrix-auth-plugin/releases) (2.6.5 and newer only) or [CHANGELOG](CHANGELOG.md) (before 3.0 only).
1010

1111
## Use Cases
1212

pom.xml

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,20 @@
44
<parent>
55
<groupId>org.jenkins-ci.plugins</groupId>
66
<artifactId>plugin</artifactId>
7-
<version>4.7</version>
7+
<version>4.37</version>
88
</parent>
99
<artifactId>matrix-auth</artifactId>
1010
<version>${revision}${changelist}</version>
1111
<packaging>hpi</packaging>
1212
<name>Matrix Authorization Strategy Plugin</name>
1313
<url>https://github.com/jenkinsci/matrix-auth-plugin</url>
1414
<properties>
15-
<revision>2.6.6</revision>
15+
<revision>3.2</revision>
1616
<changelist>-SNAPSHOT</changelist>
1717
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
18-
<hpi.compatibleSinceVersion>2.0</hpi.compatibleSinceVersion>
19-
<jenkins.version>2.222.1</jenkins.version>
18+
<hpi.compatibleSinceVersion>3.0</hpi.compatibleSinceVersion>
19+
<jenkins.version>2.277.1</jenkins.version>
2020
<java.level>8</java.level>
21-
<workflow-cps.version>2.31</workflow-cps.version>
22-
<configuration-as-code.version>1.35</configuration-as-code.version>
2321
</properties>
2422
<licenses>
2523
<license>
@@ -33,58 +31,57 @@
3331
<url>https://github.com/${gitHubRepo}</url>
3432
<tag>${scmTag}</tag>
3533
</scm>
34+
35+
<dependencyManagement>
36+
<dependencies>
37+
<dependency>
38+
<groupId>io.jenkins.tools.bom</groupId>
39+
<artifactId>bom-2.277.x</artifactId>
40+
<version>28</version>
41+
<scope>import</scope>
42+
<type>pom</type>
43+
</dependency>
44+
</dependencies>
45+
</dependencyManagement>
46+
3647
<dependencies>
3748
<!-- optional plugin dependencies -->
3849
<dependency>
3950
<groupId>org.jenkins-ci.plugins</groupId>
4051
<artifactId>cloudbees-folder</artifactId>
41-
<version>6.1.0</version>
4252
<optional>true</optional>
4353
</dependency>
4454
<dependency>
4555
<groupId>io.jenkins</groupId>
4656
<artifactId>configuration-as-code</artifactId>
47-
<version>${configuration-as-code.version}</version>
4857
<optional>true</optional>
4958
</dependency>
5059

5160
<!-- test dependencies -->
5261
<dependency>
5362
<groupId>org.jenkins-ci.plugins</groupId>
5463
<artifactId>credentials</artifactId>
55-
<version>2.1.16</version>
5664
<scope>test</scope>
5765
</dependency>
5866
<dependency>
5967
<groupId>org.jenkins-ci.plugins.workflow</groupId>
6068
<artifactId>workflow-cps</artifactId>
61-
<version>${workflow-cps.version}</version>
6269
<scope>test</scope>
6370
</dependency>
6471
<dependency>
6572
<groupId>org.jenkins-ci.plugins.workflow</groupId>
6673
<artifactId>workflow-cps</artifactId>
67-
<version>${workflow-cps.version}</version>
6874
<classifier>tests</classifier>
6975
<scope>test</scope>
7076
</dependency>
7177
<dependency>
7278
<groupId>org.jenkins-ci.plugins.workflow</groupId>
7379
<artifactId>workflow-multibranch</artifactId>
74-
<version>2.10</version>
75-
<scope>test</scope>
76-
</dependency>
77-
<dependency>
78-
<!-- requireUpperBoundDeps -->
79-
<groupId>org.jenkins-ci.plugins</groupId>
80-
<artifactId>structs</artifactId>
81-
<version>1.19</version>
8280
<scope>test</scope>
8381
</dependency>
8482
<dependency>
8583
<groupId>io.jenkins.configuration-as-code</groupId>
8684
<artifactId>test-harness</artifactId>
87-
<version>${configuration-as-code.version}</version>
8885
<scope>test</scope>
8986
</dependency>
9087
<dependency>
@@ -100,13 +97,6 @@
10097
</exclusion>
10198
</exclusions>
10299
</dependency>
103-
<dependency>
104-
<!-- requireUpperBounds -->
105-
<groupId>org.jenkins-ci.plugins</groupId>
106-
<artifactId>script-security</artifactId>
107-
<version>1.54</version>
108-
<scope>test</scope>
109-
</dependency>
110100
</dependencies>
111101

112102
<repositories>

src/main/java/com/cloudbees/hudson/plugins/folder/properties/AuthorizationMatrixProperty.java

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.cloudbees.hudson.plugins.folder.AbstractFolder;
2727
import com.cloudbees.hudson.plugins.folder.AbstractFolderProperty;
2828
import com.cloudbees.hudson.plugins.folder.AbstractFolderPropertyDescriptor;
29+
import edu.umd.cs.findbugs.annotations.NonNull;
2930
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3031
import hudson.Extension;
3132
import hudson.model.AbstractItem;
@@ -34,6 +35,7 @@
3435
import hudson.model.listeners.ItemListener;
3536
import hudson.security.AuthorizationStrategy;
3637
import jenkins.model.Jenkins;
38+
import org.acegisecurity.acls.sid.PrincipalSid;
3739
import org.jenkinsci.Symbol;
3840
import org.jenkinsci.plugins.matrixauth.AuthorizationPropertyDescriptor;
3941
import hudson.security.Permission;
@@ -45,6 +47,8 @@
4547
import hudson.util.FormValidation;
4648
import net.sf.json.JSONObject;
4749
import org.acegisecurity.acls.sid.Sid;
50+
import org.jenkinsci.plugins.matrixauth.AuthorizationType;
51+
import org.jenkinsci.plugins.matrixauth.PermissionEntry;
4852
import org.kohsuke.accmod.Restricted;
4953
import org.kohsuke.accmod.restrictions.DoNotUse;
5054
import org.kohsuke.accmod.restrictions.NoExternalUse;
@@ -64,10 +68,10 @@
6468
import java.util.HashSet;
6569
import java.util.List;
6670
import java.util.Map;
67-
import java.util.Map.Entry;
6871
import java.util.Set;
6972
import java.util.logging.Level;
7073
import java.util.logging.Logger;
74+
import java.util.stream.Collectors;
7175

7276
/**
7377
* Holds ACL for {@link ProjectMatrixAuthorizationStrategy}.
@@ -78,13 +82,10 @@ public class AuthorizationMatrixProperty extends AbstractFolderProperty<Abstract
7882

7983
/**
8084
* List up all permissions that are granted.
81-
*
82-
* Strings are either the granted authority or the principal, which is not
83-
* distinguished.
8485
*/
85-
private final Map<Permission, Set<String>> grantedPermissions = new HashMap<>();
86+
private final Map<Permission, Set<PermissionEntry>> grantedPermissions = new HashMap<>();
8687

87-
private final Set<String> sids = new HashSet<>();
88+
private final Set<String> groupSids = Collections.synchronizedSet(new HashSet<>());
8889

8990
/**
9091
* @deprecated unused, use {@link #setInheritanceStrategy(InheritanceStrategy)} instead.
@@ -99,10 +100,12 @@ public class AuthorizationMatrixProperty extends AbstractFolderProperty<Abstract
99100
protected AuthorizationMatrixProperty() {
100101
}
101102

103+
// TODO(3.0) How is this used?
104+
@Deprecated
102105
public AuthorizationMatrixProperty(Map<Permission,? extends Set<String>> grantedPermissions) {
103-
// do a deep copy to be safe
104-
for (Entry<Permission,? extends Set<String>> e : grantedPermissions.entrySet())
105-
this.grantedPermissions.put(e.getKey(),new HashSet<>(e.getValue()));
106+
for (Map.Entry<Permission,? extends Set<String>> e : grantedPermissions.entrySet()) {
107+
this.grantedPermissions.put(e.getKey(), e.getValue().stream().map(sid -> new PermissionEntry(AuthorizationType.EITHER, sid)).collect(Collectors.toSet()));
108+
}
106109
}
107110

108111
@DataBoundConstructor // JENKINS-49199: Used for job-dsl
@@ -113,37 +116,30 @@ public AuthorizationMatrixProperty(List<String> permissions) {
113116
}
114117
}
115118

116-
@Restricted(NoExternalUse.class)
119+
@Override
117120
public Set<String> getGroups() {
118-
return new HashSet<>(sids);
121+
return groupSids;
119122
}
120123

121-
/**
122-
* Returns all the (Permission,sid) pairs that are granted, in the multi-map form.
123-
*
124-
* @return
125-
* read-only. never null.
126-
*/
127-
public Map<Permission,Set<String>> getGrantedPermissions() {
128-
return Collections.unmodifiableMap(grantedPermissions);
124+
@Override
125+
public void recordGroup(String sid) {
126+
this.groupSids.add(sid);
127+
}
128+
129+
@Override
130+
public Map<Permission, Set<PermissionEntry>> getGrantedPermissionEntries() {
131+
return grantedPermissions;
129132
}
130133

131134
@Override
132135
public Permission getEditingPermission() {
133136
return Item.CONFIGURE;
134137
}
135138

136-
/**
137-
* Adds to {@link #grantedPermissions}. Use of this method should be limited
138-
* during construction, as this object itself is considered immutable once
139-
* populated.
140-
*/
141-
public void add(Permission p, String sid) {
142-
Set<String> set = grantedPermissions.get(p);
143-
if (set == null)
144-
grantedPermissions.put(p, set = new HashSet<>());
145-
set.add(sid);
146-
sids.add(sid);
139+
@Override
140+
protected void setOwner(@NonNull AbstractFolder<?> owner) {
141+
super.setOwner(owner);
142+
FolderContributor.record(owner);
147143
}
148144

149145
@Extension(optional = true)
@@ -166,7 +162,6 @@ public AuthorizationMatrixProperty newInstance(StaplerRequest req, JSONObject fo
166162
}
167163

168164
@Override
169-
@SuppressWarnings("rawtypes")
170165
public boolean isApplicable(Class<? extends AbstractFolder> folder) {
171166
return isApplicable();
172167
}
@@ -182,7 +177,7 @@ private final class AclImpl extends SidACL {
182177
@SuppressFBWarnings(value = "NP_BOOLEAN_RETURN_NULL",
183178
justification = "Because that is the way this SPI works")
184179
protected Boolean hasPermission(Sid sid, Permission p) {
185-
if (AuthorizationMatrixProperty.this.hasPermission(toString(sid),p))
180+
if (AuthorizationMatrixProperty.this.hasPermission(toString(sid), p, sid instanceof PrincipalSid))
186181
return true;
187182
return null;
188183
}
@@ -202,12 +197,12 @@ public InheritanceStrategy getInheritanceStrategy() {
202197
}
203198

204199
/**
205-
* Persist {@link ProjectMatrixAuthorizationStrategy} as a list of IDs that
206-
* represent ProjectMatrixAuthorizationStrategy#grantedPermissions.
200+
* Persist {@link AuthorizationMatrixProperty} as a list of IDs that
201+
* represent {@link AuthorizationMatrixProperty#getGrantedPermissions()}.
207202
*/
208203
@Restricted(DoNotUse.class)
204+
@SuppressWarnings("unused")
209205
public static final class ConverterImpl extends AbstractAuthorizationPropertyConverter<AuthorizationMatrixProperty> {
210-
@SuppressWarnings("rawtypes")
211206
public boolean canConvert(Class type) {
212207
return type == AuthorizationMatrixProperty.class;
213208
}
@@ -241,13 +236,13 @@ public void onCreated(Item item) {
241236
User current = User.current();
242237
String sid = current == null ? "anonymous" : current.getId();
243238

244-
if (!strategy.getACL((AbstractItem) folder).hasPermission(Jenkins.getAuthentication(), Item.READ)) {
245-
prop.add(Item.READ, sid);
239+
if (!strategy.getACL((AbstractItem) folder).hasPermission2(Jenkins.getAuthentication2(), Item.READ)) {
240+
prop.add(Item.READ, PermissionEntry.user(sid));
246241
}
247-
if (!strategy.getACL((AbstractItem) folder).hasPermission(Jenkins.getAuthentication(), Item.CONFIGURE)) {
248-
prop.add(Item.CONFIGURE, sid);
242+
if (!strategy.getACL((AbstractItem) folder).hasPermission2(Jenkins.getAuthentication2(), Item.CONFIGURE)) {
243+
prop.add(Item.CONFIGURE, PermissionEntry.user(sid));
249244
}
250-
if (prop.getGrantedPermissions().size() > 0) {
245+
if (prop.getGrantedPermissionEntries().size() > 0) {
251246
try {
252247
if (propIsNew) {
253248
folder.addProperty(prop);

0 commit comments

Comments
 (0)