From 3928cdef7cd1f4abd2112887e0ec4fe67b6f0542 Mon Sep 17 00:00:00 2001 From: shoko <270575765+shokollm@users.noreply.github.com> Date: Thu, 26 Mar 2026 19:10:40 +0000 Subject: [PATCH] security(polymarket-browse): validate --detail argument and show error if out of range - Add sys import for stderr/exit - Validate --detail index before accessing array - Show error with available range instead of silent fallback to first event - Exit with code 1 if --detail is out of range --- skills/polymarket-browse/scripts/browse.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/skills/polymarket-browse/scripts/browse.py b/skills/polymarket-browse/scripts/browse.py index e1af87b..8f7fb92 100644 --- a/skills/polymarket-browse/scripts/browse.py +++ b/skills/polymarket-browse/scripts/browse.py @@ -6,6 +6,7 @@ Browse tradeable Polymarket events by game category. import html import json +import sys import time import argparse import hashlib @@ -1224,10 +1225,15 @@ def main() -> None: # Print detail for selected event if any if result["match_events"] and args.detail > 0: - print("\n") idx = args.detail - 1 - if idx < 0 or idx >= len(result["match_events"]): - idx = 0 + num_events = len(result["match_events"]) + if idx < 0 or idx >= num_events: + print( + f"Error: --detail {args.detail} is out of range (available: 1-{num_events}).", + file=sys.stderr, + ) + sys.exit(1) + print("\n") detail_event = result["match_events"][idx] detail = format_detail_event(detail_event) print_detail(detail_event, detail)