From bfb7d0d7580fc8c9aedf546d5b2dc0e112a2ab46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20B=C3=A1ch?= <45133811+barttran2k@users.noreply.github.com> Date: Wed, 8 Apr 2026 01:15:24 +0700 Subject: [PATCH] fix(security): potential indexerror when parsing malformed readme (#632) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a line starting with `*` (app entry) appears before any category header (`### •` or `## –`), `categories[-1]` will raise an `IndexError` because the `categories` list will be empty. A malformed or tampered README.md could cause the CI script to crash with an unhandled exception. Affected files: ensure_sorted.py Signed-off-by: Trần Bách <45133811+barttran2k@users.noreply.github.com> --- ensure_sorted.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ensure_sorted.py b/ensure_sorted.py index 50b6683..a4a91aa 100755 --- a/ensure_sorted.py +++ b/ensure_sorted.py @@ -79,6 +79,8 @@ def main(): categories.append(category) # This is an app elif lines[i].startswith("*"): + if not categories: + raise RuntimeError("App entry found before any category header") # The last category in the categories list is the one we're working on category = categories[-1] category.add_app(lines[i])