Skip to content

Commit 873aa29

Browse files
[GitHub] Make release audit more strict for LLVM 19 and beyond (#125841)
Before 19, we had releases from release managers, the bot, and community members. 19 started to restrict this, with only select community members uploading releases. The lists of users are written out each time to make modifying this easier. If we cannot parse the release number, I've made it raise an issue saying so. Since this may also be a sign of a malicious action.
1 parent 60493ed commit 873aa29

File tree

1 file changed

+63
-27
lines changed

1 file changed

+63
-27
lines changed

.github/workflows/release-asset-audit.py

Lines changed: 63 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import github
2+
import re
23
import sys
34

45
_SPECIAL_CASE_BINARIES = {
@@ -16,38 +17,73 @@ def _is_valid(uploader_name, valid_uploaders, asset_name):
1617
return False
1718

1819

20+
def _get_uploaders(release_version):
21+
# Until llvm 18, assets were uploaded by community members, the release managers
22+
# and the GitHub Actions bot.
23+
if release_version <= 18:
24+
return set(
25+
[
26+
"DimitryAndric",
27+
"stefanp-ibm",
28+
"lei137",
29+
"omjavaid",
30+
"nicolerabjohn",
31+
"amy-kwan",
32+
"mandlebug",
33+
"zmodem",
34+
"androm3da",
35+
"tru",
36+
"rovka",
37+
"rorth",
38+
"quinnlp",
39+
"kamaub",
40+
"abrisco",
41+
"jakeegan",
42+
"maryammo",
43+
"tstellar",
44+
"github-actions[bot]",
45+
]
46+
)
47+
# llvm 19 and beyond, only the release managers, bot and a much smaller
48+
# number of community members.
49+
elif release_version >= 19:
50+
return set(
51+
[
52+
"zmodem",
53+
"omjavaid",
54+
"tru",
55+
"tstellar",
56+
"github-actions[bot]",
57+
]
58+
)
59+
60+
61+
def _get_major_release_version(release_title):
62+
# All release titles are of the form "LLVM X.Y.Z(-rcN)".
63+
match = re.match("LLVM ([0-9]+)\.", release_title)
64+
if match is None:
65+
_write_comment_and_exit_with_error(
66+
f'Could not parse release version from release title "{release_title}".'
67+
)
68+
else:
69+
return int(match.groups()[0])
70+
71+
72+
def _write_comment_and_exit_with_error(comment):
73+
with open("comment", "w") as file:
74+
file.write(comment)
75+
sys.exit(1)
76+
77+
1978
def main():
2079
token = sys.argv[1]
2180

2281
gh = github.Github(login_or_token=token)
2382
repo = gh.get_repo("llvm/llvm-project")
2483

25-
uploaders = set(
26-
[
27-
"DimitryAndric",
28-
"stefanp-ibm",
29-
"lei137",
30-
"omjavaid",
31-
"nicolerabjohn",
32-
"amy-kwan",
33-
"mandlebug",
34-
"zmodem",
35-
"androm3da",
36-
"tru",
37-
"rovka",
38-
"rorth",
39-
"quinnlp",
40-
"kamaub",
41-
"abrisco",
42-
"jakeegan",
43-
"maryammo",
44-
"tstellar",
45-
"github-actions[bot]",
46-
]
47-
)
48-
4984
for release in repo.get_releases():
5085
print("Release:", release.title)
86+
uploaders = _get_uploaders(_get_major_release_version(release.title))
5187
for asset in release.get_assets():
5288
created_at = asset.created_at
5389
updated_at = (
@@ -57,9 +93,9 @@ def main():
5793
f"{asset.name} : {asset.uploader.login} [{created_at} {updated_at}] ( {asset.download_count} )"
5894
)
5995
if not _is_valid(asset.uploader.login, uploaders, asset.name):
60-
with open('comment', 'w') as file:
61-
file.write(f'@{asset.uploader.login} is not a valid uploader.')
62-
sys.exit(1)
96+
_write_comment_and_exit_with_error(
97+
f"@{asset.uploader.login} is not a valid uploader."
98+
)
6399

64100

65101
if __name__ == "__main__":

0 commit comments

Comments
 (0)