Skip to content

Commit 4fa10b5

Browse files
authored
kernelCTF: fix check-submission.py for v2 flags (#152)
In 57ace30 we introduced a new flag format but forgot to update the flag regex in check-submission.py so now it's rejecting valid submisisons that use the new format (e.g. #151).
1 parent 3247012 commit 4fa10b5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

kernelctf/check-submission.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
checkList(exploitFolders, lambda f: any(f.startswith(p) for p in validExploitFolderPrefixes),
4343
f"The submission folder name (`{subDirName}`) is not consistent with the exploits in the `{EXPLOIT_DIR}` folder. " +
4444
f"Based on the folder name (`{subDirName}`), the subfolders are expected to be prefixed with one of these: {', '.join(f'`{t}-`' for t in targets)}, " +
45-
"but this is not true for the following entries: <LIST>. You can put the extra files into a folder prefixed with `extra-`, " +
45+
"but this is not true for the following entries: <LIST>. You can put the extra files into a folder prefixed with `extra-`, " +
4646
"but try to make it clear what's the difference between this exploit and the others.")
4747

4848
reqFilesPerExploit = ["Makefile", "exploit.c", "exploit"]
@@ -121,7 +121,17 @@
121121
if cve != publicData["CVE"]:
122122
error(f"The CVE on the public spreadsheet for submission `{submissionId}` is `{publicData['CVE']}` but the PR is for `{cve}`.")
123123

124-
flagTargets = set([checkRegex(flag, r"kernelCTF\{v1:([^:]+):\d+\}", f"The flag (`{flag}`) is invalid").group(1) for flag in flags])
124+
flagRegex = r"kernelCTF\{(?:v1:([^:]+)|v2:([^:]+):([^:]*)):\d+\}"
125+
def flagTarget(flag):
126+
match = checkRegex(flag, flagRegex, f"The flag (`{flag}`) is invalid")
127+
if match.group(1):
128+
# v1 flag
129+
return match.group(1)
130+
131+
# v2 flag
132+
return match.group(2)
133+
134+
flagTargets = set([flagTarget(flag) for flag in flags])
125135
if "mitigation-6.1-v2" in flagTargets:
126136
flagTargets = flagTargets - {"mitigation-6.1-v2"} | {"mitigation-6.1"}
127137
print(f"[-] Got flags for the following targets: {', '.join(flagTargets)}")
@@ -153,4 +163,3 @@ def summary(success, text):
153163
ghSet("OUTPUT", f"artifact_backup_dir={'_'.join(submissionIds)}")
154164

155165
summary(True, f"✅ The file structure verification of the PR was successful!")
156-

0 commit comments

Comments
 (0)