Skip to content

Commit bfb7d0d

Browse files
authored
fix(security): potential indexerror when parsing malformed readme (#632)
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>
1 parent 67d3746 commit bfb7d0d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

ensure_sorted.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def main():
7979
categories.append(category)
8080
# This is an app
8181
elif lines[i].startswith("*"):
82+
if not categories:
83+
raise RuntimeError("App entry found before any category header")
8284
# The last category in the categories list is the one we're working on
8385
category = categories[-1]
8486
category.add_app(lines[i])

0 commit comments

Comments
 (0)