mirror of
https://github.com/offa/android-foss.git
synced 2026-04-20 04:06:19 +05:30
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>
This commit is contained in:
parent
67d3746f69
commit
bfb7d0d758
1 changed files with 2 additions and 0 deletions
|
|
@ -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])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue