Skip to content

Commit a5854b9

Browse files
authored
Merge pull request #1728 from Kobzol/remove-admin
Forbid admin permissions
2 parents a25982a + bd8084f commit a5854b9

File tree

9 files changed

+48
-11
lines changed

9 files changed

+48
-11
lines changed

repos/rust-lang/crates.io-index-archive.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "Archive of the crates.io-index commit history after squashes"
44
bots = []
55

66
[access.teams]
7-
crates-io = "admin"
7+
crates-io = "maintain"
88

99
[[branch-protections]]
1010
pattern = "snapshot-*"

repos/rust-lang/sync-team.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ bots = []
55

66
[access.teams]
77
infra = "write"
8-
infra-admins = "admin"
8+
infra-admins = "maintain"
99

1010
[[branch-protections]]
1111
pattern = "master"

repos/rust-lang/www.rust-lang.org.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ homepage = "https://www.rust-lang.org"
55
bots = ["rustbot"]
66

77
[access.teams]
8-
# Admin is needed for integrating with external services, e.g. Pontoon
9-
website = "admin"
8+
# Maintain is needed for integrating with external services, e.g. Pontoon
9+
website = "maintain"
1010

1111
[[branch-protections]]
1212
pattern = "master"

src/validate.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use crate::data::Data;
22
use crate::github::GitHubApi;
3-
use crate::schema::{Bot, Email, MergeBot, Permissions, Team, TeamKind, TeamPeople, ZulipMember};
3+
use crate::schema::{
4+
Bot, Email, MergeBot, Permissions, RepoPermission, Team, TeamKind, TeamPeople, ZulipMember,
5+
};
46
use crate::zulip::ZulipApi;
57
use anyhow::{bail, Error};
68
use log::{error, warn};
@@ -51,6 +53,7 @@ static CHECKS: &[Check<fn(&Data, &mut Vec<String>)>] = checks![
5153
validate_repos,
5254
validate_branch_protections,
5355
validate_member_roles,
56+
validate_admin_access,
5457
validate_website,
5558
];
5659

@@ -1024,6 +1027,40 @@ fn validate_member_roles(data: &Data, errors: &mut Vec<String>) {
10241027
);
10251028
}
10261029

1030+
/// Validate that admin access is not used anywhere
1031+
fn validate_admin_access(data: &Data, errors: &mut Vec<String>) {
1032+
wrapper(data.all_repos(), errors, |repo, errors| {
1033+
wrapper(repo.access.teams.iter(), errors, |(team, permission), _| {
1034+
if let RepoPermission::Admin = permission {
1035+
bail!(
1036+
"Repository {}/{} uses `admin` permission for team `{team}`",
1037+
repo.org,
1038+
repo.name
1039+
);
1040+
} else {
1041+
Ok(())
1042+
}
1043+
});
1044+
wrapper(
1045+
repo.access.individuals.iter(),
1046+
errors,
1047+
|(member, permission), _| {
1048+
if let RepoPermission::Admin = permission {
1049+
bail!(
1050+
"Repository {}/{} uses `admin` permission for member `{member}`",
1051+
repo.org,
1052+
repo.name
1053+
);
1054+
} else {
1055+
Ok(())
1056+
}
1057+
},
1058+
);
1059+
1060+
Ok(())
1061+
});
1062+
}
1063+
10271064
/// We use Fluent ids which are lowercase alphanumeric with hyphens.
10281065
fn ascii_kebab_case(s: &str) -> bool {
10291066
s.chars()

tests/static-api/_expected/v1/repos.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"teams": [
1010
{
1111
"name": "foo",
12-
"permission": "admin"
12+
"permission": "maintain"
1313
}
1414
],
1515
"members": [],
@@ -42,7 +42,7 @@
4242
"teams": [
4343
{
4444
"name": "foo",
45-
"permission": "admin"
45+
"permission": "maintain"
4646
}
4747
],
4848
"members": [],

tests/static-api/_expected/v1/repos/archived_repo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"teams": [
88
{
99
"name": "foo",
10-
"permission": "admin"
10+
"permission": "maintain"
1111
}
1212
],
1313
"members": [],

tests/static-api/_expected/v1/repos/some_repo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"teams": [
88
{
99
"name": "foo",
10-
"permission": "admin"
10+
"permission": "maintain"
1111
}
1212
],
1313
"members": [],

tests/static-api/repos/archive/test-org/archived_repo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "An archived repo!"
44
bots = []
55

66
[access.teams]
7-
foo = "admin"
7+
foo = "maintain"
88

99
[[branch-protections]]
1010
pattern = "master"

tests/static-api/repos/test-org/some_repo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "A repo!"
44
bots = []
55

66
[access.teams]
7-
foo = "admin"
7+
foo = "maintain"
88

99
[[branch-protections]]
1010
pattern = "master"

0 commit comments

Comments
 (0)