Skip to content

Commit

Permalink
kernelCTF: fix check-submission.py for v2 flags
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
matrizzo committed Jan 7, 2025
1 parent 12f5ea9 commit 44f5c2c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions kernelctf/check-submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
checkList(exploitFolders, lambda f: any(f.startswith(p) for p in validExploitFolderPrefixes),
f"The submission folder name (`{subDirName}`) is not consistent with the exploits in the `{EXPLOIT_DIR}` folder. " +
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)}, " +
"but this is not true for the following entries: <LIST>. You can put the extra files into a folder prefixed with `extra-`, " +
"but this is not true for the following entries: <LIST>. You can put the extra files into a folder prefixed with `extra-`, " +
"but try to make it clear what's the difference between this exploit and the others.")

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

flagTargets = set([checkRegex(flag, r"kernelCTF\{v1:([^:]+):\d+\}", f"The flag (`{flag}`) is invalid").group(1) for flag in flags])
flagRegex = r"kernelCTF\{(?:v1:([^:]+)|v2:([^:]+):([^:]*)):\d+\}"
def flagTarget(flag):
match = checkRegex(flag, flagRegex, f"The flag (`{flag}`) is invalid")
if match.group(1):
# v1 flag
return match.group(1)

# v2 flag
return match.group(2)

flagTargets = set([flagTarget(flag) for flag in flags])
if "mitigation-6.1-v2" in flagTargets:
flagTargets = flagTargets - {"mitigation-6.1-v2"} | {"mitigation-6.1"}
print(f"[-] Got flags for the following targets: {', '.join(flagTargets)}")
Expand Down Expand Up @@ -153,4 +163,3 @@ def summary(success, text):
ghSet("OUTPUT", f"artifact_backup_dir={'_'.join(submissionIds)}")

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

0 comments on commit 44f5c2c

Please sign in to comment.